troessner/reek

View on GitHub
samples/smelly_source/ruby.rb

Summary

Maintainability
F
1 wk
Test Coverage

Method scan_tokens has a Cognitive Complexity of 273 (exceeds 5 allowed). Consider refactoring.
Open

    def scan_tokens tokens, options
      last_token_dot = false
      value_expected = true
      heredocs = nil
      last_state = nil
Severity: Minor
Found in samples/smelly_source/ruby.rb - About 5 days 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 scan_tokens has 283 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def scan_tokens tokens, options
      last_token_dot = false
      value_expected = true
      heredocs = nil
      last_state = nil
Severity: Major
Found in samples/smelly_source/ruby.rb - About 1 day to fix

    File ruby.rb has 296 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module CodeRay
    module Scanners
    
      # This scanner is really complex, since Ruby _is_ a complex language!
      #
    Severity: Minor
    Found in samples/smelly_source/ruby.rb - About 3 hrs to fix

      Avoid deeply nested control flow statements.
      Open

                    case m = getch
                    when state.delim, '\\'
                      tokens << [match + m, :char]
                    when nil
                      tokens << [match, :error]
      Severity: Major
      Found in samples/smelly_source/ruby.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      tokens << [modifiers, :modifier] unless modifiers.empty?
        Severity: Major
        Found in samples/smelly_source/ruby.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                    elsif match = scan(/\#.*/) or
                      ( bol? and match = scan(/#{patterns::RUBYDOC_OR_DATA}/o) )
                        kind = :comment
                        value_expected = true
                        tokens << [match, kind]
          Severity: Major
          Found in samples/smelly_source/ruby.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                          if esc = scan(/ #{patterns::ESCAPE} /ox)
                            tokens << [match + esc, :char]
                          else
                            tokens << [match, :error]
                          end
            Severity: Major
            Found in samples/smelly_source/ruby.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          if heredocs
                            unscan  # heredoc scanning needs \n at start
                            state = heredocs.shift
                            tokens << [:open, state.type]
                            heredocs = nil if heredocs.empty?
              Severity: Major
              Found in samples/smelly_source/ruby.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            if match == "\n"
                              value_expected = true  # FIXME not quite true
                              state = :initial if state == :undef_comma_expected
                            end
                Severity: Major
                Found in samples/smelly_source/ruby.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                if state.paren_depth > 0
                                  tokens << [match, :nesting_delimiter]
                                  next
                                end
                  Severity: Major
                  Found in samples/smelly_source/ruby.rb - About 45 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status