Showing 9 of 9 total issues
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
- Read upRead up
- Exclude checks
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 call
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def call(gems, versions, version_constraint)
gems.each do |gem|
if versions.has_key? gem.name
version = versions[gem.name]
if !::Gem::Version.new(version).prerelease?
- Read upRead up
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 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
- Read upRead up
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)
- Read upRead up
- Exclude checks
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
Put one space between the method name and the first argument. Open
attr_writer :versions
- Read upRead up
- Exclude checks
Checks that exactly one space is used between a method name and the first argument for method calls without parentheses.
Alternatively, extra spaces can be added to align the argument with something on a preceding or following line, if the AllowForAlignment config parameter is true.
Example:
# bad
something x
something y, z
something'hello'
# good
something x
something y, z
something 'hello'
Do not suppress exceptions. Open
rescue StopIteration
- Read upRead up
- Exclude checks
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
TODO found Open
(TODO, FIXME, OPTIMIZE, HACK, REVIEW).
- Exclude checks
FIXME found Open
(TODO, FIXME, OPTIMIZE, HACK, REVIEW).
- Exclude checks
HACK found Open
(TODO, FIXME, OPTIMIZE, HACK, REVIEW).
- Exclude checks