Showing 48 of 48 total issues

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

      def parse_object
        raise NestingError, "nesting of #@current_nesting is too deep" if
          @max_nesting.nonzero? && @current_nesting > @max_nesting
        result = @object_class.new
        delim = false
Severity: Minor
Found in extern/json/lib/json/pure/parser.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

File generator.rb has 384 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module JSON
  MAP = {
    "\x0" => '\u0000',
    "\x1" => '\u0001',
    "\x2" => '\u0002',
Severity: Minor
Found in extern/json/lib/json/pure/generator.rb - About 5 hrs to fix

    Method parse_string has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

          def parse_string
            if scan(STRING)
              return '' if self[1].empty?
              string = self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do |c|
                if u = UNESCAPE_MAP[$&[1]]
    Severity: Minor
    Found in extern/json/lib/json/pure/parser.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

    File parser.rb has 317 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'strscan'
    
    module JSON
      module Pure
        # This class implements the JSON parser that is used to parse a JSON string
    Severity: Minor
    Found in extern/json/lib/json/pure/parser.rb - About 3 hrs to fix

      File common.rb has 279 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'json/version'
      require 'json/generic_object'
      
      module JSON
        class << self
      Severity: Minor
      Found in extern/json/lib/json/common.rb - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

                  if source.encoding == ::Encoding::ASCII_8BIT
                    b = source[0, 4].bytes.to_a
                    source =
                      case
                      when b.size >= 4 && b[0] == 0 && b[1] == 0 && b[2] == 0
        Severity: Critical
        Found in extern/json/lib/json/pure/parser.rb - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

                  if defined?(::Encoding)
                    if source.encoding == ::Encoding::ASCII_8BIT
                      b = source[0, 4].bytes.to_a
                      source =
                        case
          Severity: Critical
          Found in extern/json/lib/json/pure/parser.rb - About 2 hrs to fix

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

                    def configure(opts)
                      if opts.respond_to?(:to_hash)
                        opts = opts.to_hash
                      elsif opts.respond_to?(:to_h)
                        opts = opts.to_h
            Severity: Minor
            Found in extern/json/lib/json/pure/generator.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 parse has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                  def parse
                    reset
                    obj = nil
                    if @quirks_mode
                      while !eos? && skip(IGNORE)
            Severity: Minor
            Found in extern/json/lib/json/pure/parser.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_array has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                  def parse_array
                    raise NestingError, "nesting of #@current_nesting is too deep" if
                      @max_nesting.nonzero? && @current_nesting > @max_nesting
                    result = @array_class.new
                    delim = false
            Severity: Minor
            Found in extern/json/lib/json/pure/parser.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 dump has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              def dump(obj, anIO = nil, limit = nil)
                if anIO and limit.nil?
                  anIO = anIO.to_io if anIO.respond_to?(:to_io)
                  unless anIO.respond_to?(:write)
                    limit = anIO
            Severity: Minor
            Found in extern/json/lib/json/common.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_object has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def parse_object
                    raise NestingError, "nesting of #@current_nesting is too deep" if
                      @max_nesting.nonzero? && @current_nesting > @max_nesting
                    result = @object_class.new
                    delim = false
            Severity: Minor
            Found in extern/json/lib/json/pure/parser.rb - About 1 hr to fix

              Method convert_encoding has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def convert_encoding(source)
                      if source.respond_to?(:to_str)
                        source = source.to_str
                      else
                        raise TypeError, "#{source.inspect} is not like a string"
              Severity: Minor
              Found in extern/json/lib/json/pure/parser.rb - About 1 hr to fix

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

                      def convert_encoding(source)
                        if source.respond_to?(:to_str)
                          source = source.to_str
                        else
                          raise TypeError, "#{source.inspect} is not like a string"
                Severity: Minor
                Found in extern/json/lib/json/pure/parser.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 initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                      def initialize(source, opts = {})
                        opts ||= {}
                        unless @quirks_mode = opts[:quirks_mode]
                          source = convert_encoding source
                        end
                Severity: Minor
                Found in extern/json/lib/json/pure/parser.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_value has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def parse_value
                        case
                        when scan(FLOAT)
                          Float(self[1])
                        when scan(INTEGER)
                Severity: Minor
                Found in extern/json/lib/json/pure/parser.rb - About 1 hr to fix

                  Method parse has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def parse
                          reset
                          obj = nil
                          if @quirks_mode
                            while !eos? && skip(IGNORE)
                  Severity: Minor
                  Found in extern/json/lib/json/pure/parser.rb - About 1 hr to fix

                    Method generator= has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def generator=(generator) # :nodoc:
                          old, $VERBOSE = $VERBOSE, nil
                          @generator = generator
                          generator_methods = generator::GeneratorMethods
                          for const in generator_methods.constants
                    Severity: Minor
                    Found in extern/json/lib/json/common.rb - About 1 hr to fix

                      Method parse_string has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def parse_string
                              if scan(STRING)
                                return '' if self[1].empty?
                                string = self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do |c|
                                  if u = UNESCAPE_MAP[$&[1]]
                      Severity: Minor
                      Found in extern/json/lib/json/pure/parser.rb - About 1 hr to fix

                        Method parse_array has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def parse_array
                                raise NestingError, "nesting of #@current_nesting is too deep" if
                                  @max_nesting.nonzero? && @current_nesting > @max_nesting
                                result = @array_class.new
                                delim = false
                        Severity: Minor
                        Found in extern/json/lib/json/pure/parser.rb - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language