Showing 687 of 687 total issues
Method offense_message
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def offense_message(line)
effective_style = if style == :native
Platform.windows? ? :crlf : :lf
else
style
- 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_def
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def on_def(node)
return if acceptable?(node)
if node.body.nil?
register_offense(node, MSG_EMPTY)
- 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 roundup_relevant_cops
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def roundup_relevant_cops(processed_source)
cops.select do |cop|
next true if processed_source.comment_config.cop_opted_in?(cop)
next false if cop.excluded_file?(processed_source.file_path)
next false unless @registry.enabled?(cop, @config)
- 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 find_offending_var
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def find_offending_var(node, variables = Set.new, values = [])
if node.or_type?
find_offending_var(node.lhs, variables, values)
find_offending_var(node.rhs, variables, values)
elsif simple_double_comparison?(node)
- 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_send
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def on_send(node)
return if node.arguments.empty?
return unless node.arguments.all?(&:array_type?)
offense = offense_range(node)
- 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_send
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def on_send(node)
return if allow_send? && !node.method?(:public_send)
return unless (first_argument = node.first_argument)
return unless STATIC_METHOD_NAME_NODE_TYPES.include?(first_argument.type)
- 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 return_boolean_value?
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def return_boolean_value?(condition)
return false unless condition
if condition.begin_type?
return_boolean_value?(condition.children.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 ignored_literal_ranges
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def ignored_literal_ranges(ast)
# which lines start inside a string literal?
return [] if ast.nil?
ast.each_node(:str, :dstr, :array).with_object(Set.new) do |literal, ranges|
- 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 11 (exceeds 5 allowed). Consider refactoring. Open
def on_new_investigation
last_line = last_line(processed_source)
processed_source.raw_source.each_line.with_index do |line, index|
break if index >= last_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
Method complexity_score_for
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def complexity_score_for(node)
case node.type
when :case
# If cond is nil, that means each when has an expression that
# evaluates to true or false. It's just an alternative to
- 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 exclusive_with?
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def exclusive_with?(other)
return false unless other
return false if may_jump_to_other_branch?
other.each_ancestor(include_self: true) do |other_ancestor|
- 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 validate_cop_list
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def validate_cop_list(names)
return unless names
cop_names = Cop::Registry.global.names
departments = Cop::Registry.global.departments.map(&:to_s)
- 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 corrected_rand_op_integer(node)
random_call(node) do |prefix_node, random_node|
prefix = prefix_from_prefix_node(prefix_node)
left_int, right_int = boundaries_from_random_node(random_node)
- 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 53.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def corrected_integer_op_rand(node)
random_call(node) do |prefix_node, random_node|
prefix = prefix_from_prefix_node(prefix_node)
left_int, right_int = boundaries_from_random_node(random_node)
- 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 53.
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_check_options
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_check_options(opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
section(opts, 'Basic Options') do # rubocop:disable Metrics/BlockLength
option(opts, '-l', '--lint') do
@options[:only] ||= []
@options[:only] << 'Lint'
Method extract_ruby_sources
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def extract_ruby_sources(processed_source)
self.class.ruby_extractors.find do |ruby_extractor|
result = ruby_extractor.call(processed_source)
break result if result
rescue StandardError
- 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 contained_by_multiline_collection_that_could_be_broken_up?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def contained_by_multiline_collection_that_could_be_broken_up?(node)
node.each_ancestor.find do |ancestor|
if (ancestor.hash_type? || ancestor.array_type?) &&
breakable_collection?(ancestor, ancestor.children)
return children_could_be_broken_up?(ancestor.children)
- 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_class
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def on_class(node)
return unless (module_node = node.parent) && node.parent_class
description_beginning = first_comment_line(module_node)
return unless description_beginning
- 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 extension_versions
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.extension_versions(env)
features = config_for_pwd(env).loaded_features.sort
features.filter_map do |loaded_feature|
next unless (match = loaded_feature.match(/rubocop-(?<feature>.*)/))
- 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 properties
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def properties(cop)
header = [
'Enabled by default', 'Safe', 'Supports autocorrection', 'Version Added',
'Version Changed'
]
- 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"