rpanachi/core_ext

View on GitHub

Showing 91 of 105 total issues

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

  def as_json(options = nil) #:nodoc:
    # create a subset of the hash by applying :only or :except
    subset = if options
      if attrs = options[:only]
        slice(*Array(attrs))
Severity: Minor
Found in lib/core_ext/object/json.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 in_groups has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def in_groups(number, fill_with = nil)
    # size.div number gives minor group size;
    # size % number gives how many objects need extra accommodation;
    # each group hold either division or division + 1 items.
    division = size.div number
Severity: Minor
Found in lib/core_ext/array/grouping.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 mattr_reader has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def mattr_reader(*syms)
    options = syms.extract_options!
    syms.each do |sym|
      raise NameError.new("invalid attribute name: #{sym}") unless sym =~ /\A[_A-Za-z]\w*\z/
      class_eval(<<-EOS, __FILE__, __LINE__ + 1)
Severity: Minor
Found in lib/core_ext/module/attribute_accessors.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

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

  def mattr_writer(*syms)
    options = syms.extract_options!
    syms.each do |sym|
      raise NameError.new("invalid attribute name: #{sym}") unless sym =~ /\A[_A-Za-z]\w*\z/
      class_eval(<<-EOS, __FILE__, __LINE__ + 1)
Severity: Minor
Found in lib/core_ext/module/attribute_accessors.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 handler_for_rescue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def handler_for_rescue(exception)
      # We go from right to left because pairs are pushed onto rescue_handlers
      # as rescue_from declarations are found.
      _, rescuer = self.class.rescue_handlers.reverse.detect do |klass_name, handler|
        # The purpose of allowing strings in rescue_from is to support the
Severity: Minor
Found in lib/core_ext/rescuable.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 collapse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def collapse(element, depth)
      hash = get_attributes(element)

      child_nodes = element.child_nodes
      if child_nodes.length > 0
Severity: Minor
Found in lib/core_ext/xml_mini/jdom.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_xml has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def to_xml(options = {})
    require 'core_ext/builder' unless defined?(Builder)

    options = options.dup
    options[:indent]  ||= 2
Severity: Minor
Found in lib/core_ext/hash/conversions.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 civil_from_format has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def self.civil_from_format(utc_or_local, year, month=1, day=1, hour=0, min=0, sec=0)
Severity: Major
Found in lib/core_ext/date_time/conversions.rb - About 50 mins to fix

    Method safe_constantize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def safe_constantize(camel_cased_word)
          constantize(camel_cased_word)
        rescue NameError => e
          raise if e.name && !(camel_cased_word.to_s.split("::").include?(e.name.to_s) ||
            e.name.to_s == camel_cased_word.to_s)
    Severity: Minor
    Found in lib/core_ext/inflector/methods.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 + has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def +(other)
          if duration_of_variable_length?(other)
            method_missing(:+, other)
          else
            result = utc.acts_like?(:date) ? utc.since(other) : utc + other rescue utc.since(other)
    Severity: Minor
    Found in lib/core_ext/time_with_zone.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 tidy_bytes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def tidy_bytes(string, force = false)
              return string if string.empty?
              return recode_windows1252_chars(string) if force
    
              # We can't transcode to the same format, so we choose a nearly-identical encoding.
    Severity: Minor
    Found in lib/core_ext/multibyte/unicode.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 sum has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def sum(sign, time = ::Time.current) #:nodoc:
            parts.inject(time) do |t,(type,number)|
              if t.acts_like?(:time) || t.acts_like?(:date)
                if type == :seconds
                  t.since(sign * number)
    Severity: Minor
    Found in lib/core_ext/duration.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 append_features has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def append_features(base)
          if base.instance_variable_defined?(:@_dependencies)
            base.instance_variable_get(:@_dependencies) << self
            return false
          else
    Severity: Minor
    Found in lib/core_ext/concern.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 to_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def to_hash(hash={})
              node_hash = {}
    
              # Insert node hash into parent hash correctly.
              case hash[name]
    Severity: Minor
    Found in lib/core_ext/xml_mini/nokogiri.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 deprecated_false_terminator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def deprecated_false_terminator # :nodoc:
            Proc.new do |target, result_lambda|
              terminate = true
              catch(:abort) do
                result = result_lambda.call if result_lambda.is_a?(Proc)
    Severity: Minor
    Found in lib/core_ext/callbacks.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 wrap_with_time_zone has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def wrap_with_time_zone(time)
            if time.acts_like?(:time)
              periods = time_zone.periods_for_local(time)
              self.class.new(nil, time_zone, time, periods.include?(period) ? period : nil)
            elsif time.is_a?(Range)
    Severity: Minor
    Found in lib/core_ext/time_with_zone.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 to_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def to_hash(hash={})
            node_hash = {}
    
            # Insert node hash into parent hash correctly.
            case hash[name]
    Severity: Minor
    Found in lib/core_ext/xml_mini/libxml.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 rescue_from has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def rescue_from(*klasses, &block)
            options = klasses.extract_options!
    
            unless options.has_key?(:with)
              if block_given?
    Severity: Minor
    Found in lib/core_ext/rescuable.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def initialize(name, filter, kind, options, chain_config)
    Severity: Minor
    Found in lib/core_ext/callbacks.rb - About 35 mins to fix
      Severity
      Category
      Status
      Source
      Language