lib/lock_jar/runtime.rb
Method lockfile_dependencies
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def lockfile_dependencies(lockfile, groups, with_locals = true)
dependencies = []
groups.each do |group|
next unless lockfile.groups[group.to_s]
- Read upRead up
- Create a ticketCreate a ticket
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 resolver
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def resolver(opts = {})
# XXX: Caches the resolver by the options. Passing in nil opts will replay
# from the cache. This need to change.
if !opts.nil?
opts[:local_repo] = File.expand_path(opts[:local_repo]) if opts[:local_repo]
- Read upRead up
- Create a ticketCreate a ticket
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
Favor modifier unless
usage when having a single-line body. Another good alternative is the usage of control flow &&
/||
. Open
Open
unless with_locals
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for if and unless statements that would fit on one line
if written as a modifier if/unless. The maximum line length is
configured in the Metrics/LineLength
cop.
Example:
# bad
if condition
do_stuff(bar)
end
unless qux.empty?
Foo.do_something
end
# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?