rspec/rspec-core

View on GitHub
lib/rspec/core/formatters.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method add has 26 lines of code (exceeds 25 allowed). Consider refactoring.

    def add(formatter_to_use, *paths)
      # If a formatter instance was passed, we can register it directly,
      # with no need for any of the further processing that happens below.
      if Loader.formatters.key?(formatter_to_use.class)
        register formatter_to_use, notifications_for(formatter_to_use.class)
Severity: Minor
Found in lib/rspec/core/formatters.rb - About 1 hr to fix

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

        def custom_formatter(formatter_ref)
          if Class === formatter_ref
            formatter_ref
          elsif string_const?(formatter_ref)
            begin
    Severity: Minor
    Found in lib/rspec/core/formatters.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 setup_default has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.

        def setup_default(output_stream, deprecation_stream)
          add default_formatter, output_stream if @formatters.empty?
    
          unless @formatters.any? { |formatter| DeprecationFormatter === formatter }
            add DeprecationFormatter, deprecation_stream, output_stream
    Severity: Minor
    Found in lib/rspec/core/formatters.rb - About 45 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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

        def add(formatter_to_use, *paths)
          # If a formatter instance was passed, we can register it directly,
          # with no need for any of the further processing that happens below.
          if Loader.formatters.key?(formatter_to_use.class)
            register formatter_to_use, notifications_for(formatter_to_use.class)
    Severity: Minor
    Found in lib/rspec/core/formatters.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

    There are no issues that match your filters.

    Category