rspec/rspec-core

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

Summary

Maintainability
A
3 hrs
Test Coverage

Method filter_applies? has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.

        def filter_applies?(key, filter_value, metadata)
          silence_metadata_example_group_deprecations do
            return location_filter_applies?(filter_value, metadata) if key == :locations
            return id_filter_applies?(filter_value, metadata)       if key == :ids
            return filters_apply?(key, filter_value, metadata)      if Hash === filter_value
Severity: Minor
Found in lib/rspec/core/metadata_filter.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

Avoid too many return statements within this method.

            return filter_applies_to_any_value?(key, filter_value, metadata) if Array === meta_value
Severity: Major
Found in lib/rspec/core/metadata_filter.rb - About 30 mins to fix

    Avoid too many return statements within this method.

                return proc_filter_applies?(key, filter_value, metadata) if Proc === filter_value
    Severity: Major
    Found in lib/rspec/core/metadata_filter.rb - About 30 mins to fix

      Avoid too many return statements within this method.

                  return true if TrueClass === filter_value && meta_value
      Severity: Major
      Found in lib/rspec/core/metadata_filter.rb - About 30 mins to fix

        There are no issues that match your filters.

        Category