EGI-FCTF/rOCCI-api

View on GitHub

Showing 26 of 26 total issues

Method set_auth_token has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

        def set_auth_token(tenant = nil, keystone_version = nil)
          response = @env_ref.class.get @keystone_url
          Occi::Api::Log.debug response.inspect

          raise ::Occi::Api::Client::Errors::AuthnError,
Severity: Minor
Found in lib/occi/api/client/http/authn_plugins/keystone.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

File keystone.rb has 263 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Occi::Api::Client
  module Http
    module AuthnPlugins

      class Keystone < Base
Severity: Minor
Found in lib/occi/api/client/http/authn_plugins/keystone.rb - About 2 hrs to fix

    Method set_auth_token has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def set_auth_token(tenant = nil, keystone_version = nil)
              response = @env_ref.class.get @keystone_url
              Occi::Api::Log.debug response.inspect
    
              raise ::Occi::Api::Client::Errors::AuthnError,
    Severity: Minor
    Found in lib/occi/api/client/http/authn_plugins/keystone.rb - About 1 hr to fix

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

              def get_first_working_project
                response = @env_ref.class.get(
                  "#{@base_url}/auth/projects",
                  :headers => get_req_headers
                )
      Severity: Major
      Found in lib/occi/api/client/http/authn_plugins/keystone.rb and 1 other location - About 1 hr to fix
      lib/occi/api/client/http/authn_plugins/keystone.rb on lines 169..187

      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

              def get_first_working_tenant
                response = @env_ref.class.get(
                  "#{@base_url}/tenants",
                  :headers => get_req_headers
                )
      Severity: Major
      Found in lib/occi/api/client/http/authn_plugins/keystone.rb and 1 other location - About 1 hr to fix
      lib/occi/api/client/http/authn_plugins/keystone.rb on lines 266..284

      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 setup has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

              def setup(options = {})
                # set up pem and optionally pem_password and ssl_ca_path
                raise ArgumentError, "Missing required option 'user_cert' for x509 auth!" unless @options[:user_cert]
                raise ArgumentError, "The file specified in 'user_cert' does not exist!" unless File.exists? @options[:user_cert]
      
      
      Severity: Minor
      Found in lib/occi/api/client/http/authn_plugins/x509.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 3 locations. Consider refactoring.
      Open

            def get_mixin_type_identifier(type)
              return type if (type =~ URI::ABS_URI) || (type && type.start_with?('/'))
      
              mixins = @model.mixins.to_a.select { |m| m.term == type }
              tis = mixins.collect { |m| m.type_identifier }
      Severity: Major
      Found in lib/occi/api/client/base/mixin_methods.rb and 2 other locations - About 1 hr to fix
      lib/occi/api/client/base/category_methods.rb on lines 37..49
      lib/occi/api/client/base/kind_methods.rb on lines 53..65

      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 53.

      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 3 locations. Consider refactoring.
      Open

            def get_kind_type_identifier(type)
              return type if (type =~ URI::ABS_URI) || (type && type.start_with?('/'))
      
              kinds = @model.kinds.to_a.select { |k| k.term == type }
              tis = kinds.collect { |k| k.type_identifier }
      Severity: Major
      Found in lib/occi/api/client/base/kind_methods.rb and 2 other locations - About 1 hr to fix
      lib/occi/api/client/base/category_methods.rb on lines 37..49
      lib/occi/api/client/base/mixin_methods.rb on lines 187..199

      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 53.

      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 3 locations. Consider refactoring.
      Open

            def get_category_type_identifier(type)
              return type if (type =~ URI::ABS_URI) || (type && type.start_with?('/'))
      
              cats = @model.categories.to_a.select { |k| k.term == type }
              tis = cats.collect { |c| c.type_identifier }
      Severity: Major
      Found in lib/occi/api/client/base/category_methods.rb and 2 other locations - About 1 hr to fix
      lib/occi/api/client/base/kind_methods.rb on lines 53..65
      lib/occi/api/client/base/mixin_methods.rb on lines 187..199

      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 53.

      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 get_mixins has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def get_mixins(type = nil, include_self = false)
              unless type.blank?
                type_id = get_mixin_type_identifier(type)
                unless type_id
                  raise ArgumentError,
      Severity: Minor
      Found in lib/occi/api/client/base/mixin_methods.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 post_create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def post_create(response)
              if response.code == 200
                collection = Occi::Parser.parse(
                  response.content_type,
                  response.body
      Severity: Minor
      Found in lib/occi/api/client/http/party_wrappers.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 get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def get(path='/', filter=nil)
              raise ArgumentError, "Path is a required argument!" if path.blank?
      
              # apply filters if present
              headers = self.class.headers.clone
      Severity: Minor
      Found in lib/occi/api/client/http/party_wrappers.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 describe has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def describe(resource_type_identifier=nil)
            if resource_type_identifier
              resource_type_identifier = get_resource_type_identifier(resource_type_identifier)
            end
      
      
      Severity: Minor
      Found in lib/occi/api/client/client_http.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 connect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def connect(protocol = :http, options = {})
          raise ArgumentError, 'Protocol is a required argument!' unless protocol
      
          if block_given?
            options = options.marshal_dump if options.is_a?(OpenStruct)
      Severity: Minor
      Found in lib/occi/api/dsl.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

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

        module Http
          module AuthnPlugins
      
            class Basic < Base
      
      
      Severity: Minor
      Found in lib/occi/api/client/http/authn_plugins/basic.rb and 1 other location - About 40 mins to fix
      lib/occi/api/client/http/authn_plugins/digest.rb on lines 2..15

      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 38.

      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

        module Http
          module AuthnPlugins
      
            class Digest < Base
      
      
      Severity: Minor
      Found in lib/occi/api/client/http/authn_plugins/digest.rb and 1 other location - About 40 mins to fix
      lib/occi/api/client/http/authn_plugins/basic.rb on lines 2..15

      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 38.

      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 set_auth_token has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def set_auth_token(tenant = nil)
                if @options[:original_type] == "x509"
                  set_voms_unscoped_token
                elsif @options[:type] == "oauth2"
                  set_oauth2_unscoped_token
      Severity: Minor
      Found in lib/occi/api/client/http/authn_plugins/keystone.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 list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def list(resource_type_identifier=nil)
            if resource_type_identifier
              resource_type_identifier = get_resource_type_identifier(resource_type_identifier)
              path = path_for_kind_type_identifier(resource_type_identifier)
            end
      Severity: Minor
      Found in lib/occi/api/client/client_http.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

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

            def get_resource(resource_type)
              Occi::Api::Log.debug("Instantiating #{resource_type.inspect}")
      
              type_id = get_resource_type_identifier(resource_type)
              raise "Unknown resource type! #{resource_type.inspect}" unless type_id
      Severity: Minor
      Found in lib/occi/api/client/base/entity_methods.rb and 1 other location - About 25 mins to fix
      lib/occi/api/client/base/entity_methods.rb on lines 39..48

      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 30.

      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 get_process_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def get_process_response(path, response)
              Occi::Api::Log.debug "Response from location: #{path.inspect}"
              kind = @model.get_by_location(path) if @model
      
              Occi::Api::Log.debug "Response should contain kind: #{kind ? kind.type_identifier.inspect : 'none'}"
      Severity: Minor
      Found in lib/occi/api/client/http/party_wrappers.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

      Severity
      Category
      Status
      Source
      Language