troessner/reek

View on GitHub

Showing 70 of 77 total issues

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

    def flush_left( text )
        indt = 0
        if text =~ /^ /
            while text !~ /^ {#{indt}}\S/
                indt += 1
Severity: Minor
Found in samples/smelly_source/redcloth.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 rootdir has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def self.rootdir
    env = ENV['INLINEDIR'] || ENV['HOME']

    # in case both INLINEDIR and HOME aren't defined, and under Windows
    # default to HOMEDRIVE + HOMEPATH values
Severity: Minor
Found in samples/smelly_source/inline.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 inline_textile_span has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def inline_textile_span( text ) 
        QTAGS.each do |qtag_rc, ht, qtag_re, rtype|
            text.gsub!( qtag_re ) do |m|
             
                case rtype
Severity: Minor
Found in samples/smelly_source/redcloth.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 inline has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def inline(lang = :C, options={})
    case options
    when TrueClass, FalseClass then
      warn "WAR\NING: 2nd argument to inline is now a hash, changing to {:testing=>#{options}}" unless options
      options = { :testing => options  }
Severity: Minor
Found in samples/smelly_source/inline.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 initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def initialize(pattern = nil, conv = nil,
                   short = nil, long = nil, arg = nil,
                   desc = ([] if short or long), block = Proc.new)
Severity: Major
Found in samples/smelly_source/optparse.rb - About 50 mins to fix

    Avoid deeply nested control flow statements.
    Open

                  rescue InvalidOption
                    # if no short options match, try completion with long
                    # options.
                    sw, = complete(:long, opt)
                    eq ||= !rest
    Severity: Major
    Found in samples/smelly_source/optparse.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

                      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

                            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

                              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

                                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

                    Avoid deeply nested control flow statements.
                    Open

                                            htmlesc( line, :NoQuotes ) unless used_offtags['notextile']
                    Severity: Major
                    Found in samples/smelly_source/redcloth.rb - About 45 mins to fix

                      Method complete has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def complete(id, opt, icase = false, *pat, &block)
                      Severity: Minor
                      Found in samples/smelly_source/optparse.rb - About 35 mins to fix

                        Method update has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def update(sw, sopts, lopts, nsw = nil, nlopts = nil)
                        Severity: Minor
                        Found in samples/smelly_source/optparse.rb - About 35 mins to fix

                          Method textile_fn_ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def textile_fn_( tag, num, atts, cite, content )
                          Severity: Minor
                          Found in samples/smelly_source/redcloth.rb - About 35 mins to fix

                            Method summarize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                              def summarize(to = [], width = @summary_width, max = width - 1, indent = @summary_indent, &blk)
                            Severity: Minor
                            Found in samples/smelly_source/optparse.rb - About 35 mins to fix

                              Method summarize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  def summarize(sdone = [], ldone = [], width = 1, max = width - 1, indent = "")
                              Severity: Minor
                              Found in samples/smelly_source/optparse.rb - About 35 mins to fix

                                Method track_visibility has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                      def track_visibility(children:, visibility:, names:)
                                        return unless VISIBILITY_MODIFIERS.include? visibility
                                
                                        if names.any?
                                          children.each do |child|
                                Severity: Minor
                                Found in lib/reek/context/visibility_tracker.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

                                Severity
                                Category
                                Status
                                Source
                                Language