Showing 19 of 19 total issues
Cyclomatic complexity for request_filename is too high. [8/6] Open
def request_filename
if node.root? and node.default_format == format
""
elsif node.root? and format
"#{node.default_name}.#{format}"
- 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.
Cyclomatic complexity for resolve_layout is too high. [7/6] Open
def resolve_layout
return resource.data.fetch("layout") if resource.data.key? "layout"
return layout unless has_layout_conditions?
clause, formats = layout_conditions.first
- 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.
Method compile
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def compile
status "Building #{site.root_path.expand_path} to #{root_path.expand_path}"
resources.each do |resource, path|
if resource.renderable?
status "Rendering #{path}"
- 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 resolve_layout
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def resolve_layout
return resource.data.fetch("layout") if resource.data.key? "layout"
return layout unless has_layout_conditions?
clause, formats = layout_conditions.first
- 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 request_filename
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def request_filename
if node.root? and node.default_format == format
""
elsif node.root? and format
"#{node.default_name}.#{format}"
- 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_basename
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def parse_basename
base = basename
filename, extname = split_filename(base)
# This is a root path, so we have to treat it a little differently
- 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 controller_layout
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def controller_layout
private_layout_method = self.method(:_layout)
layout =
if Rails.version >= "6"
private_layout_method.call lookup_context, current_resource_rails_formats
- 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 - glob
. If it's necessary, use _
or _glob
as an argument name to indicate that it won't be used. You can also write as all(*)
if you want the method to accept any arguments but don't care about them. Open
def self.all(glob = "**/*.gemspec")
- 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
unexpected token kRESCUE
(Using Ruby 2.2 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
rescue
- Exclude checks
Unused method argument - title_key
. Open
def link_to_page(page, *args, title_key: DEFAULT_TITLE_KEY, **kwargs, &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
unexpected token error
(Using Ruby 2.2 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
format&.to_sym
- Exclude checks
unexpected token error
(Using Ruby 2.2 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
format_extension = path.format&.to_s
- Exclude checks
unexpected token error
(Using Ruby 2.2 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
(handler_is_format? ? handler : @format)&.to_sym
- Exclude checks
Useless assignment to variable - headers
. Use _
or _headers
as a variable name to indicate that it won't be used. Open
code, headers, response = rails_app.routes.call env
- Read upRead up
- Exclude checks
This cop checks for every useless assignment to local variable in every
scope.
The basic idea for this cop was from the warning of ruby -cw
:
assigned but unused variable - foo
Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.
Example:
# bad
def some_method
some_var = 1
do_something
end
Example:
# good
def some_method
some_var = 1
do_something(some_var)
end
Useless assignment to variable - code
. Use _
or _code
as a variable name to indicate that it won't be used. Open
code, headers, response = rails_app.routes.call env
- Read upRead up
- Exclude checks
This cop checks for every useless assignment to local variable in every
scope.
The basic idea for this cop was from the warning of ruby -cw
:
assigned but unused variable - foo
Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.
Example:
# bad
def some_method
some_var = 1
do_something
end
Example:
# good
def some_method
some_var = 1
do_something(some_var)
end
TODO found Open
# TODO: I don't want to look this up everytime I try to figure out the
- Exclude checks
TODO found Open
# TODO: Put a better extension/mime_type handler into resource tree, then instead of faltening
- Exclude checks
TODO found Open
# TODO: Get rid of these so that folks have ot call site.resources.get ...
- Exclude checks
TODO found Open
# TODO: When `type: :all` is scoped, some queries will mistakenly return single resources.
- Exclude checks