troessner/reek

View on GitHub

Showing 77 of 77 total issues

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 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 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 parse_signature has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_signature(src, raw=false)

      sig = self.strip_comments(src)
      # strip preprocessor directives
      sig.gsub!(/^\s*\#.*(\\\n.*)*/, '')
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

                  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

                                htmlesc( line, :NoQuotes ) unless used_offtags['notextile']
        Severity: Major
        Found in samples/smelly_source/redcloth.rb - About 45 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

                      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

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                      module Reek
                        module Errors
                          # Gets raised when trying to configure a detector which is unknown to us.
                          # This might happen for multiple reasons. The users might have a typo in
                          # his comment or he might use a detector that does not exist anymore.
                      Severity: Minor
                      Found in lib/reek/errors/bad_detector_in_comment_error.rb and 1 other location - About 40 mins to fix
                      lib/reek/errors/garbage_detector_configuration_in_comment_error.rb on lines 6..33

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 37.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                      module Reek
                        module Errors
                          # Gets raised when trying to use a configuration for a detector
                          # that can't be parsed into a hash.
                          class GarbageDetectorConfigurationInCommentError < BaseError
                      lib/reek/errors/bad_detector_in_comment_error.rb on lines 6..34

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 37.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      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 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 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
                              Severity
                              Category
                              Status
                              Source
                              Language