ManageIQ/azure-armrest

View on GitHub
lib/azure/armrest/resource_group_based_service.rb

Summary

Maintainability
B
4 hrs
Test Coverage
C
78%

Method list_all has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def list_all(filter = {})
        url = build_url
        url = yield(url) || url if block_given?

        skip_accessors_definition = filter.delete(:skip_accessors_definition) || false
Severity: Minor
Found in lib/azure/armrest/resource_group_based_service.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 build_id_string has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def build_id_string(resource_group = nil, *args)
        id_string = File.join('', 'subscriptions', configuration.subscription_id)
        id_string = File.join(id_string, 'resourceGroups', resource_group) if resource_group
        id_string = File.join(id_string, 'providers', @provider, @service_name)

Severity: Minor
Found in lib/azure/armrest/resource_group_based_service.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 build_id_string has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def build_id_string(resource_group = nil, *args)
        id_string = File.join('', 'subscriptions', configuration.subscription_id)
        id_string = File.join(id_string, 'resourceGroups', resource_group) if resource_group
        id_string = File.join(id_string, 'providers', @provider, @service_name)

Severity: Minor
Found in lib/azure/armrest/resource_group_based_service.rb - About 1 hr to fix

    Do not mix named captures and numbered captures in a Regexp literal.
    Open

            regex = %r{
              subscriptions/(?<subscription_id>[^\/]+)?
              (/resourceGroups/(?<resource_group>[^\/]+)?)?
              (/providers/(?<provider>[^\/]+)?)?
              (/(?<service_name>[^\/]+)?/(?<resource_name>[^\/]+))?

    Do not mix named captures and numbered captures in a Regexp literal because numbered capture is ignored if they're mixed. Replace numbered captures with non-capturing groupings or named captures.

    Example:

    # bad
    /(?<foo>FOO)(BAR)/
    
    # good
    /(?<foo>FOO)(?<bar>BAR)/
    
    # good
    /(?<foo>FOO)(?:BAR)/
    
    # good
    /(FOO)(BAR)/</foo></bar></foo></foo>

    There are no issues that match your filters.

    Category
    Status