From 0e5ebf96dbe71f3b51d4aa0801489040a107a1b2 Mon Sep 17 00:00:00 2001 From: Alexander Olofsson <alexander.olofsson@liu.se> Date: Wed, 27 Mar 2024 10:04:18 +0100 Subject: [PATCH] Make rubocop happier --- lib/passwordstate.rb | 1 - lib/passwordstate/errors.rb | 2 +- lib/passwordstate/resource.rb | 4 ++-- lib/passwordstate/resource_list.rb | 4 ++-- lib/passwordstate/resources/document.rb | 10 +++++----- lib/passwordstate/resources/password.rb | 6 ++++-- lib/passwordstate/resources/password_list.rb | 2 +- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/passwordstate.rb b/lib/passwordstate.rb index d9e0ea2..f195421 100644 --- a/lib/passwordstate.rb +++ b/lib/passwordstate.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'logging' -require 'pp' require 'passwordstate/version' require 'passwordstate/client' require 'passwordstate/errors' diff --git a/lib/passwordstate/errors.rb b/lib/passwordstate/errors.rb index 2f4fd02..8ebf62e 100644 --- a/lib/passwordstate/errors.rb +++ b/lib/passwordstate/errors.rb @@ -15,7 +15,7 @@ module Passwordstate @errors = errors errorstr = errors.map { |err| err['message'] || err['phrase'] || err['error'] }.join('; ') - super "Passwordstate responded with an error to the request:\n#{errorstr}" + super("Passwordstate responded with an error to the request:\n#{errorstr}") end def self.new_by_code(code, req, res, errors = []) diff --git a/lib/passwordstate/resource.rb b/lib/passwordstate/resource.rb index 77a5467..2955714 100644 --- a/lib/passwordstate/resource.rb +++ b/lib/passwordstate/resource.rb @@ -126,7 +126,7 @@ module Passwordstate nil_as_string = opts.fetch(:nil_as_string, self.class.nil_as_string) (self.class.send(:accessor_field_names) + self.class.send(:read_field_names) + self.class.send(:write_field_names)).to_h do |field| redact = self.class.send(:field_options)[field]&.fetch(:redact, false) && !ignore_redact - at_field = "@#{field}".to_sym + at_field = :"@#{field}" field = at_field if atify value = instance_variable_get(at_field) unless redact value = '[ REDACTED ]' if redact @@ -190,7 +190,7 @@ module Passwordstate parsed_value = convert.call(value, direction: :from) end - instance_variable_set "@#{field}".to_sym, parsed_value || value + instance_variable_set :"@#{field}", parsed_value || value end self end diff --git a/lib/passwordstate/resource_list.rb b/lib/passwordstate/resource_list.rb index 0a02722..240826f 100644 --- a/lib/passwordstate/resource_list.rb +++ b/lib/passwordstate/resource_list.rb @@ -62,11 +62,11 @@ module Passwordstate end def operation_supported?(operation) - return nil unless %i[search all get post put delete].include?(operation) + return false unless %i[search all get post put delete].include?(operation) return false if options.key?(:only) && !options[:only].include?(operation) return false if options.key?(:except) && options[:except].include?(operation) - !options.fetch("#{operation}_path".to_sym, '').nil? + !options.fetch(:"#{operation}_path", '').nil? end def new(data) diff --git a/lib/passwordstate/resources/document.rb b/lib/passwordstate/resources/document.rb index 26decca..678cae3 100644 --- a/lib/passwordstate/resources/document.rb +++ b/lib/passwordstate/resources/document.rb @@ -13,7 +13,7 @@ module Passwordstate alias title document_name def self.all(client, store, **query) - super client, query.merge(_api_path: "#{api_path}/#{validate_store! store}") + super(client, query.merge(_api_path: "#{api_path}/#{validate_store! store}")) end def self.search(client, store, **options) @@ -21,19 +21,19 @@ module Passwordstate end def self.get(client, store, object) - super client, object, _api_path: "#{api_path}/#{validate_store! store}" + super(client, object, _api_path: "#{api_path}/#{validate_store! store}") end def self.post(client, store, data, **query) - super client, data, query.merge(_api_path: "#{api_path}/#{validate_store! store}") + super(client, data, query.merge(_api_path: "#{api_path}/#{validate_store! store}")) end def self.put(client, store, data, **query) - super client, data, query.merge(_api_path: "#{api_path}/#{validate_store! store}") + super(client, data, query.merge(_api_path: "#{api_path}/#{validate_store! store}")) end def self.delete(client, store, object, **query) - super client, object, query.merge(_api_path: "#{api_path}/#{validate_store! store}") + super(client, object, query.merge(_api_path: "#{api_path}/#{validate_store! store}")) end class << self diff --git a/lib/passwordstate/resources/password.rb b/lib/passwordstate/resources/password.rb index 69b88fd..d5f58c2 100644 --- a/lib/passwordstate/resources/password.rb +++ b/lib/passwordstate/resources/password.rb @@ -112,11 +112,13 @@ module Passwordstate end def self.all(client, **query) - super client, **{ query_all: true }.merge(query) + query = { query_all: true }.merge(query) + super(client, **query) end def self.search(client, **query) - super client, **{ _api_path: 'searchpasswords' }.merge(query) + query = { _api_path: 'searchpasswords' }.merge(query) + super(client, **query) end def self.generate(client, **options) diff --git a/lib/passwordstate/resources/password_list.rb b/lib/passwordstate/resources/password_list.rb index 39f0e9b..3160d41 100644 --- a/lib/passwordstate/resources/password_list.rb +++ b/lib/passwordstate/resources/password_list.rb @@ -70,7 +70,7 @@ module Passwordstate alias title password_list def self.search(client, **query) - super client, **query.merge(_api_path: 'searchpasswordlists') + super(client, **query.merge(_api_path: 'searchpasswordlists')) end def passwords -- GitLab