ninech/netbox-client-ruby

View on GitHub

Showing 8 of 27 total issues

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

Method find_by has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def find_by(attributes)
      fail ArgumentError, '"attributes" expects a hash' unless attributes.is_a? Hash

      filter(attributes).find do |netbox_object|
        attributes.all? do |filter_key, filter_value|
Severity: Minor
Found in lib/netbox_client_ruby/entities.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

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

    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

      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

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

          def page(page)
            raise ArgumentError, "The offset '#{page}' is not numeric but has to be." unless page.is_a? Numeric
            raise ArgumentError, "The offset '#{page}' must be integer but isn't." unless page.integer?
            raise ArgumentError, "The offset '#{page}' must not be negative but is." if page.negative?
      
      
      Severity: Minor
      Found in lib/netbox_client_ruby/entities.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 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

      Severity
      Category
      Status
      Source
      Language