rspec/rspec-core

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

Summary

Maintainability
C
7 hrs
Test Coverage

File metadata.rb has 326 lines of code (exceeds 250 allowed). Consider refactoring.

module RSpec
  module Core
    # Each ExampleGroup class and Example instance owns an instance of
    # Metadata, which is Hash extended to support lazy evaluation of values
    # associated with keys that may or may not be used by any example or group.
Severity: Minor
Found in lib/rspec/core/metadata.rb - About 3 hrs to fix

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

            def self.backwards_compatibility_default_proc(&example_group_selector)
              Proc.new do |hash, key|
                case key
                when :example_group
                  # We commonly get here when rspec-core is applying a previously
    Severity: Minor
    Found in lib/rspec/core/metadata.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 create has 5 arguments (exceeds 4 allowed). Consider refactoring.

            def self.create(parent_group_metadata, user_metadata, example_group_index, *args, &block)
    Severity: Minor
    Found in lib/rspec/core/metadata.rb - About 35 mins to fix

      Method create has 5 arguments (exceeds 4 allowed). Consider refactoring.

              def self.create(group_metadata, user_metadata, index_provider, description, block)
      Severity: Minor
      Found in lib/rspec/core/metadata.rb - About 35 mins to fix

        Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.

                def initialize(metadata, user_metadata, index_provider, description_args, block)
        Severity: Minor
        Found in lib/rspec/core/metadata.rb - About 35 mins to fix

          Method ascending has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

                def self.ascending(metadata)
                  yield metadata
                  return unless (group_metadata = metadata.fetch(:example_group) { metadata[:parent_example_group] })
          
                  loop do
          Severity: Minor
          Found in lib/rspec/core/metadata.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

          There are no issues that match your filters.

          Category