rpanachi/core_ext

View on GitHub

Showing 91 of 105 total issues

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

        def self.build(callback_sequence, user_callback, user_conditions, chain_config, filter)
Severity: Minor
Found in lib/core_ext/callbacks.rb - About 35 mins to fix

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

            def self.halting_and_conditional(callback_sequence, user_callback, user_conditions, halted_lambda, filter)
    Severity: Minor
    Found in lib/core_ext/callbacks.rb - About 35 mins to fix

      Method advance has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def advance(options)
          unless options[:weeks].nil?
            options[:weeks], partial_weeks = options[:weeks].divmod(1)
            options[:days] = options.fetch(:days, 0) + 7 * partial_weeks
          end
      Severity: Minor
      Found in lib/core_ext/time/calculations.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 utc_offset has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def utc_offset
            if @utc_offset
              @utc_offset
            else
              @current_period ||= tzinfo.current_period if tzinfo
      Severity: Minor
      Found in lib/core_ext/time_zone.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 apply_inflections has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def apply_inflections(word, rules)
            result = word.to_s.dup
      
            if word.empty? || inflections.uncountables.uncountable?(result)
              result
      Severity: Minor
      Found in lib/core_ext/inflector/methods.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 _run_class_setup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def _run_class_setup      # class setup method should only happen in parent
              @@class_setup_mutex.synchronize do
                unless defined?(@@ran_class_setup) || ENV['ISOLATION_TEST']
                  self.class.setup if self.class.respond_to?(:setup)
                  @@ran_class_setup = true
      Severity: Minor
      Found in lib/core_ext/testing/isolation.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 benchmark has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def benchmark(message = "Benchmarking", options = {})
            if logger
              options.assert_valid_keys(:level, :silence)
              options[:level] ||= :info
      
      
      Severity: Minor
      Found in lib/core_ext/benchmarkable.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 include? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def include?(value)
            if value.is_a?(::Range)
              # 1...10 includes 1..9 but it does not include 1..10.
              operator = exclude_end? && !value.exclude_end? ? :< : :<=
              super(value.first) && value.last.send(operator, last)
      Severity: Minor
      Found in lib/core_ext/range/include_range.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

      Avoid too many return statements within this method.
      Open

            return CoreExt::NumberHelper.number_to_human(self, options)
      Severity: Major
      Found in lib/core_ext/numeric/conversions.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return CoreExt::NumberHelper.number_to_human_size(self, options)
        Severity: Major
        Found in lib/core_ext/numeric/conversions.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return CoreExt::NumberHelper.number_to_rounded(self, options)
          Severity: Major
          Found in lib/core_ext/numeric/conversions.rb - About 30 mins to fix

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

              def truncate(truncate_at, options = {})
                return dup unless length > truncate_at
            
                omission = options[:omission] || '...'
                length_with_room_for_omission = truncate_at - omission.length
            Severity: Minor
            Found in lib/core_ext/string/filters.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 to_s has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def to_s(*args)
                format, options = args
                options ||= {}
            
                case format
            Severity: Minor
            Found in lib/core_ext/numeric/conversions.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 parts_to_time has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def parts_to_time(parts, now)
                    return if parts.empty?
            
                    time = Time.new(
                      parts.fetch(:year, now.year),
            Severity: Minor
            Found in lib/core_ext/time_zone.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 rename_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def rename_key(key, options = {})
                  camelize  = options[:camelize]
                  dasherize = !options.has_key?(:dasherize) || options[:dasherize]
                  if camelize
                    key = true == camelize ? key.camelize : key.camelize(camelize)
            Severity: Minor
            Found in lib/core_ext/xml_mini.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 merge! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def merge!(hash, key, value)
                  if hash.has_key?(key)
                    if hash[key].instance_of?(Array)
                      hash[key] << value
                    else
            Severity: Minor
            Found in lib/core_ext/xml_mini/jdom.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def initialize(constructor = {})
                  if constructor.respond_to?(:to_hash)
                    super()
                    update(constructor)
            
            
            Severity: Minor
            Found in lib/core_ext/hash_with_indifferent_access.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 deep_merge! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def deep_merge!(other_hash, &block)
                other_hash.each_pair do |current_key, other_value|
                  this_value = self[current_key]
            
                  self[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash)
            Severity: Minor
            Found in lib/core_ext/hash/deep_merge.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 [] has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def [](arg)
                    case arg
                      when String
                      begin
                        @lazy_zones_map[arg] ||= create(arg)
            Severity: Minor
            Found in lib/core_ext/time_zone.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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse(data)
                  if !data.respond_to?(:read)
                    data = StringIO.new(data || '')
                  end
            
            
            Severity: Minor
            Found in lib/core_ext/xml_mini/nokogiri.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