Assignment Branch Condition size for check_for_errors is too high. [19.62/15] Open
def self.check_for_errors(json)
if json["status"] == -1
if json.include? "errorNumber"
raise_error json["errorNumber"], json["errorMessage"]
end
- 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 check_for_errors
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.check_for_errors(json)
if json["status"] == -1
if json.include? "errorNumber"
raise_error json["errorNumber"], json["errorMessage"]
end
- 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
Extra empty line detected before the rescue
. Open
rescue RestClient::ExceptionWithResponse => e
- Read upRead up
- Exclude checks
This cops checks if empty lines exist around the bodies of begin
sections. This cop doesn't check empty lines at begin
body
beginning/end and around method definition body.
Style/EmptyLinesAroundBeginBody
or Style/EmptyLinesAroundMethodBody
can be used for this purpose.
Example:
# good
begin
do_something
rescue
do_something2
else
do_something3
ensure
do_something4
end
# good
def foo
do_something
rescue
do_something2
end
# bad
begin
do_something
rescue
do_something2
else
do_something3
ensure
do_something4
end
# bad
def foo
do_something
rescue
do_something2
end
Extra empty line detected after the rescue
. Open
unless e.response.code == 503
- Read upRead up
- Exclude checks
This cops checks if empty lines exist around the bodies of begin
sections. This cop doesn't check empty lines at begin
body
beginning/end and around method definition body.
Style/EmptyLinesAroundBeginBody
or Style/EmptyLinesAroundMethodBody
can be used for this purpose.
Example:
# good
begin
do_something
rescue
do_something2
else
do_something3
ensure
do_something4
end
# good
def foo
do_something
rescue
do_something2
end
# bad
begin
do_something
rescue
do_something2
else
do_something3
ensure
do_something4
end
# bad
def foo
do_something
rescue
do_something2
end
Extra empty line detected at begin
body beginning. Open
resp = RestClient.post url, body, content_type: :json
- Read upRead up
- Exclude checks
This cops checks if empty lines exist around the bodies of begin-end blocks.
Example:
# good
begin
# ...
end
# bad
begin
# ...
end
Extra empty line detected at begin
body end. Open
end
- Read upRead up
- Exclude checks
This cops checks if empty lines exist around the bodies of begin-end blocks.
Example:
# good
begin
# ...
end
# bad
begin
# ...
end
Freeze mutable objects assigned to constants. Open
IGNORED_ERROR_CODES = [
"9602", # No license to disassociate
"9616", # License already assigned
]
- 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