awesome-print/awesome_print

View on GitHub

Showing 18 of 387 total issues

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

      def format
        vars = variables.map do |var|
          property = var.to_s[1..-1].to_sym # to_s because of some monkey patching done by Puppet.
          accessor = if object.respond_to?(:"#{property}=")
            object.respond_to?(property) ? :accessor : :writer
Severity: Minor
Found in lib/awesome_print/formatters/object_formatter.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 format has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def format
        vars = variables.map do |var|
          property = var.to_s[1..-1].to_sym # to_s because of some monkey patching done by Puppet.
          accessor = if struct.respond_to?(:"#{property}=")
            struct.respond_to?(property) ? :accessor : :writer
Severity: Minor
Found in lib/awesome_print/formatters/struct_formatter.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 initialize has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def initialize(options = {})
      @options = {
        indent:        4,      # Number of spaces for indenting.
        index:         true,   # Display array indices.
        html:          false,  # Use ANSI color codes rather than HTML.
Severity: Minor
Found in lib/awesome_print/inspector.rb - About 1 hr to fix

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

        def awesome_active_model_error(object)
          return object.inspect if !defined?(::ActiveSupport::OrderedHash)
          return awesome_object(object) if @options[:raw]
    
          object_dump = object.marshal_dump.first
    Severity: Minor
    Found in lib/awesome_print/ext/active_record.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 awesome_active_record_instance has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def awesome_active_record_instance(object)
          return object.inspect if !defined?(::ActiveSupport::OrderedHash)
          return awesome_object(object) if @options[:raw]
    
          data = if object.class.column_names != object.attributes.keys
    Severity: Minor
    Found in lib/awesome_print/ext/active_record.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 method_tuple has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def method_tuple(method)
            if method.respond_to?(:parameters) # Ruby 1.9.2+
              # See http://readruby.chengguangnan.com/methods#method-objects-parameters
              # (mirror: http://archive.is/XguCA#selection-3381.1-3381.11)
              args = method.parameters.inject([]) do |arr, (type, name)|
    Severity: Minor
    Found in lib/awesome_print/formatters/base_formatter.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 format has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def format
            vars = variables.map do |var|
              property = var.to_s[1..-1].to_sym # to_s because of some monkey patching done by Puppet.
              accessor = if object.respond_to?(:"#{property}=")
                object.respond_to?(property) ? :accessor : :writer
    Severity: Minor
    Found in lib/awesome_print/formatters/object_formatter.rb - About 1 hr to fix

      Method format has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def format
              vars = variables.map do |var|
                property = var.to_s[1..-1].to_sym # to_s because of some monkey patching done by Puppet.
                accessor = if struct.respond_to?(:"#{property}=")
                  struct.respond_to?(property) ? :accessor : :writer
      Severity: Minor
      Found in lib/awesome_print/formatters/struct_formatter.rb - About 1 hr to fix

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

            def awesome_mongo_mapper_instance(object)
              return object.inspect if !defined?(::ActiveSupport::OrderedHash)
              return awesome_object(object) if @options[:raw]
        
              data = object.keys.keys.sort_by { |k| k }.inject(::ActiveSupport::OrderedHash.new) do |hash, name|
        Severity: Minor
        Found in lib/awesome_print/ext/mongo_mapper.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 cast_with_mongoid has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def cast_with_mongoid(object, type)
              cast = cast_without_mongoid(object, type)
              if defined?(::Mongoid::Document)
                if object.is_a?(Class) && object.ancestors.include?(::Mongoid::Document)
                  cast = :mongoid_class
        Severity: Minor
        Found in lib/awesome_print/ext/mongoid.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 cast_with_mongo_mapper has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def cast_with_mongo_mapper(object, type)
              apply_default_mongo_mapper_options
              cast = cast_without_mongo_mapper(object, type)
        
              if defined?(::MongoMapper::Document)
        Severity: Minor
        Found in lib/awesome_print/ext/mongo_mapper.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 cast_with_active_record has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def cast_with_active_record(object, type)
              cast = cast_without_active_record(object, type)
              return cast if !defined?(::ActiveRecord::Base)
        
              if object.is_a?(::ActiveRecord::Base)
        Severity: Minor
        Found in lib/awesome_print/ext/active_record.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 cast_with_active_support has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def cast_with_active_support(object, type)
              cast = cast_without_active_support(object, type)
              if defined?(::ActiveSupport) && defined?(::HashWithIndifferentAccess)
                if (defined?(::ActiveSupport::TimeWithZone) && object.is_a?(::ActiveSupport::TimeWithZone)) || object.is_a?(::Date)
                  cast = :active_support_time
        Severity: Minor
        Found in lib/awesome_print/ext/active_support.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_to_hash has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def convert_to_hash(object)
              return nil if has_method_accessor?(object)
              return nil if !object.respond_to?(:to_hash) || object.method(:to_hash).arity != 0
        
              # ActionController::Parameters will raise if they are not yet permitted
        Severity: Minor
        Found in lib/awesome_print/formatter.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 printable_hash has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def printable_hash
                data = printable_keys
                width = left_width(data)
        
                data.map! do |key, value|
        Severity: Minor
        Found in lib/awesome_print/formatters/hash_formatter.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 colorize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def colorize(str, type)
              str = CGI.escapeHTML(str) if options[:html]
              if options[:plain] || !options[:color][type] || !inspector.colorize?
                str
              #
        Severity: Minor
        Found in lib/awesome_print/colorize.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 align has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def align(value, width)
                if options[:multiline]
                  if options[:indent] > 0
                    value.rjust(width)
                  elsif options[:indent] == 0
        Severity: Minor
        Found in lib/awesome_print/formatters/base_formatter.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 grep has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def grep(pattern, &blk)
            #
            # The following looks rather insane and I've sent numerous hours trying
            # to figure it out. The problem is that if grep gets called with the
            # block, for example:
        Severity: Minor
        Found in lib/awesome_print/core_ext/awesome_method_array.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