troessner/reek

View on GitHub

Showing 77 of 77 total issues

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

    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

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

      module Reek
        module Errors
          # Gets raised when Reek is unable to process the source due to a SyntaxError
          class SyntaxError < BaseError
            TEMPLATE = "Source '%<source>s' cannot be processed by Reek due to a syntax error in the source file."
      Severity: Minor
      Found in lib/reek/errors/syntax_error.rb and 2 other locations - About 30 mins to fix
      lib/reek/errors/encoding_error.rb on lines 5..39
      lib/reek/errors/incomprehensible_source_error.rb on lines 5..42

      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 32.

      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 3 locations. Consider refactoring.
      Open

      module Reek
        module Errors
          # Gets raised when Reek is unable to process the source
          class IncomprehensibleSourceError < BaseError
            TEMPLATE = 'Source %<source>s cannot be processed by Reek.'
      Severity: Minor
      Found in lib/reek/errors/incomprehensible_source_error.rb and 2 other locations - About 30 mins to fix
      lib/reek/errors/encoding_error.rb on lines 5..39
      lib/reek/errors/syntax_error.rb on lines 5..41

      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 32.

      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 3 locations. Consider refactoring.
      Open

      module Reek
        module Errors
          # Gets raised when Reek is unable to process the source due to an EncodingError
          class EncodingError < BaseError
            TEMPLATE = "Source '%<source>s' cannot be processed by Reek due to an encoding error in the source file."
      Severity: Minor
      Found in lib/reek/errors/encoding_error.rb and 2 other locations - About 30 mins to fix
      lib/reek/errors/incomprehensible_source_error.rb on lines 5..42
      lib/reek/errors/syntax_error.rb on lines 5..41

      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 32.

      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 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

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

            def sniff
              # TODO: Only checks instance methods!
              actual = context.node_instance_methods.length
              return [] if actual <= max_allowed_methods
      
      
      Severity: Minor
      Found in lib/reek/smell_detectors/too_many_methods.rb and 1 other location - About 20 mins to fix
      lib/reek/smell_detectors/long_parameter_list.rb on lines 35..42

      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 27.

      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

            def sniff
              count = expression.arg_names.length
              return [] if count <= max_allowed_params
      
              [smell_warning(
      Severity: Minor
      Found in lib/reek/smell_detectors/long_parameter_list.rb and 1 other location - About 20 mins to fix
      lib/reek/smell_detectors/too_many_methods.rb on lines 38..46

      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 27.

      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

      Severity
      Category
      Status
      Source
      Language