rpanachi/core_ext

View on GitHub

Showing 105 of 105 total issues

File callbacks.rb has 482 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'core_ext/concern'
require 'core_ext/descendants_tracker'
require 'core_ext/array/extract_options'
require 'core_ext/class/attribute'
require 'core_ext/kernel/reporting'
Severity: Minor
Found in lib/core_ext/callbacks.rb - About 7 hrs to fix

    Class TimeWithZone has 51 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class TimeWithZone
    
        # Report class name as 'Time' to thwart type checking.
        def self.name
          'Time'
    Severity: Major
    Found in lib/core_ext/time_with_zone.rb - About 7 hrs to fix

      Method compose has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

            def compose(codepoints)
              pos = 0
              eoa = codepoints.length - 1
              starter_pos = 0
              starter_char = codepoints[0]
      Severity: Minor
      Found in lib/core_ext/multibyte/unicode.rb - About 5 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

      Method to_tag has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_tag(key, value, options)
            type_name = options.delete(:type)
            merged_options = options.merge(:root => key, :skip_instruct => true)
      
            if value.is_a?(::Method) || value.is_a?(::Proc)
      Severity: Minor
      Found in lib/core_ext/xml_mini.rb - About 4 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 HashWithIndifferentAccess has 31 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class HashWithIndifferentAccess < Hash
          # Returns +true+ so that <tt>Array#extract_options!</tt> finds members of
          # this class.
          def extractable_options?
            true
      Severity: Minor
      Found in lib/core_ext/hash_with_indifferent_access.rb - About 3 hrs to fix

        Method class_attribute has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

          def class_attribute(*attrs)
            options = attrs.extract_options!
            instance_reader = options.fetch(:instance_accessor, true) && options.fetch(:instance_reader, true)
            instance_writer = options.fetch(:instance_accessor, true) && options.fetch(:instance_writer, true)
            instance_predicate = options.fetch(:instance_predicate, true)
        Severity: Minor
        Found in lib/core_ext/class/attribute.rb - About 3 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 TimeZone has 30 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class TimeZone
            # Keys are Rails TimeZone names, values are TZInfo identifiers.
            MAPPING = {
              "International Date Line West" => "Pacific/Midway",
              "Midway Island"                => "Pacific/Midway",
        Severity: Minor
        Found in lib/core_ext/time_zone.rb - About 3 hrs to fix

          Method constantize has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

              def constantize(camel_cased_word)
                names = camel_cased_word.split('::'.freeze)
          
                # Trigger a built-in NameError exception including the ill-formed constant in the message.
                Object.const_get(camel_cased_word) if names.empty?
          Severity: Minor
          Found in lib/core_ext/inflector/methods.rb - About 3 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

          File time_zone.rb has 306 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'tzinfo'
          require 'core_ext/object/blank'
          require 'core_ext/object/try'
          require 'concurrent/map'
          
          
          Severity: Minor
          Found in lib/core_ext/time_zone.rb - About 3 hrs to fix

            Method convert has a Cognitive Complexity of 21 (exceeds 5 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 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 Time has 24 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class Time
              include DateAndTime::Calculations
            
              COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
            
            
            Severity: Minor
            Found in lib/core_ext/time/calculations.rb - About 2 hrs to fix

              File unicode.rb has 277 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              module CoreExt
                module Multibyte
                  module Unicode
              
                    extend self
              Severity: Minor
              Found in lib/core_ext/multibyte/unicode.rb - About 2 hrs to fix

                Method change has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                  def change(options)
                    new_year  = options.fetch(:year, year)
                    new_month = options.fetch(:month, month)
                    new_day   = options.fetch(:day, day)
                    new_hour  = options.fetch(:hour, hour)
                Severity: Minor
                Found in lib/core_ext/time/calculations.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

                Method delegate has a Cognitive Complexity of 17 (exceeds 5 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 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 Chars has 21 methods (exceeds 20 allowed). Consider refactoring.
                Open

                    class Chars
                      include Comparable
                      attr_reader :wrapped_string
                      alias to_s wrapped_string
                      alias to_str wrapped_string
                Severity: Minor
                Found in lib/core_ext/multibyte/chars.rb - About 2 hrs to fix

                  Method compose has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def compose(codepoints)
                          pos = 0
                          eoa = codepoints.length - 1
                          starter_pos = 0
                          starter_char = codepoints[0]
                  Severity: Major
                  Found in lib/core_ext/multibyte/unicode.rb - About 2 hrs to fix

                    Method process_hash has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def process_hash(value)
                            if value.include?('type') && !value['type'].is_a?(Hash) && @disallowed_types.include?(value['type'])
                              raise DisallowedType, value['type']
                            end
                    
                    
                    Severity: Minor
                    Found in lib/core_ext/hash/conversions.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

                    Method config_accessor has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def config_accessor(*names)
                            options = names.extract_options!
                    
                            names.each do |name|
                              raise NameError.new('invalid config attribute name') unless name =~ /\A[_A-Za-z]\w*\z/
                    Severity: Minor
                    Found in lib/core_ext/configurable.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

                    Method to_xml has a Cognitive Complexity of 15 (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/array/conversions.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 class_attribute has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def class_attribute(*attrs)
                        options = attrs.extract_options!
                        instance_reader = options.fetch(:instance_accessor, true) && options.fetch(:instance_reader, true)
                        instance_writer = options.fetch(:instance_accessor, true) && options.fetch(:instance_writer, true)
                        instance_predicate = options.fetch(:instance_predicate, true)
                    Severity: Minor
                    Found in lib/core_ext/class/attribute.rb - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language