Skip to content
Snippets Groups Projects
Verified Commit 0e5ebf96 authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

Make rubocop happier

parent b10bfc3e
No related branches found
No related tags found
No related merge requests found
Pipeline #121177 failed
# frozen_string_literal: true
require 'logging'
require 'pp'
require 'passwordstate/version'
require 'passwordstate/client'
require 'passwordstate/errors'
......
......@@ -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 = [])
......
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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)
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment