mguymon/lock_jar

View on GitHub
lib/lock_jar/runtime/list.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method list has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def list(lockfile_or_path, groups = ['default'], opts = {}, &blk)
        dependencies = []
        maps = []
        with_locals = { with_locals: true }.merge(opts).delete(:with_locals)

Severity: Minor
Found in lib/lock_jar/runtime/list.rb - About 1 hr 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 list has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def list(lockfile_or_path, groups = ['default'], opts = {}, &blk)
        dependencies = []
        maps = []
        with_locals = { with_locals: true }.merge(opts).delete(:with_locals)

Severity: Minor
Found in lib/lock_jar/runtime/list.rb - About 1 hr to fix

Use !empty? instead of size > 0.
Open

        if maps && maps.size > 0
Severity: Minor
Found in lib/lock_jar/runtime/list.rb by rubocop

This cop checks for numeric comparisons that can be replaced by a predicate method, such as receiver.length == 0, receiver.length > 0, receiver.length != 0, receiver.length < 1 and receiver.size == 0 that can be replaced by receiver.empty? and !receiver.empty.

Example:

# bad
[1, 2, 3].length == 0
0 == "foobar".length
array.length < 1
{a: 1, b: 2}.length != 0
string.length > 0
hash.size > 0

# good
[1, 2, 3].empty?
"foobar".empty?
array.empty?
!{a: 1, b: 2}.empty?
!string.empty?
!hash.empty?

There are no issues that match your filters.

Category
Status