troessner/reek

View on GitHub

Showing 9 of 13 total issues

Class ContextBuilder has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

  class ContextBuilder
    attr_reader :context_tree

    def initialize(syntax_tree)
      @exp = syntax_tree
Severity: Minor
Found in lib/reek/context_builder.rb - About 3 hrs to fix

    Method source_paths has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

          def source_paths
            paths.each_with_object([]) do |given_path, relevant_paths|
              unless given_path.exist?
                print_no_such_file_error(given_path)
                next
    Severity: Minor
    Found in lib/reek/source/source_locator.rb - About 2 hrs 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

    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|
              new_depth = increment_depth(iterator, depth)
    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 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|
                child.visibility = visibility if names.include?(child.name)
    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

    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
                result[call_node].record(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)
                false
    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 uses_param_in_call_in_condition? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def uses_param_in_call_in_condition?
              return unless condition
              condition.each_node(:send) do |inner|
                next unless regular_call_involving_param? inner
                return true
    Severity: Minor
    Found in lib/reek/smell_detectors/control_parameter.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