Showing 56 of 56 total issues
Assignment Branch Condition size for run is too high. [17.15/15] Open
def run
Dir.chdir(@directory) do
Dir["**/*.rb"].each do |path|
parsed = RuboCop::ProcessedSource.new(File.read(path), path)
- 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
Assignment Branch Condition size for on_method_def is too high. [16.58/15] Open
def on_method_def(_node, _method_name, _args, body)
return unless _method_name == :init
return unless body
return if body.self_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
Method on_method_def
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def on_method_def(_node, _method_name, _args, body)
return unless _method_name == :init
return unless body
return if body.self_type?
- 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
Avoid too many return
statements within this method. Open
return if last_expr_in_body.self_type?
Avoid too many return
statements within this method. Open
return if last_expr_in_body.return_type? && last_expr_in_body.children.last.self_type?
Freeze mutable objects assigned to constants. Open
MESSAGE = "When overriding the #dealloc method, super must be called."
- Read upRead up
- Exclude checks
This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).
Example:
# bad
CONST = [1, 2, 3]
# good
CONST = [1, 2, 3].freeze
Freeze mutable objects assigned to constants. Open
MESSAGE = "When overriding the #init method, self must be returned."
- Read upRead up
- Exclude checks
This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).
Example:
# bad
CONST = [1, 2, 3]
# good
CONST = [1, 2, 3].freeze
Space inside parentheses detected. Open
def initialize(directory: , io: , engine_config: )
- Read upRead up
- Exclude checks
Checks for spaces inside ordinary round parentheses.
Example:
# bad
f( 3)
g = (a + 3 )
# good
f(3)
g = (a + 3)
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Open
require 'json'
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Open
require 'rubocop/cop/rubymotion/dealloc_must_call_super'
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Extra empty line detected at module body beginning. Open
class DeallocMustCallSuper < Cop
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of modules match the configuration.
Example: EnforcedStyle: empty_lines
# good
module Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
module Foo
module Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
module Foo
def bar; end
end
Example: EnforcedStyle: noemptylines (default)
# good
module Foo
def bar
# ...
end
end
Freeze mutable objects assigned to constants. Open
MESSAGE = "Do not use retainCount"
- Read upRead up
- Exclude checks
This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).
Example:
# bad
CONST = [1, 2, 3]
# good
CONST = [1, 2, 3].freeze
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Open
require 'rake/testtask'
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Space missing to the left of {. Open
if body.each_node.none?{|x| x.type == :self }
- Read upRead up
- Exclude checks
Checks that block braces have or don't have a space before the opening brace depending on configuration.
Example:
# bad
foo.map{ |a|
a.bar.to_s
}
# good
foo.map { |a|
a.bar.to_s
}
Trailing whitespace detected. Open
private
- Exclude checks
Line is too long. [96/80] Open
return if last_expr_in_body.return_type? && last_expr_in_body.children.last.self_type?
- Exclude checks
Trailing whitespace detected. Open
if (node.children.last == :retainCount) ||
- Exclude checks
Space found before comma. Open
def initialize(directory: , io: , engine_config: )
- Read upRead up
- Exclude checks
Checks for comma (,) preceded by space.
Example:
# bad
[1 , 2 , 3]
a(1 , 2)
each { |a , b| }
# good
[1, 2, 3]
a(1, 2)
each { |a, b| }
Line is too long. [111/80] Open
gem "rubocop", :git => 'https://github.com/mrb/rubocop.git', :ref => 'c4b6ae4c323172c81e0f8f18f54e4e36a03b73d1'
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks