Cyclomatic complexity for execute_with_options_with_newrelic is too high. [8/6] Open
define_method :execute_with_options_with_newrelic do |statement, options|
operation = nil
statement_txt = nil
statement_words = nil
- 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.
Block has too many lines. [29/25] Open
define_method :execute_with_options_with_newrelic do |statement, options|
operation = nil
statement_txt = nil
statement_words = nil
- Read upRead up
- Exclude checks
This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.
Add an empty line after magic comments. Open
begin
- Read upRead up
- Exclude checks
Checks for a newline after the final magic comment.
Example:
# good
# frozen_string_literal: true
# Some documentation for Person
class Person
# Some code
end
# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
# Some code
end
Extra blank line detected. Open
included do
- Read upRead up
- Exclude checks
This cops checks for two or more consecutive blank lines.
Example:
# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method
# good
some_method
# one empty line
some_method
Avoid when
branches without a body. Open
when "batch"
- Read upRead up
- Exclude checks
This cop checks for the presence of when
branches without a body.
Example:
# bad
case foo
when bar then 1
when baz then # nothing
end
Example:
# good
case foo
when bar then 1
when baz then 2
end
Line is too long. [84/80] Open
NewRelic::Agent::Datastores.wrap("Cassandra", operation, table, callback) do
- Exclude checks
Use proc
instead of Proc.new
. Open
callback = Proc.new do |result, scoped_metric, elapsed|
- Read upRead up
- Exclude checks
This cops checks for uses of Proc.new where Kernel#proc would be more appropriate.
Example:
# bad
p = Proc.new { |n| puts n }
# good
p = proc { |n| puts n }
Unnecessary utf-8 encoding comment. Open
# -*- encoding : utf-8 -*-
- Exclude checks
Use alias_method
instead of alias
. Open
alias :execute_with_options_without_newrelic :execute_with_options
- Read upRead up
- Exclude checks
This cop enforces the use of either #alias
or #alias_method
depending on configuration.
It also flags uses of alias :symbol
rather than alias bareword
.
Example: EnforcedStyle: prefer_alias (default)
# bad
alias_method :bar, :foo
alias :bar :foo
# good
alias bar foo
Example: EnforcedStyle: preferaliasmethod
# bad
alias :bar :foo
alias bar foo
# good
alias_method :bar, :foo
Use alias_method
instead of alias
. Open
alias :execute_with_options :execute_with_options_with_newrelic
- Read upRead up
- Exclude checks
This cop enforces the use of either #alias
or #alias_method
depending on configuration.
It also flags uses of alias :symbol
rather than alias bareword
.
Example: EnforcedStyle: prefer_alias (default)
# bad
alias_method :bar, :foo
alias :bar :foo
# good
alias bar foo
Example: EnforcedStyle: preferaliasmethod
# bad
alias :bar :foo
alias bar foo
# good
alias_method :bar, :foo