aviator/aviator

View on GitHub

Showing 74 of 74 total issues

Method infer_version has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

      def infer_version(session_data, request_name, service)
        if session_data.has_key?(:auth_service) && session_data[:auth_service][:api_version]
        session_data[:auth_service][:api_version].to_sym

        elsif session_data.has_key?(:auth_service) && session_data[:auth_service][:host_uri]
Severity: Minor
Found in lib/aviator/openstack/provider.rb - About 4 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 Request has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Request

    class ApiVersionNotDefinedError < StandardError
      def initialize
        super "api_version is not defined."
Severity: Minor
Found in lib/aviator/core/request.rb - About 3 hrs to fix

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

          def find_request(service, name, session_data, options)
            service = service.to_s
            endpoint_type = options[:endpoint_type]
            endpoint_types = if endpoint_type
                               [StrUtil.camelize(endpoint_type.to_s)]
    Severity: Minor
    Found in lib/aviator/openstack/provider.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 request has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def request(request_name, options={}, &params)
          if options[:api_version].nil? && @default_options[:api_version]
            options[:api_version] = @default_options[:api_version]
          end
    
    
    Severity: Minor
    Found in lib/aviator/core/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 describe_request has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.describe_request(provider_name, service_name, api_version, endpoint_type, request_name)
          service = Aviator::Service.new :provider => provider_name, :service => service_name
          request_class = "Aviator::#{ StrUtil.camelize(provider_name) }::#{ StrUtil.camelize(service_name) }::Requests::"\
                          "#{ StrUtil.camelize(api_version) }::#{ StrUtil.camelize(endpoint_type) }::#{ StrUtil.camelize(request_name) }"
          request_class = StrUtil.constantize(request_class)
    Severity: Minor
    Found in lib/aviator/core/cli/describer.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 describe_request has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.describe_request(provider_name, service_name, api_version, endpoint_type, request_name)
          service = Aviator::Service.new :provider => provider_name, :service => service_name
          request_class = "Aviator::#{ StrUtil.camelize(provider_name) }::#{ StrUtil.camelize(service_name) }::Requests::"\
                          "#{ StrUtil.camelize(api_version) }::#{ StrUtil.camelize(endpoint_type) }::#{ StrUtil.camelize(request_name) }"
          request_class = StrUtil.constantize(request_class)
    Severity: Minor
    Found in lib/aviator/core/cli/describer.rb - About 1 hr to fix

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

          def base_url
            if session_data[:base_url]
              session_data[:base_url]
      
            elsif keystone_v2_style_session_data? && keystone_v2_style_service_info?
      Severity: Minor
      Found in lib/aviator/openstack/common/requests/v0/public/base.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 url has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def url
            str  = "#{ base_url }/volumes"
            str += "/detail" if params[:details]
      
            filters = []
      Severity: Minor
      Found in lib/aviator/openstack/volume/requests/v1/public/list_volumes.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 url has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def url
            str  = "#{ base_url }/servers"
            str += "/detail" if params[:details]
      
            filters = []
      Severity: Minor
      Found in lib/aviator/openstack/compute/requests/v2/public/list_servers.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_request_class has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def get_request_class(root_namespace, request_class_arr)
              provider_specific = request_class_arr != [:request]
      
              if provider_specific
                full_request_class_arr = request_class_arr.dup
      Severity: Minor
      Found in lib/aviator/core/request_builder.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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                service_specs = session_data[:body][:token][:catalog].select{|s| s[:type].match("#{ service }(v\d+)?") }
                raise MultipleServiceApisError.new(service, service_specs, request_name) unless service_specs.length <= 1
                raise Aviator::Service::MissingServiceEndpointError.new(service.to_s, request_name) unless service_specs.length > 0
                version = service_specs[0][:endpoints][0][:url].match(/(v\d+)\.?\d*/)
                version ? version[1].to_sym : :v1
      Severity: Major
      Found in lib/aviator/openstack/provider.rb and 1 other location - About 1 hr to fix
      lib/aviator/openstack/provider.rb on lines 167..173

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 63.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                service_specs = session_data[:body][:access][:serviceCatalog].select{|s| s[:type].match("#{ service }(v\d+)?") }
                raise MultipleServiceApisError.new(service, service_specs, request_name) unless service_specs.length <= 1
                raise Aviator::Service::MissingServiceEndpointError.new(service.to_s, request_name) unless service_specs.length > 0
                version = service_specs[0][:endpoints][0][:publicURL].match(/(v\d+)\.?\d*/)
                version ? version[1].to_sym : :v1
      Severity: Major
      Found in lib/aviator/openstack/provider.rb and 1 other location - About 1 hr to fix
      lib/aviator/openstack/provider.rb on lines 174..179

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 63.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          def url
            str  = "#{ base_url }/volumes"
            str += "/detail" if params[:details]
      
            filters = []
      lib/aviator/openstack/compute/requests/v2/public/list_servers.rb on lines 40..53

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 62.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          def url
            str  = "#{ base_url }/servers"
            str += "/detail" if params[:details]
      
            filters = []
      lib/aviator/openstack/volume/requests/v1/public/list_volumes.rb on lines 30..43

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 62.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        define_request :add_role_to_user_on_tenant, :inherit => [:openstack, :common, :v2, :admin, :base] do
      
          meta :service, :identity
      
          link 'documentation',
      lib/aviator/openstack/identity/requests/v2/admin/delete_role_from_user_on_tenant.rb on lines 3..29

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 61.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        define_request :delete_role_from_user_on_tenant, :inherit => [:openstack, :common, :v2, :admin, :base] do
      
          meta :service, :identity
      
      
      
      lib/aviator/openstack/identity/requests/v2/admin/add_role_to_user_on_tenant.rb on lines 3..28

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 61.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Method compact_hash has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def compact_hash(hash, opts = {})
            opts[:recurse] ||= true
            hash.inject({}) do |new_hash, (k,v)|
              if !v.nil?
                new_hash[k] = opts[:recurse] && v.kind_of?(Hash) ? compact_hash(v, opts) : v
      Severity: Minor
      Found in lib/aviator/openstack/identity/requests/v3/public/create_token.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 request has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def request(request_name, options={}, &params)
            if options[:api_version].nil? && @default_options[:api_version]
              options[:api_version] = @default_options[:api_version]
            end
      
      
      Severity: Minor
      Found in lib/aviator/core/service.rb - About 1 hr to fix

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

          define_request :set_image_metadata, :inherit => [:openstack, :common, :v2, :public, :base] do
        
            meta :service, :compute
        
            link 'documentation',
        lib/aviator/openstack/compute/requests/v2/public/set_server_metadata.rb on lines 3..33
        lib/aviator/openstack/compute/requests/v2/public/update_image_metadata.rb on lines 3..33
        lib/aviator/openstack/compute/requests/v2/public/update_server_metadata.rb on lines 3..33

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 52.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

          define_request :set_server_metadata, :inherit => [:openstack, :common, :v2, :public, :base] do
        
            meta :service, :compute
        
            link 'documentation',
        lib/aviator/openstack/compute/requests/v2/public/set_image_metadata.rb on lines 3..33
        lib/aviator/openstack/compute/requests/v2/public/update_image_metadata.rb on lines 3..33
        lib/aviator/openstack/compute/requests/v2/public/update_server_metadata.rb on lines 3..33

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 52.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Severity
        Category
        Status
        Source
        Language