joonty/pessimize

View on GitHub
lib/pessimize/gemfile.rb

Summary

Maintainability
A
55 mins
Test Coverage

Assignment Branch Condition size for parse_gems_from_tokens! is too high. [21.91/20]
Open

    def parse_gems_from_tokens!
      enum = tokens.each_with_index

      loop do
        (tok, i) = enum.next
Severity: Minor
Found in lib/pessimize/gemfile.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

    def parse_gems_from_tokens!
      enum = tokens.each_with_index

      loop do
        (tok, i) = enum.next
Severity: Minor
Found in lib/pessimize/gemfile.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

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

    def all_gem_tokens_collected?(current_token, next_token)
Severity: Minor
Found in lib/pessimize/gemfile.rb by rubocop

This cop checks for unused method arguments.

Example:

# bad

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

Example:

# good

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

Do not suppress exceptions.
Open

    rescue StopIteration
Severity: Minor
Found in lib/pessimize/gemfile.rb by rubocop

This cop checks for rescue blocks with no body.

Example:

# bad

def some_method
  do_something
rescue
  # do nothing
end

Example:

# bad

begin
  do_something
rescue
  # do nothing
end

Example:

# good

def some_method
  do_something
rescue
  handle_exception
end

Example:

# good

begin
  do_something
rescue
  handle_exception
end

There are no issues that match your filters.

Category
Status