ManageIQ/linux_admin

View on GitHub
lib/linux_admin/rpm.rb

Summary

Maintainability
A
55 mins
Test Coverage
A
100%

Method info has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def self.info(pkg)
      params = { "-qi" => pkg}
      in_description = false
      out = Common.run!(rpm_cmd, :params => params).output
      # older versions of rpm may have multiple fields per line,
Severity: Minor
Found in lib/linux_admin/rpm.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

Wrap expressions with varying precedence with parentheses to avoid ambiguity.
Open

          rpm['description'] << line + " "
Severity: Minor
Found in lib/linux_admin/rpm.rb by rubocop

Looks for expressions containing multiple binary operators where precedence is ambiguous due to lack of parentheses. For example, in 1 + 2 * 3, the multiplication will happen before the addition, but lexically it appears that the addition will happen first.

The cop does not consider unary operators (ie. !a or -b) or comparison operators (ie. a =~ b) because those are not ambiguous.

NOTE: Ranges are handled by Lint/AmbiguousRange.

Example:

# bad
a + b * c
a || b && c
a ** b + c

# good (different precedence)
a + (b * c)
a || (b && c)
(a ** b) + c

# good (same precedence)
a + b + c
a * b / c % d

There are no issues that match your filters.

Category
Status