onddo/chef-encrypted-attributes

View on GitHub

Showing 14 of 14 total issues

Class Config has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Config
      include ::Chef::Mixin::ParamsValidate

      # Returns configuration options list.
      #
Severity: Minor
Found in lib/chef/encrypted_attribute/config.rb - About 2 hrs to fix

    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 included has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def self.included(includer)
                includer.class_eval do
                  # Helper method to set the encrypted attributes configuration.
                  def self.encrypted_attributes_option_set(key, value)
                    Chef::Config[:knife][:encrypted_attributes][key] = value
      Severity: Minor
      Found in lib/chef/knife/core/encrypted_attribute_editor_options.rb - About 1 hr 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 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 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 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 edit_data_string_to_obj has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                        def edit_data_string_to_obj(data, format)
                          case format
                          when 'JSON', 'json'
                            if data.nil?
                              {}
                Severity: Minor
                Found in lib/chef/knife/core/encrypted_attribute_editor_options.rb - About 35 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 get_public_key has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                      def self.get_public_key(node)
                        return node['public_key'] unless node['public_key'].nil?
                        RemoteClients.get_public_key(node['name'])
                      rescue Net::HTTPServerException => e
                        raise e unless e.response.code == '403'
                Severity: Minor
                Found in lib/chef/encrypted_attribute/remote_nodes.rb - About 35 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 delete_attribute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                      def delete_attribute(attr_ary)
                        assert_attribute_array(attr_ary)
                        cache_key = cache_key(name, attr_ary)
                
                        node = Chef::Node.load(name)
                Severity: Minor
                Found in lib/chef/encrypted_attribute/remote_node.rb - About 35 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 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

                Method run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                      def run
                        parse_args
                
                        return unless
                          Chef::EncryptedAttribute.exist_on_node?(@node_name, @attr_ary)
                Severity: Minor
                Found in lib/chef/knife/encrypted_attribute_delete.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

                Method get_public_keys has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                      def self.get_public_keys(users = [])
                        if users == '*' # users are [a-z0-9\-_]+, cannot be *
                          cache.key?('*') ? cache['*'] : cache['*'] = all_public_keys
                        elsif users.is_a?(Array)
                          get_users_public_keys(users)
                Severity: Minor
                Found in lib/chef/encrypted_attribute/remote_users.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

                Severity
                Category
                Status
                Source
                Language