EGI-FCTF/rOCCI-cli

View on GitHub

Showing 33 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

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

            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 ..."
              raise "Unknown resource #{options.resource.inspect}, there is nothing to trigger here!"
        Severity: Minor
        Found in lib/occi/cli/helpers/trigger_helper.rb and 1 other location - About 45 mins to fix
        lib/occi/cli/helpers/update_helper.rb on lines 3..8

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

        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

            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 ..."
              raise "Unknown resource #{options.resource.inspect}, there is nothing to update here!"
        Severity: Minor
        Found in lib/occi/cli/helpers/update_helper.rb and 1 other location - About 45 mins to fix
        lib/occi/cli/helpers/trigger_helper.rb on lines 4..9

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

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

        Severity
        Category
        Status
        Source
        Language