ManageIQ/azure-armrest

View on GitHub

Showing 53 of 85 total issues

File storage_account.rb has 571 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'azure-signature'
require 'active_support'
require 'active_support/core_ext/hash/conversions'

module Azure
Severity: Major
Found in lib/azure/armrest/model/storage_account.rb - About 1 day to fix

    Method get_private_images has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

          def get_private_images(storage_accounts)
            results = []
            mutex = Mutex.new
    
            Parallel.each(storage_accounts, :in_threads => configuration.max_threads) do |storage_account|
    Severity: Minor
    Found in lib/azure/armrest/storage_account_service.rb - About 5 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

    Class StorageAccount has 36 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class StorageAccount < BaseModel
          attr_from_hash :name          => :name,
                         :blob_endpoint => [:properties, :primaryEndpoints, :blob]
    
          # Classes used to wrap container and blob information.
    Severity: Minor
    Found in lib/azure/armrest/model/storage_account.rb - About 4 hrs to fix

      Class ArmrestService has 35 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class ArmrestService
            extend Gem::Deprecate
      
            # Configuration to access azure APIs
            attr_accessor :armrest_configuration
      Severity: Minor
      Found in lib/azure/armrest/armrest_service.rb - About 4 hrs to fix

        Method delete_unmanaged_storage has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

              def delete_unmanaged_storage(vm, options)
                sas = Azure::Armrest::StorageAccountService.new(configuration)
        
                storage_account = sas.get_from_vm(vm)
        
        
        Severity: Minor
        Found in lib/azure/armrest/virtual_machine_service.rb - About 3 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 rest_execute has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

                def rest_execute(options, http_method = :get, encode = true, max_retries = 3)
                  tries ||= 0
                  url = encode ? Addressable::URI.encode(options[:url]) : options[:url]
                  options = options.merge(:method => http_method, :url => url)
                  RestClient::Request.execute(options)
        Severity: Minor
        Found in lib/azure/armrest/armrest_service.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 read has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          def read(sas_url, options = {})
            # The same restrictions that apply to the StorageAccount method also apply here.
            range = options[:range] if options[:range]
            range ||= options[:start_byte]..options[:end_byte] if options[:start_byte] && options[:end_byte]
            range ||= options[:start_byte]..options[:start_byte] + options[:length] - 1 if options[:start_byte] && options[:length]
        Severity: Minor
        Found in lib/azure/armrest/storage/managed_storage_helper.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

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

            class StorageAccountService < ResourceGroupBasedService
              # Creates and returns a new StorageAccountService (SAS) instance.
              #
              def initialize(configuration, options = {})
                super(configuration, 'storageAccounts', 'Microsoft.Storage', options)
        Severity: Minor
        Found in lib/azure/armrest/storage_account_service.rb - About 2 hrs to fix

          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

            Class BaseModel has 21 methods (exceeds 20 allowed). Consider refactoring.
            Open

                class BaseModel
                  # Initially inherit the exclusion list from parent class or create an empty Set.
                  def self.excl_list
                    @excl_list ||= superclass.respond_to?(:excl_list, true) ? superclass.send(:excl_list) : Set.new
                  end
            Severity: Minor
            Found in lib/azure/armrest/model/base_model.rb - About 2 hrs to fix

              Class VirtualMachineService has 21 methods (exceeds 20 allowed). Consider refactoring.
              Open

                  class VirtualMachineService < ResourceGroupBasedService
                    # Create and return a new VirtualMachineService instance. Most
                    # methods for a VirtualMachineService instance will return one or more
                    # VirtualMachine instances.
                    #
              Severity: Minor
              Found in lib/azure/armrest/virtual_machine_service.rb - About 2 hrs to fix

                Method create_blob has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                      def create_blob(container, blob, key = access_key, options = {})
                        raise ArgumentError, "No access key specified" unless key
                
                        timeout = options.delete(:timeout)
                        payload = options.delete(:payload) || ''
                Severity: Minor
                Found in lib/azure/armrest/model/storage_account.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 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_query has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                      def build_query(options)
                        array = []
                
                        options.each do |key, value|
                          next if key == :all
                Severity: Minor
                Found in lib/azure/armrest/model/storage_account.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 create_blob has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def create_blob(container, blob, key = access_key, options = {})
                        raise ArgumentError, "No access key specified" unless key
                
                        timeout = options.delete(:timeout)
                        payload = options.delete(:payload) || ''
                Severity: Minor
                Found in lib/azure/armrest/model/storage_account.rb - About 1 hr to fix

                  Method get_blob_raw has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def get_blob_raw(container, blob, key = access_key, options = {})
                          raise ArgumentError, "No access key specified" unless key
                  
                          url = File.join(properties.primary_endpoints.blob, container, blob)
                          url += "?snapshot=" + options[:date] if options[:date]
                  Severity: Minor
                  Found in lib/azure/armrest/model/storage_account.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 blobs has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def blobs(container, key = access_key, options = {})
                          raise ArgumentError, "No access key specified" unless key
                  
                          query = "restype=container&comp=list"
                          skip_defs = options[:skip_accessors_definition]
                  Severity: Minor
                  Found in lib/azure/armrest/model/storage_account.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 delete_associated_nics has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def delete_associated_nics(vm, options)
                          nis = Azure::Armrest::Network::NetworkInterfaceService.new(configuration)
                          nics = vm.properties.network_profile.network_interfaces.map(&:id)
                  
                          if options[:ip_addresses]
                  Severity: Minor
                  Found in lib/azure/armrest/virtual_machine_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 get_private_images has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def get_private_images(storage_accounts)
                          results = []
                          mutex = Mutex.new
                  
                          Parallel.each(storage_accounts, :in_threads => configuration.max_threads) do |storage_account|
                  Severity: Minor
                  Found in lib/azure/armrest/storage_account_service.rb - About 1 hr to fix

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language