rspec/rspec-expectations

View on GitHub
lib/rspec/matchers/built_in/raise_error.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Class RaiseError has 28 methods (exceeds 20 allowed). Consider refactoring.

      class RaiseError
        include Composable

        # Used as a sentinel value to be able to tell when the user did not pass an
        # argument. We can't use `nil` for that because we need to warn when `nil` is
Severity: Minor
Found in lib/rspec/matchers/built_in/raise_error.rb - About 3 hrs to fix

    Method matches? has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.

            def matches?(given_proc, negative_expectation=false, &block)
              @given_proc = given_proc
              @block ||= block
              @raised_expected_error = false
              @with_expected_message = false
    Severity: Minor
    Found in lib/rspec/matchers/built_in/raise_error.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 warn_for_negative_false_positives! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

            def warn_for_negative_false_positives!
              expression = if expecting_specific_exception? && @expected_message
                             "`expect { }.not_to raise_error(SpecificErrorClass, message)`"
                           elsif expecting_specific_exception?
                             "`expect { }.not_to raise_error(SpecificErrorClass)`"
    Severity: Minor
    Found in lib/rspec/matchers/built_in/raise_error.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