Method split_on
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def split_on( file_name, field, options = {} )
regex = options[:filter] ? Regexp.new(options[:filter]) : nil
log :debug, "Using REGEX: #{regex.inspect}" if regex
- 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 file_set_field_by_map
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def file_set_field_by_map( file_name, fields, value_map, regex = nil )
lines = []
objects = []
- 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 file_set_field_by_map
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def file_set_field_by_map( file_name, fields, value_map, regex = nil )
lines = []
objects = []
Method file_set_field
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def file_set_field( file_name, field, old_value, new_value, regex = nil )
Pass __FILE__
and __LINE__
to eval
method, as they are used by backtraces. Open
instance_eval <<-end_eval
- Read upRead up
- Exclude checks
This cop checks eval
method usage. eval
can receive source location
metadata, that are filename and line number. The metadata is used by
backtraces. This cop recommends to pass the metadata to eval
method.
Example:
# bad
eval <<-RUBY
def do_something
end
RUBY
# bad
C.class_eval <<-RUBY
def do_something
end
RUBY
# good
eval <<-RUBY, binding, __FILE__, __LINE__ + 1
def do_something
end
RUBY
# good
C.class_eval <<-RUBY, __FILE__, __LINE__ + 1
def do_something
end
RUBY
Do not place comments on the same line as the end
keyword. Open
end # END class methods
- Read upRead up
- Exclude checks
This cop checks for comments put on the same line as some keywords.
These keywords are: begin
, class
, def
, end
, module
.
Note that some comments (such as :nodoc:
and rubocop:disable
) are
allowed.
Example:
# bad
if condition
statement
end # end if
# bad
class X # comment
statement
end
# bad
def x; end # comment
# good
if condition
statement
end
# good
class X # :nodoc:
y
end
Use uppercase heredoc delimiters. Open
end_eval
- Read upRead up
- Exclude checks
This cop checks that your heredocs are using the configured case. By default it is configured to enforce uppercase heredocs.
Example: EnforcedStyle: uppercase (default)
# bad
<<-sql
SELECT * FROM foo
sql
# good
<<-SQL
SELECT * FROM foo
SQL
Example: EnforcedStyle: lowercase
# bad
<<-SQL
SELECT * FROM foo
SQL
# good
<<-sql
SELECT * FROM foo
sql
Pass __FILE__
and __LINE__
to eval
method, as they are used by backtraces. Open
class_eval <<-end_eval
- Read upRead up
- Exclude checks
This cop checks eval
method usage. eval
can receive source location
metadata, that are filename and line number. The metadata is used by
backtraces. This cop recommends to pass the metadata to eval
method.
Example:
# bad
eval <<-RUBY
def do_something
end
RUBY
# bad
C.class_eval <<-RUBY
def do_something
end
RUBY
# good
eval <<-RUBY, binding, __FILE__, __LINE__ + 1
def do_something
end
RUBY
# good
C.class_eval <<-RUBY, __FILE__, __LINE__ + 1
def do_something
end
RUBY
Use a guard clause instead of wrapping the code inside a conditional expression. Open
unless filtered.empty?
- Read upRead up
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression
Example:
# bad
def test
if something
work
end
end
# good
def test
return unless something
work
end
# also good
def test
work if something
end
# bad
if something
raise 'exception'
else
ok
end
# good
raise 'exception' if something
ok
Use uppercase heredoc delimiters. Open
end_eval
- Read upRead up
- Exclude checks
This cop checks that your heredocs are using the configured case. By default it is configured to enforce uppercase heredocs.
Example: EnforcedStyle: uppercase (default)
# bad
<<-sql
SELECT * FROM foo
sql
# good
<<-SQL
SELECT * FROM foo
SQL
Example: EnforcedStyle: lowercase
# bad
<<-SQL
SELECT * FROM foo
SQL
# good
<<-sql
SELECT * FROM foo
sql
Use uppercase heredoc delimiters. Open
end_eval
- Read upRead up
- Exclude checks
This cop checks that your heredocs are using the configured case. By default it is configured to enforce uppercase heredocs.
Example: EnforcedStyle: uppercase (default)
# bad
<<-sql
SELECT * FROM foo
sql
# good
<<-SQL
SELECT * FROM foo
SQL
Example: EnforcedStyle: lowercase
# bad
<<-SQL
SELECT * FROM foo
SQL
# good
<<-sql
SELECT * FROM foo
sql
Pass __FILE__
and __LINE__
to eval
method, as they are used by backtraces. Open
instance_eval <<-end_eval
- Read upRead up
- Exclude checks
This cop checks eval
method usage. eval
can receive source location
metadata, that are filename and line number. The metadata is used by
backtraces. This cop recommends to pass the metadata to eval
method.
Example:
# bad
eval <<-RUBY
def do_something
end
RUBY
# bad
C.class_eval <<-RUBY
def do_something
end
RUBY
# good
eval <<-RUBY, binding, __FILE__, __LINE__ + 1
def do_something
end
RUBY
# good
C.class_eval <<-RUBY, __FILE__, __LINE__ + 1
def do_something
end
RUBY
Pass __FILE__
and __LINE__
to eval
method, as they are used by backtraces. Open
class_eval <<-end_eval
- Read upRead up
- Exclude checks
This cop checks eval
method usage. eval
can receive source location
metadata, that are filename and line number. The metadata is used by
backtraces. This cop recommends to pass the metadata to eval
method.
Example:
# bad
eval <<-RUBY
def do_something
end
RUBY
# bad
C.class_eval <<-RUBY
def do_something
end
RUBY
# good
eval <<-RUBY, binding, __FILE__, __LINE__ + 1
def do_something
end
RUBY
# good
C.class_eval <<-RUBY, __FILE__, __LINE__ + 1
def do_something
end
RUBY
Use uppercase heredoc delimiters. Open
end_eval
- Read upRead up
- Exclude checks
This cop checks that your heredocs are using the configured case. By default it is configured to enforce uppercase heredocs.
Example: EnforcedStyle: uppercase (default)
# bad
<<-sql
SELECT * FROM foo
sql
# good
<<-SQL
SELECT * FROM foo
SQL
Example: EnforcedStyle: lowercase
# bad
<<-SQL
SELECT * FROM foo
SQL
# good
<<-sql
SELECT * FROM foo
sql
Use uppercase heredoc delimiters. Open
end_eval
- Read upRead up
- Exclude checks
This cop checks that your heredocs are using the configured case. By default it is configured to enforce uppercase heredocs.
Example: EnforcedStyle: uppercase (default)
# bad
<<-sql
SELECT * FROM foo
sql
# good
<<-SQL
SELECT * FROM foo
SQL
Example: EnforcedStyle: lowercase
# bad
<<-SQL
SELECT * FROM foo
SQL
# good
<<-sql
SELECT * FROM foo
sql
Pass __FILE__
and __LINE__
to eval
method, as they are used by backtraces. Open
instance_eval <<-end_eval
- Read upRead up
- Exclude checks
This cop checks eval
method usage. eval
can receive source location
metadata, that are filename and line number. The metadata is used by
backtraces. This cop recommends to pass the metadata to eval
method.
Example:
# bad
eval <<-RUBY
def do_something
end
RUBY
# bad
C.class_eval <<-RUBY
def do_something
end
RUBY
# good
eval <<-RUBY, binding, __FILE__, __LINE__ + 1
def do_something
end
RUBY
# good
C.class_eval <<-RUBY, __FILE__, __LINE__ + 1
def do_something
end
RUBY