ishakir/DSON

View on GitHub

Showing 7 of 7 total issues

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

    def self.new(value)
      return HashValue.new(value)    if value.respond_to? :keys
      return ArrayValue.new(value)   if value.respond_to? :each
      return NilValue.instance       if value.nil?
      return TrueValue.instance      if value.is_a? TrueClass
Severity: Minor
Found in lib/DSON/value.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 handle_next has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.handle_next(options)
      word_array = options[:word_array]

      fail 'An error has occurred, this could be either user error or a bug. Please check your DSON is valid, and if it is, please raise a GitHub issue' if word_array.empty?

Severity: Minor
Found in lib/DSON/value.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

Avoid too many return statements within this method.
Open

      return NumericValue.new(value) if value.is_a? Integer or value.is_a? Float
Severity: Major
Found in lib/DSON/value.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return StringValue.new(value)  if value.is_a? String
    Severity: Major
    Found in lib/DSON/value.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return NumericValue.so_parse(first_word) unless first_word.start_with? '"'
      Severity: Major
      Found in lib/DSON/value.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return NilValue.so_parse            if first_word == 'empty'
        Severity: Major
        Found in lib/DSON/value.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return FalseValue.instance     if value.is_a? FalseClass
          Severity: Major
          Found in lib/DSON/value.rb - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language