EGI-FCTF/rOCCI-cli

View on GitHub

Showing 20 of 33 total issues

Method parse has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring.
Open

    def self.parse(args, test_env = false)

      @@quiet = test_env

      options = Hashie::Mash.new
Severity: Minor
Found in lib/occi/cli/occi_opts.rb - About 1 day 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 parse has 255 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.parse(args, test_env = false)

      @@quiet = test_env

      options = Hashie::Mash.new
Severity: Major
Found in lib/occi/cli/occi_opts.rb - About 1 day to fix

    File occi_opts.rb has 381 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'optparse'
    require 'uri'
    require 'erb'
    
    # load all parts of OcciOpts
    Severity: Minor
    Found in lib/occi/cli/occi_opts.rb - About 5 hrs to fix

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

        def helper_describe(options, output = nil)
          if resource_types.include?(options.resource) || resource_type_identifiers.include?(options.resource) || options.resource.start_with?(options.endpoint) || options.resource.start_with?('/')
            Occi::Cli::Log.debug "#{options.resource.inspect} is a resource type, type identifier or an actual resource."
      
            resources_or_links = describe(options.resource)
      Severity: Minor
      Found in lib/occi/cli/helpers/describe_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

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

        def helper_update(options, output = nil)
          unless resource_types.include?(options.resource) || resource_type_identifiers.include?(options.resource) \
                                                           || \
                 options.resource.start_with?(options.endpoint) || options.resource.start_with?('/')
            Occi::Cli::Log.error "I have no idea what #{options.resource.inspect} is ..."
      Severity: Minor
      Found in lib/occi/cli/helpers/update_helper.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 helper_link_kind has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def helper_link_kind(options, link)
          raise "No valid links given!" if link.blank?
      
          case link
          when /\/network\//, /\/ipreservation\//
      Severity: Minor
      Found in lib/occi/cli/helpers/link_helper.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 helper_create_attach_context_vars has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def helper_create_attach_context_vars(options, res)
          # TODO: find a better/universal way to do contextualization
          return unless options.context_vars
          Occi::Cli::Log.debug "with context variables: #{options.context_vars.inspect}"
      
      
      Severity: Minor
      Found in lib/occi/cli/helpers/create_helper.rb - About 1 hr to fix

        Method resources_to_json has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def resources_to_json(occi_resources)
              # generate JSON document from Occi::Core::Resources
              occi_resources = occi_resources.to_a
        
              if @output_format.to_s.end_with? '_pretty'
        Severity: Minor
        Found in lib/occi/cli/resource_output_factory.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 format has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def format(data)
              # construct a method name from data type and output format
              if data.kind_of? Occi::Core::Resources
                method = "resources_to_#{@output_format}".to_sym
              elsif data.kind_of? Occi::Core::Links
        Severity: Minor
        Found in lib/occi/cli/resource_output_factory.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 check_incompatible_args has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.check_incompatible_args(options, opts)
              if !options.dump_model && options.filter
                if @@quiet
                  exit false
                else
        Severity: Minor
        Found in lib/occi/cli/occi_opts.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 helper_create_attach_links has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def helper_create_attach_links(options, res)
            return unless options.links
            Occi::Cli::Log.debug "with links: #{options.links.inspect}"
        
            options.links.each do |link|
        Severity: Minor
        Found in lib/occi/cli/helpers/create_helper.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 parse_context_variable has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.parse_context_variable(cvar)
                ary = CONTEXT_REGEXP.match(cvar).to_a.drop 1
                raise ArgumentError, "Context variables must always contain ATTR=VALUE pairs!" unless ary.length == 2
        
                symbol = ary[0].to_sym
        Severity: Minor
        Found in lib/occi/cli/occi_opts/occi_opts_helper.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_mandatory_args has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.get_mandatory_args(options)
              mandatory = []
        
              if options.action == :trigger
                mandatory << :trigger_action
        Severity: Minor
        Found in lib/occi/cli/occi_opts.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 helper_create_wait has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def helper_create_wait(resource_link, timeout)
            begin
              Timeout::timeout(timeout) {
                Occi::Cli::Log.debug "Starting #{timeout}s wait period for #{resource_link.inspect} to become active"
                while true
        Severity: Minor
        Found in lib/occi/cli/helpers/create_helper.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 helper_trigger has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def helper_trigger(options, output = nil)
            unless resource_types.include?(options.resource) || resource_type_identifiers.include?(options.resource) \
                                                             || \
                   options.resource.start_with?(options.endpoint) || options.resource.start_with?('/')
              Occi::Cli::Log.error "I have no idea what #{options.resource.inspect} is ..."
        Severity: Minor
        Found in lib/occi/cli/helpers/trigger_helper.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 helper_link has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def helper_link(options, output = nil)
            location = nil
        
            unless options.resource.start_with?(options.endpoint) || options.resource.start_with?('/')
              raise "Given resource is not a valid instance URL! #{options.resource.inspect}"
        Severity: Minor
        Found in lib/occi/cli/helpers/link_helper.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 helper_create_attach_mixins has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def helper_create_attach_mixins(options, res)
            return unless options.mixins
            Occi::Cli::Log.debug "with mixins: #{options.mixins.inspect}"
        
            options.mixins.to_a.each do |mxn|
        Severity: Minor
        Found in lib/occi/cli/helpers/create_helper.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 parse_attribute_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.parse_attribute_value(value)
                result = value
        
                ATTR_NUM_EXP =~ value
                result = Regexp.last_match(:number).to_i if Regexp.last_match(:number)
        Severity: Minor
        Found in lib/occi/cli/occi_opts/occi_opts_helper.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 helper_link_attach_mixins has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def helper_link_attach_mixins(mixins, link)
            return if mixins.blank?
        
            Occi::Cli::Log.debug "with mixins: #{mixins.inspect}"
        
        
        Severity: Minor
        Found in lib/occi/cli/helpers/link_helper.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

        Method helper_create_attach_context_vars has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def helper_create_attach_context_vars(options, res)
            # TODO: find a better/universal way to do contextualization
            return unless options.context_vars
            Occi::Cli::Log.debug "with context variables: #{options.context_vars.inspect}"
        
        
        Severity: Minor
        Found in lib/occi/cli/helpers/create_helper.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