hashie/hashie

View on GitHub

Showing 23 of 25 total issues

Class Mash has 43 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Mash < Hash
    include Hashie::Extensions::RubyVersionCheck
    extend Hashie::Extensions::KeyConflictWarning

    ALLOWED_SUFFIXES = %w[? ! = _].freeze
Severity: Minor
Found in lib/hashie/mash.rb - About 5 hrs to fix

    Method all has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def all(query)
          return to_enum(:all, query) unless block_given?
    
          if @hash.include? query
            yield @hash[query]
    Severity: Minor
    Found in lib/hashie/rash.rb - About 2 hrs 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

    Class Dash has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Dash < Hash
        include Hashie::Extensions::PrettyInspect
    
        alias to_s inspect
    
    
    Severity: Minor
    Found in lib/hashie/dash.rb - About 2 hrs to fix

      File mash.rb has 261 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'hashie/hash'
      require 'hashie/array'
      require 'hashie/utils'
      require 'hashie/logger'
      require 'hashie/extensions/key_conflict_warning'
      Severity: Minor
      Found in lib/hashie/mash.rb - About 2 hrs to fix

        Method build_coercion has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

                def build_coercion(type)
                  if type.is_a? Enumerable
                    if type.class == ::Hash
                      type, key_type, value_type = type.class, *type.first
                      build_hash_coercion(type, key_type, value_type)
        Severity: Minor
        Found in lib/hashie/extensions/coercion.rb - About 1 hr 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 update_attributes! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_attributes!(attributes)
              update_attributes(attributes)
        
              self.class.defaults.each_pair do |prop, value|
                next unless fetch(prop, nil).nil?
        Severity: Minor
        Found in lib/hashie/dash.rb - About 1 hr 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 <=> has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def <=>(other)
                lhsegments = segments
                rhsegments = other.segments
        
                lhsize = lhsegments.size
        Severity: Minor
        Found in lib/hashie/extensions/ruby_version.rb - About 1 hr 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 all has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def all(query)
              return to_enum(:all, query) unless block_given?
        
              if @hash.include? query
                yield @hash[query]
        Severity: Minor
        Found in lib/hashie/rash.rb - About 1 hr to fix

          Method _recursive_merge has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def _recursive_merge(hash, other_hash, &block)
                  other_hash.each do |k, v|
                    hash[k] =
                      if hash.key?(k) && hash[k].is_a?(::Hash) && v.is_a?(::Hash)
                        _recursive_merge(hash[k], v, &block)
          Severity: Minor
          Found in lib/hashie/extensions/deep_merge.rb - About 1 hr 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 to_hash has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def to_hash(options = {})
                out = {}
                each_key do |k|
                  assignment_key =
                    if options[:stringify_keys]
          Severity: Minor
          Found in lib/hashie/hash.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 method_missing has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def method_missing(name, *args)
                  return super unless args.empty?
          
                  if query_method?(name)
                    key = key_from_query_method(name)
          Severity: Minor
          Found in lib/hashie/extensions/method_access.rb - About 45 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 deep_fetch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def deep_fetch(*args, &block)
                  args.reduce(self) do |obj, arg|
                    begin
                      arg = Integer(arg) if obj.is_a? Array
                      obj.fetch(arg)
          Severity: Minor
          Found in lib/hashie/extensions/deep_fetch.rb - About 45 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 _deep_locate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def self._deep_locate(comparator, object, result = [])
                  if object.is_a?(::Enumerable)
                    if object.any? { |value| _match_comparator?(value, comparator, object) }
                      result.push object
                    end
          Severity: Minor
          Found in lib/hashie/extensions/deep_locate.rb - About 45 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 included has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.included(base)
                  Hashie::Extensions::Dash::IndifferentAccess.maybe_extend(base)
          
                  base.class_eval do
                    alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
          Severity: Minor
          Found in lib/hashie/extensions/indifferent_access.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 coerce_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def coerce_value(from, into, options = {})
                    options = { strict: true }.merge(options)
          
                    if ABSTRACT_CORE_TYPES.key? from
                      ABSTRACT_CORE_TYPES[from].each do |type|
          Severity: Minor
          Found in lib/hashie/extensions/coercion.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 method_missing has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def method_missing(name, *args)
                  if key?(name)
                    self[name]
                  else
                    sname = name.to_s
          Severity: Minor
          Found in lib/hashie/extensions/method_access.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 convert_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def convert_value(val, duping = false) #:nodoc:
                case val
                when self.class
                  val.dup
                when Hash
          Severity: Minor
          Found in lib/hashie/mash.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 _deep_update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def _deep_update(other_hash, &blk)
                other_hash.each_pair do |k, v|
                  key = convert_key(k)
                  if v.is_a?(::Hash) && key?(key) && regular_reader(key).is_a?(Mash)
                    custom_reader(key).deep_update(v, &blk)
          Severity: Minor
          Found in lib/hashie/mash.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 log_collision? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def log_collision?(method_key)
                return unless method_key.is_a?(String) || method_key.is_a?(Symbol)
                return unless respond_to?(method_key)
          
                _, suffix = method_name_and_suffix(method_key)
          Severity: Minor
          Found in lib/hashie/mash.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 set_value_with_coercion has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def set_value_with_coercion(key, value)
                    into = self.class.key_coercion(key) || self.class.value_coercion(value)
          
                    unless value.nil? || into.nil?
                      begin
          Severity: Minor
          Found in lib/hashie/extensions/coercion.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