ManageIQ/azure-armrest

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

Summary

Maintainability
B
4 hrs
Test Coverage
A
90%

Class Configuration has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Configuration
      # Clear all class level caches. Typically used for testing only.
      def self.clear_caches
        token_cache.clear
      end
Severity: Minor
Found in lib/azure/armrest/configuration.rb - About 2 hrs to fix

    Method initialize has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def initialize(args)
            # Use defaults, and override with provided arguments
            options = {
              :api_version   => '2015-01-01',
              :accept        => 'application/json',
    Severity: Minor
    Found in lib/azure/armrest/configuration.rb - About 1 hr to fix

      Method initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def initialize(args)
              # Use defaults, and override with provided arguments
              options = {
                :api_version   => '2015-01-01',
                :accept        => 'application/json',
      Severity: Minor
      Found in lib/azure/armrest/configuration.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 set_provider_api_versions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def set_provider_api_versions
              # A lookup table for getting api-version strings per provider and service.
              @provider_api_versions = Hash.new { |hash, key| hash[key] = {} }
      
              providers.each do |rp|
      Severity: Minor
      Found in lib/azure/armrest/configuration.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

      Variable value used in void context.
      Open

              value
      Severity: Minor
      Found in lib/azure/armrest/configuration.rb by rubocop

      Checks for operators, variables, literals, lambda, proc and nonmutating methods used in void context.

      Example: CheckForMethodsWithNoSideEffects: false (default)

      # bad
      def some_method
        some_num * 10
        do_something
      end
      
      def some_method(some_var)
        some_var
        do_something
      end

      Example: CheckForMethodsWithNoSideEffects: true

      # bad
      def some_method(some_array)
        some_array.sort
        do_something(some_array)
      end
      
      # good
      def some_method
        do_something
        some_num * 10
      end
      
      def some_method(some_var)
        do_something
        some_var
      end
      
      def some_method(some_array)
        some_array.sort!
        do_something(some_array)
      end

      There are no issues that match your filters.

      Category
      Status