rspec/rspec-core

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

Summary

Maintainability
C
1 day
Test Coverage

File exception_presenter.rb has 378 lines of code (exceeds 250 allowed). Consider refactoring.

RSpec::Support.require_rspec_core "formatters/console_codes"
RSpec::Support.require_rspec_core "formatters/snippet_extractor"
RSpec::Support.require_rspec_core 'formatters/syntax_highlighter'
RSpec::Support.require_rspec_support "encoded_string"

Severity: Minor
Found in lib/rspec/core/formatters/exception_presenter.rb - About 5 hrs to fix

    Class ExceptionPresenter has 27 methods (exceeds 20 allowed). Consider refactoring.

          class ExceptionPresenter
            attr_reader :exception, :example, :description, :message_color,
                        :detail_formatter, :extra_detail_formatter, :backtrace_formatter
            private :message_color, :detail_formatter, :extra_detail_formatter, :backtrace_formatter
    
    
    Severity: Minor
    Found in lib/rspec/core/formatters/exception_presenter.rb - About 3 hrs to fix

      Method formatted_cause has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.

                def formatted_cause(exception)
                  last_cause = final_exception(exception, [exception])
                  cause = []
      
                  if exception.cause
      Severity: Minor
      Found in lib/rspec/core/formatters/exception_presenter.rb - About 1 hr 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 read_failed_lines has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

              def read_failed_lines
                matching_line = find_failed_line
                unless matching_line
                  return ["Unable to find matching line from backtrace"]
                end
      Severity: Minor
      Found in lib/rspec/core/formatters/exception_presenter.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 multiple_exception_summarizer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

                def multiple_exception_summarizer(exception, prior_detail_formatter, color)
                  lambda do |example, colorizer|
                    summary = if exception.aggregation_metadata[:hide_backtrace]
                                # Since the backtrace is hidden, the subfailures will come
                                # immediately after this, and using `:` will read well.
      Severity: Minor
      Found in lib/rspec/core/formatters/exception_presenter.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