bblimke/webmock

View on GitHub
lib/webmock/request_pattern.rb

Summary

Maintainability
C
1 day
Test Coverage

File request_pattern.rb has 314 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module WebMock

  module RSpecMatcherDetector
    def rSpecHashIncludingMatcher?(matcher)
      matcher.class.name =~ /R?Spec::Mocks::ArgumentMatchers::HashIncludingMatcher/
Severity: Minor
Found in lib/webmock/request_pattern.rb - About 3 hrs to fix

    Method matching_body_hashes? has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def matching_body_hashes?(query_parameters, pattern, content_type)
          return false unless query_parameters.is_a?(Hash)
          return false unless query_parameters.keys.sort == pattern.keys.sort
          query_parameters.each do |key, actual|
            expected = pattern[key]
    Severity: Minor
    Found in lib/webmock/request_pattern.rb - About 2 hrs 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 matches? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def matches?(headers)
          if empty_headers?(@pattern)
            empty_headers?(headers)
          else
            return false if empty_headers?(headers)
    Severity: Minor
    Found in lib/webmock/request_pattern.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 matches? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def matches?(request_signature)
          content_type = request_signature.headers['Content-Type'] if request_signature.headers
          content_type = content_type.split(';').first if content_type
          @method_pattern.matches?(request_signature.method) &&
            @uri_pattern.matches?(request_signature.uri) &&
    Severity: Minor
    Found in lib/webmock/request_pattern.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 matches? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def matches?(body, content_type = "")
          assert_non_multipart_body(content_type)
    
          if (@pattern).is_a?(Hash)
            return true if @pattern.empty?
    Severity: Minor
    Found in lib/webmock/request_pattern.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 add_query_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_query_params(query_params)
          @query_params = if query_params.is_a?(Hash)
            query_params
          elsif query_params.is_a?(WebMock::Matchers::HashIncludingMatcher) \
                  || query_params.is_a?(WebMock::Matchers::HashExcludingMatcher)
    Severity: Minor
    Found in lib/webmock/request_pattern.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
    Status