Assignment Branch Condition size for method_missing is too high. [18.63/15] Open
def method_missing(name, *args, &block)
@result ||= if @batch_action == name
s = yield(@ids)
if s.is_a?(Hash) && s[:data]
Tabulatr::Responses::RawResponse.new(s[:data], filename: s[:filename], type: s[:type])
- 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
Cyclomatic complexity for method_missing is too high. [8/6] Open
def method_missing(name, *args, &block)
@result ||= if @batch_action == name
s = yield(@ids)
if s.is_a?(Hash) && s[:data]
Tabulatr::Responses::RawResponse.new(s[:data], filename: s[:filename], type: s[:type])
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Perceived complexity for method_missing is too high. [9/7] Open
def method_missing(name, *args, &block)
@result ||= if @batch_action == name
s = yield(@ids)
if s.is_a?(Hash) && s[:data]
Tabulatr::Responses::RawResponse.new(s[:data], filename: s[:filename], type: s[:type])
- Read upRead up
- Exclude checks
This cop tries to produce a complexity score that's a measure of the
complexity the reader experiences when looking at a method. For that
reason it considers when
nodes as something that doesn't add as much
complexity as an if
or a &&
. Except if it's one of those special
case
/when
constructs where there's no expression after case
. Then
the cop treats it as an if
/elsif
/elsif
... and lets all the when
nodes count. In contrast to the CyclomaticComplexity cop, this cop
considers else
nodes as adding complexity.
Example:
def my_method # 1
if cond # 1
case var # 2 (0.8 + 4 * 0.2, rounded)
when 1 then func_one
when 2 then func_two
when 3 then func_three
when 4..10 then func_other
end
else # 1
do_something until a && b # 2
end # ===
end # 7 complexity points
Method has too many lines. [12/10] Open
def method_missing(name, *args, &block)
@result ||= if @batch_action == name
s = yield(@ids)
if s.is_a?(Hash) && s[:data]
Tabulatr::Responses::RawResponse.new(s[:data], filename: s[:filename], type: s[:type])
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
2 trailing blank lines detected. Open
- Exclude checks
end
at 43, 4 is not aligned with if
at 32, 16. Open
end
- Read upRead up
- Exclude checks
This cop checks whether the end keywords are aligned properly.
Three modes are supported through the EnforcedStyleAlignWith
configuration parameter:
If it's set to keyword
(which is the default), the end
shall be aligned with the start of the keyword (if, class, etc.).
If it's set to variable
the end
shall be aligned with the
left-hand-side of the variable assignment, if there is one.
If it's set to start_of_line
, the end
shall be aligned with the
start of the line where the matching keyword appears.
Example: EnforcedStyleAlignWith: keyword (default)
# bad
variable = if true
end
# good
variable = if true
end
Example: EnforcedStyleAlignWith: variable
# bad
variable = if true
end
# good
variable = if true
end
Example: EnforcedStyleAlignWith: startofline
# bad
variable = if true
end
# good
puts(if true
end)
Unused method argument - args
. If it's necessary, use _
or _args
as an argument name to indicate that it won't be used. Open
def method_missing(name, *args, &block)
- 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
When using method_missing
, define respond_to_missing?
and fall back on super
. Open
def method_missing(name, *args, &block)
@result ||= if @batch_action == name
s = yield(@ids)
if s.is_a?(Hash) && s[:data]
Tabulatr::Responses::RawResponse.new(s[:data], filename: s[:filename], type: s[:type])
- Read upRead up
- Exclude checks
This cop checks for the presence of method_missing
without also
defining respond_to_missing?
and falling back on super
.
Example:
#bad
def method_missing(name, *args)
# ...
end
#good
def respond_to_missing?(name, include_private)
# ...
end
def method_missing(name, *args)
# ...
super
end
Use nested module/class definitions instead of compact style. Open
class Tabulatr::Data::Invoker
- Read upRead up
- Exclude checks
This cop checks the style of children definitions at classes and modules. Basically there are two different styles:
Example: EnforcedStyle: nested (default)
# good
# have each child on its own line
class Foo
class Bar
end
end
Example: EnforcedStyle: compact
# good
# combine definitions as much as possible
class Foo::Bar
end
The compact style is only forced for classes/modules with one child.
Line is too long. [94/80] Open
Tabulatr::Responses::RawResponse.new(s[:data], filename: s[:filename], type: s[:type])
- Exclude checks
Line is too long. [95/80] Open
Tabulatr::Responses::FileResponse.new(s[:file], filename: s[:filename], type: s[:type])
- Exclude checks
Use 2 (not -10) spaces for indentation. Open
s = yield(@ids)
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Unused method argument - block
. If it's necessary, use _
or _block
as an argument name to indicate that it won't be used. Open
def method_missing(name, *args, &block)
- 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
Missing top-level class documentation comment. Open
class Tabulatr::Data::Invoker
- Read upRead up
- Exclude checks
This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.
The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.
Example:
# bad
class Person
# ...
end
# good
# Description/Explanation of Person class
class Person
# ...
end