zuazo/chef-encrypted-attributes

View on GitHub
lib/chef/encrypted_attribute/search_helper.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Class EncryptedAttribute has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class EncryptedAttribute
    # Search Helpers to do normal or partial searches.
    module SearchHelper
      extend self

Severity: Minor
Found in lib/chef/encrypted_attribute/search_helper.rb - About 2 hrs to fix

    Method parse_partial_search_response has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    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
    Severity: Minor
    Found in lib/chef/encrypted_attribute/search_helper.rb - About 55 mins to fix

    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

          def search(type, query, keys, rows = 1000, partial_search = true)
    Severity: Minor
    Found in lib/chef/encrypted_attribute/search_helper.rb - About 35 mins to fix

      Method normal_search has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def normal_search(type, name, query, keys, rows = 1000)
      Severity: Minor
      Found in lib/chef/encrypted_attribute/search_helper.rb - About 35 mins to fix

        Method partial_search has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def partial_search(type, name, query, keys, rows = 1000)
        Severity: Minor
        Found in lib/chef/encrypted_attribute/search_helper.rb - About 35 mins to fix

          Method search_by_name has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def search_by_name(type, name, keys, rows = 1000, partial_search = true)
          Severity: Minor
          Found in lib/chef/encrypted_attribute/search_helper.rb - About 35 mins to fix

            Method parse_normal_search_row_attribute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            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?)
            Severity: Minor
            Found in lib/chef/encrypted_attribute/search_helper.rb - About 25 mins to fix

            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

            There are no issues that match your filters.

            Category
            Status