Showing 10 of 12 total issues
Method attr_encrypted
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def attr_encrypted(*attributes)
options = attributes.last.is_a?(Hash) ? attributes.pop : {}
options = attr_encrypted_default_options.dup.merge!(attr_encrypted_options).merge!(options)
options[:encode] = options[:default_encoding] if options[:encode] == true
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method attr_encrypted
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def attr_encrypted(*attrs)
super
options = attrs.extract_options!
attr = attrs.pop
attribute attr
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method evaluated_attr_encrypted_options_for
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def evaluated_attr_encrypted_options_for(attribute)
evaluated_options = Hash.new
attributes = attr_encrypted_encrypted_attributes[attribute.to_sym]
attribute_option_value = attributes[:attribute]
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method attr_encrypted
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def attr_encrypted(*attributes)
options = attributes.last.is_a?(Hash) ? attributes.pop : {}
options = attr_encrypted_default_options.dup.merge!(attr_encrypted_options).merge!(options)
options[:encode] = options[:default_encoding] if options[:encode] == true
Method extended
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.extended(base) # :nodoc:
base.class_eval do
# https://github.com/attr-encrypted/attr_encrypted/issues/68
alias_method :reload_without_attr_encrypted, :reload
Method load_iv_for_attribute
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def load_iv_for_attribute(attribute, options)
encrypted_attribute_name = options[:attribute]
encode_iv = options[:encode_iv]
iv = options[:iv] || send("#{encrypted_attribute_name}_iv")
if options[:operation] == :encrypting
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method attr_encrypted_decrypt
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def attr_encrypted_decrypt(attribute, encrypted_value, options = {})
options = attr_encrypted_encrypted_attributes[attribute.to_sym].merge(options)
if options[:if] && !options[:unless] && not_empty?(encrypted_value)
encrypted_value = encrypted_value.unpack(options[:encode]).first if options[:encode]
value = options[:encryptor].send(options[:decrypt_method], options.merge!(value: encrypted_value))
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method attr_encrypted_encrypt
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def attr_encrypted_encrypt(attribute, value, options = {})
options = attr_encrypted_encrypted_attributes[attribute.to_sym].merge(options)
if options[:if] && !options[:unless] && (options[:allow_empty_value] || not_empty?(value))
value = options[:marshal] ? options[:marshaler].send(options[:dump_method], value) : value.to_s
encrypted_value = options[:encryptor].send(options[:encrypt_method], options.merge!(value: value))
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method load_salt_for_attribute
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def load_salt_for_attribute(attribute, options)
encrypted_attribute_name = options[:attribute]
encode_salt = options[:encode_salt]
salt = options[:salt] || send("#{encrypted_attribute_name}_salt")
if options[:operation] == :encrypting
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method method_missing_with_attr_encrypted
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def method_missing_with_attr_encrypted(method, *args, &block)
if match = /^(find|scoped)_(all_by|by)_([_a-zA-Z]\w*)$/.match(method.to_s)
attribute_names = match.captures.last.split('_and_')
attribute_names.each_with_index do |attribute, index|
if attr_encrypted?(attribute) && attr_encrypted_encrypted_attributes[attribute.to_sym][:mode] == :single_iv_and_salt
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"