ManageIQ/linux_admin

View on GitHub
lib/linux_admin/deb.rb

Summary

Maintainability
A
35 mins
Test Coverage
A
100%

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

    def self.from_string(apt_cache_string)
      in_description = false
      apt_cache_string.split("\n").each.with_object({}) do |line,deb|
        tag,value = self.from_line(line)
        if tag == 'description-en'
Severity: Minor
Found in lib/linux_admin/deb.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

Unused method argument - in_description. If it's necessary, use _ or _in_description as an argument name to indicate that it won't be used. If it's unnecessary, remove it.
Open

    def self.from_line(apt_cache_line, in_description=false)
Severity: Minor
Found in lib/linux_admin/deb.rb by rubocop

Checks for unused method arguments.

Example:

# bad
def some_method(used, unused, _unused_but_allowed)
  puts used
end

# good
def some_method(used, _unused, _unused_but_allowed)
  puts used
end

Example: AllowUnusedKeywordArguments: false (default)

# bad
def do_something(used, unused: 42)
  used
end

Example: AllowUnusedKeywordArguments: true

# good
def do_something(used, unused: 42)
  used
end

Example: IgnoreEmptyMethods: true (default)

# good
def do_something(unused)
end

Example: IgnoreEmptyMethods: false

# bad
def do_something(unused)
end

Example: IgnoreNotImplementedMethods: true (default)

# good
def do_something(unused)
  raise NotImplementedError
end

def do_something_else(unused)
  fail "TODO"
end

Example: IgnoreNotImplementedMethods: false

# bad
def do_something(unused)
  raise NotImplementedError
end

def do_something_else(unused)
  fail "TODO"
end

There are no issues that match your filters.

Category
Status