EGI-FCTF/rOCCI-core

View on GitHub

Showing 34 of 34 total issues

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

    class Model
      include Yell::Loggable
      include Helpers::ArgumentValidator
      include Helpers::Renderable

Severity: Minor
Found in lib/occi/core/model.rb - About 4 hrs to fix

    Class Entity has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Entity
          include Yell::Loggable
          include Helpers::Renderable
          include Helpers::Locatable
          include Helpers::InstanceAttributesAccessor
    Severity: Minor
    Found in lib/occi/core/entity.rb - About 3 hrs to fix

      Class Collection has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Collection < Model
            ALL_KEYS = %i[entities action_instances].freeze
            INTERNAL_COLLECTIONS = (ALL_KEYS + [:categories]).freeze
      
            attr_accessor(*ALL_KEYS)
      Severity: Minor
      Found in lib/occi/core/collection.rb - About 2 hrs to fix

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

                class << self
                  # Indicates whether this class is a renderer candidate.
                  #
                  # @return [TrueClass, FalseClass] renderer flag
                  def renderer?
        Severity: Major
        Found in lib/occi/core/renderers/text_renderer.rb and 1 other location - About 1 hr to fix
        lib/occi/core/renderers/json_renderer.rb on lines 37..67

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

                class << self
                  # Indicates whether this class is a renderer candidate.
                  #
                  # @return [TrueClass, FalseClass] renderer flag
                  def renderer?
        Severity: Major
        Found in lib/occi/core/renderers/json_renderer.rb and 1 other location - About 1 hr to fix
        lib/occi/core/renderers/text_renderer.rb on lines 37..67

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

                  def render_instance_hash
                    hsh = {}
        
                    hsh[:kind] = object_kind.to_s
                    %i[mixins actions].each do |symbol|
        Severity: Minor
        Found in lib/occi/core/renderers/json/instance.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 plain_links! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

                  def plain_links!(lines, entity)
                    lines.each do |line|
                      next unless line.start_with?(TextParser::LINK_KEYS.first)
                      logger.debug "Parsing link line #{line.inspect}" if logger_debug?
        
        
        Severity: Minor
        Found in lib/occi/core/parsers/text/entity.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 plain has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                    def plain(lines)
                      regexp = Regexp.new(Constants::REGEXP_LOCATION)
        
                      locations = lines.map do |line|
                        next if line.blank?
        Severity: Minor
        Found in lib/occi/core/parsers/text/location.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 prepare_instance_attribute_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                  def prepare_instance_attribute_value(name, type, value)
                    if ancestor_match?(IP_TYPES, type)
                      value.host? ? "\"#{value}\"" : "\"#{value}/#{value.cidr_mask}\""
                    elsif ancestor_match?(QUOTABLE_TYPES, type)
                      "\"#{value}\""
        Severity: Minor
        Found in lib/occi/core/renderers/text/attributes.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 add_extended! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                  def add_extended!(hash)
                    hash[:parent] = object_parent.to_s if object_respond_to?(:parent) && object_parent
                    %i[actions depends applies].each do |symbol|
                      next unless object_respond_to?(symbol) && !object_send(symbol).blank?
                      hash[symbol] = object_send(symbol).collect(&:to_s)
        Severity: Minor
        Found in lib/occi/core/renderers/json/category.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 plain_attributes! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                  def plain_attributes!(lines, attributes)
                    lines.each do |line|
                      next unless line.start_with?(TextParser::ATTRIBUTE_KEYS.first)
        
                      name, value = raw_attribute(line)
        Severity: Minor
        Found in lib/occi/core/parsers/text/entity.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

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

          module InfrastructureExt
            module Mixins
              # A helper class for manipulation with `availability_zone` parent mixin. Doesn't
              # provide any additional functionality aside from the class name.
              #
        Severity: Major
        Found in lib/occi/infrastructure_ext/mixins/availability_zone.rb and 4 other locations - About 30 mins to fix
        lib/occi/infrastructure/mixins/os_tpl.rb on lines 2..15
        lib/occi/infrastructure/mixins/resource_tpl.rb on lines 2..15
        lib/occi/infrastructure_ext/mixins/floatingippool.rb on lines 2..15
        lib/occi/infrastructure_ext/mixins/region.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 33.

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

          module Infrastructure
            module Mixins
              # A helper class for manipulation with `os_tpl` parent mixin. Doesn't
              # provide any additional functionality aside from the class name.
              #
        Severity: Major
        Found in lib/occi/infrastructure/mixins/os_tpl.rb and 4 other locations - About 30 mins to fix
        lib/occi/infrastructure/mixins/resource_tpl.rb on lines 2..15
        lib/occi/infrastructure_ext/mixins/availability_zone.rb on lines 2..15
        lib/occi/infrastructure_ext/mixins/floatingippool.rb on lines 2..15
        lib/occi/infrastructure_ext/mixins/region.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 33.

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

          module InfrastructureExt
            module Mixins
              # A helper class for manipulation with `region` parent mixin. Doesn't
              # provide any additional functionality aside from the class name.
              #
        Severity: Major
        Found in lib/occi/infrastructure_ext/mixins/region.rb and 4 other locations - About 30 mins to fix
        lib/occi/infrastructure/mixins/os_tpl.rb on lines 2..15
        lib/occi/infrastructure/mixins/resource_tpl.rb on lines 2..15
        lib/occi/infrastructure_ext/mixins/availability_zone.rb on lines 2..15
        lib/occi/infrastructure_ext/mixins/floatingippool.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 33.

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

          module Infrastructure
            module Mixins
              # A helper class for manipulation with `os_tpl` parent mixin. Doesn't
              # provide any additional functionality aside from the class name.
              #
        Severity: Major
        Found in lib/occi/infrastructure/mixins/resource_tpl.rb and 4 other locations - About 30 mins to fix
        lib/occi/infrastructure/mixins/os_tpl.rb on lines 2..15
        lib/occi/infrastructure_ext/mixins/availability_zone.rb on lines 2..15
        lib/occi/infrastructure_ext/mixins/floatingippool.rb on lines 2..15
        lib/occi/infrastructure_ext/mixins/region.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 33.

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

          module InfrastructureExt
            module Mixins
              # A helper class for manipulation with `floatingippool` parent mixin. Doesn't
              # provide any additional functionality aside from the class name.
              #
        Severity: Major
        Found in lib/occi/infrastructure_ext/mixins/floatingippool.rb and 4 other locations - About 30 mins to fix
        lib/occi/infrastructure/mixins/os_tpl.rb on lines 2..15
        lib/occi/infrastructure/mixins/resource_tpl.rb on lines 2..15
        lib/occi/infrastructure_ext/mixins/availability_zone.rb on lines 2..15
        lib/occi/infrastructure_ext/mixins/region.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 33.

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

                    def uri_list(lines)
                      uris = lines.map do |line|
                        next if line.blank? || line.start_with?('#')
                        logger.debug "Parsing location from line #{line.inspect}" if logger_debug?
        
        
        Severity: Minor
        Found in lib/occi/core/parsers/text/location.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 validate_entities! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def validate_entities!(body)
                  found = nil
        
                  %i[link resource entity-collection].each do |type|
                    logger.debug "Attempting to validate #{body.inspect} as #{type}" if logger_debug?
        Severity: Minor
        Found in lib/occi/core/parsers/json_parser.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 set_attributes! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                  def set_attributes!(instance, hash)
                    return if hash.blank?
                    hash.each_pair do |name, value|
                      logger.debug "Setting attribute #{name} to #{value.inspect}" if logger_debug?
                      attribute = instance.attributes[name.to_s]
        Severity: Minor
        Found in lib/occi/core/parsers/json/entity.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 prepare_parent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                  def prepare_parent
                    cand = if object.respond_to?(:directly_related)
                             prepare_kind_rel
                           elsif object.respond_to?(:depends) && object.respond_to?(:applies)
                             prepare_mixin_rel.to_a
        Severity: Minor
        Found in lib/occi/core/renderers/text/category.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