troessner/reek

View on GitHub

Showing 70 of 77 total issues

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

      def scout(exp:, depth:)
        return [] unless exp

        # Find all non-nested blocks in this expression
        exp.each_node([:block], [:block]).flat_map do |iterator|
Severity: Minor
Found in lib/reek/smell_detectors/nested_iterators.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

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

      def conditional_counts
        result = Hash.new { |hash, key| hash[key] = [] }
        collector = proc do |node|
          next unless (condition = node.condition)
          next if condition == BLOCK_GIVEN_CONDITION
Severity: Minor
Found in lib/reek/smell_detectors/repeated_conditional.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

Avoid too many return statements within this method.
Open

      return arg[s.length..-1], m
Severity: Major
Found in samples/smelly_source/optparse.rb - About 30 mins to fix

    Method parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def parse(arg, argv, &error)
            if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
              return nil, block, nil
            end
            opt = (val = parse_arg(val, &error))[1]
    Severity: Minor
    Found in samples/smelly_source/optparse.rb - About 25 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 to_html has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_html( *rules )
            rules = DEFAULT_RULES if rules.empty?
            # make our working copy
            text = self.dup
            
    Severity: Minor
    Found in samples/smelly_source/redcloth.rb - About 25 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 collect_calls has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def collect_calls(result)
              context.local_nodes(:send, [:mlhs]) do |call_node|
                next if call_node.object_creation_call?
                next if simple_method_call? call_node
    
    
    Severity: Minor
    Found in lib/reek/smell_detectors/duplicate_method_call.rb - About 25 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 ignore_file? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def ignore_file?(path)
            if options.force_exclusion?
              path.ascend do |ascendant|
                break true if path_excluded?(ascendant)
    
    
    Severity: Minor
    Found in lib/reek/source/source_locator.rb - About 25 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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(mod)
          raise ArgumentError, "Class/Module arg is required" unless Module === mod
          # new (but not on some 1.8s) -> inline -> real_caller|eval
          stack = caller
          meth = stack.shift until meth =~ /in .(inline|test_|setup)/ or stack.empty?
    Severity: Minor
    Found in samples/smelly_source/inline.rb - About 25 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 add_banner has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_banner(to)  # :nodoc:
          unless @short or @long
            s = desc.join
            to << " [" + s + "]..." unless s.empty?
          end
    Severity: Minor
    Found in samples/smelly_source/optparse.rb - About 25 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 record_call_to has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def record_call_to(exp)
            receiver = exp.receiver
            type = receiver ? receiver.type : :self
            line = exp.line
            case type
    Severity: Minor
    Found in lib/reek/context/code_context.rb - About 25 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