rpanachi/core_ext

View on GitHub

Showing 91 of 105 total issues

Method delegate has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def delegate(*methods)
    options = methods.pop
    unless options.is_a?(Hash) && to = options[:to]
      raise ArgumentError, 'Delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, to: :greeter).'
    end
Severity: Minor
Found in lib/core_ext/module/delegation.rb - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

              if (
                  # CR X LF
                  ( previous == database.boundary[:cr] and current == database.boundary[:lf] ) or
                  # L X (L|V|LV|LVT)
                  ( database.boundary[:l] === previous and in_char_class?(current, [:l,:v,:lv,:lvt]) ) or
    Severity: Critical
    Found in lib/core_ext/multibyte/unicode.rb - About 1 hr to fix

      Method find_zone! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def find_zone!(time_zone)
            if !time_zone || time_zone.is_a?(CoreExt::TimeZone)
              time_zone
            else
              # Look up the timezone based on the identifier (unless we've been
      Severity: Minor
      Found in lib/core_ext/time/zones.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 split has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def split(value = nil)
          if block_given?
            inject([[]]) do |results, element|
              if yield(element)
                results << []
      Severity: Minor
      Found in lib/core_ext/array/grouping.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 unpack_graphemes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def unpack_graphemes(string)
              codepoints = string.codepoints.to_a
              unpacked = []
              pos = 0
              marker = 0
      Severity: Minor
      Found in lib/core_ext/multibyte/unicode.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 decompose has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def decompose(type, codepoints)
              codepoints.inject([]) do |decomposed, cp|
                # if it's a hangul syllable starter character
                if HANGUL_SBASE <= cp and cp < HANGUL_SLAST
                  sindex = cp - HANGUL_SBASE
      Severity: Minor
      Found in lib/core_ext/multibyte/unicode.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 convert has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def convert
              precision = options.delete :precision
      
              if precision
                case number
      Severity: Minor
      Found in lib/core_ext/number_helper/number_to_rounded_converter.rb - About 1 hr to fix

        Method make_lambda has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def make_lambda(filter)
                case filter
                when Symbol
                  lambda { |target, _, &blk| target.send filter, &blk }
                when String
        Severity: Minor
        Found in lib/core_ext/callbacks.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 run_in_isolation has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def run_in_isolation(&blk)
                  read, write = IO.pipe
                  read.binmode
                  write.binmode
        
        
        Severity: Minor
        Found in lib/core_ext/testing/isolation.rb - About 1 hr to fix

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

              def parameterize(string, sep = :unused, separator: '-', preserve_case: false)
                unless sep == :unused
                  CoreExt::Deprecation.warn("Passing the separator argument as a positional parameter is deprecated and will soon be removed. Use `separator: '#{sep}'` instead.")
                  separator = sep
                end
          Severity: Minor
          Found in lib/core_ext/inflector/transliterate.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 convert_value has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def convert_value(value, options = {})
                  if value.is_a? Hash
                    if options[:for] == :to_hash
                      value.to_hash
                    else
          Severity: Minor
          Found in lib/core_ext/hash_with_indifferent_access.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 sum has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def sum(identity = 0)
              if block_given? || !(first.is_a?(Integer) && last.is_a?(Integer))
                super
              else
                actual_last = exclude_end? ? (last - 1) : last
          Severity: Minor
          Found in lib/core_ext/enumerable.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 skip_callback has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def skip_callback(name, *filter_list, &block)
                  type, filters, options = normalize_callback_params(filter_list, block)
                  options[:raise] = true unless options.key?(:raise)
          
                  __update_callbacks(name) do |target, chain|
          Severity: Minor
          Found in lib/core_ext/callbacks.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 atomic_write has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.atomic_write(file_name, temp_dir = dirname(file_name))
              require 'tempfile' unless defined?(Tempfile)
          
              Tempfile.open(".#{basename(file_name)}", temp_dir) do |temp_file|
                temp_file.binmode
          Severity: Minor
          Found in lib/core_ext/file/atomic.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 parse has a Cognitive Complexity of 10 (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/rexml.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 broadcast has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def self.broadcast(logger) # :nodoc:
                Module.new do
                  define_method(:add) do |*args, &block|
                    logger.add(*args, &block)
                    super(*args, &block)
          Severity: Minor
          Found in lib/core_ext/logger.rb - About 1 hr to fix

            Method run_in_isolation has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def run_in_isolation(&blk)
                      require "tempfile"
            
                      if ENV["ISOLATION_TEST"]
                        yield
            Severity: Minor
            Found in lib/core_ext/testing/isolation.rb - About 1 hr to fix

              Method make_lambda has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def make_lambda(filter)
                      case filter
                      when Symbol
                        lambda { |target, _, &blk| target.send filter, &blk }
                      when String
              Severity: Minor
              Found in lib/core_ext/callbacks.rb - About 1 hr to fix

                Method - has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def -(other)
                      if other.acts_like?(:time)
                        to_time - other.to_time
                      elsif duration_of_variable_length?(other)
                        method_missing(:-, other)
                Severity: Minor
                Found in lib/core_ext/time_with_zone.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 to_query has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def to_query(namespace = nil)
                    collect do |key, value|
                      unless (value.is_a?(Hash) || value.is_a?(Array)) && value.empty?
                        value.to_query(namespace ? "#{namespace}[#{key}]" : key)
                      end
                Severity: Minor
                Found in lib/core_ext/object/to_query.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

                Severity
                Category
                Status
                Source
                Language