lib/chef/encrypted_attribute/search_helper.rb
Class EncryptedAttribute
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class EncryptedAttribute
# Search Helpers to do normal or partial searches.
module SearchHelper
extend self
Method parse_partial_search_response
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def parse_partial_search_response(resp, name, keys)
filter_partial_search_response(resp['rows'], name).map do |row|
if row.is_a?(Hash) && row['data'].is_a?(Hash)
row['data'].tap { |r| r.delete('name') unless keys.key?('name') }
else
- 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 search
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def search(type, query, keys, rows = 1000, partial_search = true)
Method normal_search
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def normal_search(type, name, query, keys, rows = 1000)
Method partial_search
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def partial_search(type, name, query, keys, rows = 1000)
Method search_by_name
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def search_by_name(type, name, keys, rows = 1000, partial_search = true)
Method parse_normal_search_row_attribute
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def parse_normal_search_row_attribute(row, attr_ary)
attr_ary.reduce(row) do |r, attr|
if r.respond_to?(attr)
r.send(attr)
elsif r.respond_to?(:key?)
- 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"