Showing 666 of 666 total issues
Method last_heredoc_argument
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def last_heredoc_argument(node)
n = last_heredoc_argument_node(node)
return n if heredoc?(n)
return unless n.respond_to?(:arguments)
- 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 invertible?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def invertible?(node)
case node.type
when :begin
invertible?(node.children.first)
when :send
- 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 process_errors
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def process_errors(file, errors)
errors.each do |error|
line = ":#{error.line}" if error.line
column = ":#{error.column}" if error.column
location = "#{file}#{line}#{column}"
- 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 on_new_investigation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def on_new_investigation
str_ranges = nil
processed_source.lines.each.with_index(1) do |line, lineno|
next unless (range = find_offense(line, lineno))
- 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 each_extra_empty_line
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def each_extra_empty_line(lines)
prev_line = 1
lines.each do |cur_line|
if exceeds_line_offset?(cur_line - prev_line)
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def each_escape(node)
node.parsed_tree&.traverse&.reduce(0) do |char_class_depth, (event, expr)|
yield(expr.text[1], expr.ts, !char_class_depth.zero?) if expr.type == :escape
if expr.type == :set
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 40.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method add_additional_modes
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_additional_modes(opts)
section(opts, 'Additional Modes') do
option(opts, '-L', '--list-target-files')
option(opts, '--show-cops [COP1,COP2,...]') do |list|
@options[:show_cops] = list.nil? ? [] : list.split(',')
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def each_escape(node)
node.parsed_tree&.traverse&.reduce(0) do |char_class_depth, (event, expr)|
yield(expr.text[1], expr.start_index, !char_class_depth.zero?) if expr.type == :escape
if expr.type == :set
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 40.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method file
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def file
return cache_path unless cache_path_expired?
request do |response|
next if response.is_a?(Net::HTTPNotModified)
- 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 autocorrect
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def autocorrect(corrector, node, range, offending_name, preferred_name)
Method move_pos
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def move_pos(src, pos, step, condition, regexp)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(file, team, options, config_store, cache_root = nil)
Method space_offense
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def space_offense(node, token, side, message, command)
Method check
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def check(node, items, kind, begin_pos, end_pos)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
file_count, offense_count, correction_count, correctable_count, rainbow,
safe_autocorrect: false
Method move_pos_str
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def move_pos_str(src, pos, step, condition, needle)
Method fix_include_paths
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def fix_include_paths(base_config_path, hash, path, key, value)
Method autocorrect
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def autocorrect(corrector, node, condition, replacement, guard)
Method autocorrect_heredoc_argument
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def autocorrect_heredoc_argument(corrector, node, heredoc_branch, leave_branch, guard)
Method apply_autocorrect
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def apply_autocorrect(corrector, node, rhs, operator, new_rhs)