mguymon/lock_jar

View on GitHub
lib/lock_jar/runtime.rb

Summary

Maintainability
A
1 hr
Test Coverage

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

    def lockfile_dependencies(lockfile, groups, with_locals = true)
      dependencies = []

      groups.each do |group|
        next unless lockfile.groups[group.to_s]
Severity: Minor
Found in lib/lock_jar/runtime.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

Method resolver has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
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]
Severity: Minor
Found in lib/lock_jar/runtime.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

Favor modifier unless usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
Open

      unless with_locals
Severity: Minor
Found in lib/lock_jar/runtime.rb by rubocop

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?

There are no issues that match your filters.

Category
Status