ninech/netbox-client-ruby

View on GitHub
lib/netbox_client_ruby/entity.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method method_missing has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def method_missing(name_as_symbol, *args, &block)
      name = name_as_symbol.to_s

      if name.end_with?('=')
        is_readonly_field = readonly_fields.include?(name[0..-2])
Severity: Minor
Found in lib/netbox_client_ruby/entity.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

Avoid too many return statements within this method.
Open

      return true if data.is_a?(Hash) && data.key?(name)
Severity: Major
Found in lib/netbox_client_ruby/entity.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return data[name] if data.is_a?(Hash) && data.key?(name)
    Severity: Major
    Found in lib/netbox_client_ruby/entity.rb - About 30 mins to fix

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

          def update(new_values)
            new_values.each do |attribute, values|
              s_attribute = attribute.to_s
              next if readonly_fields.include? s_attribute
      
      
      Severity: Minor
      Found in lib/netbox_client_ruby/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 respond_to_missing? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def respond_to_missing?(name_as_symbol, *args)
            name = name_as_symbol.to_s
      
            return false if name.end_with?('=') && readonly_fields.include?(name[0..-2])
            return false if name.end_with?('=') && instance_variables.include?(name[0..-2])
      Severity: Minor
      Found in lib/netbox_client_ruby/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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(given_values = nil)
            return self if given_values.nil?
      
            if id_fields.count == 1 && !given_values.is_a?(Hash)
              instance_variable_set("@#{id_fields.keys.first}", given_values)
      Severity: Minor
      Found in lib/netbox_client_ruby/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

      There are no issues that match your filters.

      Category
      Status