File default.rb
has 1648 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Parser
##
# Default AST builder. Uses {AST::Node}s.
#
Class Default
has 198 methods (exceeds 20 allowed). Consider refactoring. Open
class Builders::Default
class << self
##
# AST compatibility attribute; since `-> {}` is not semantically
# equivalent to `lambda {}`, all new code should set this attribute
Method accessible
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def accessible(node)
case node.type
when :__FILE__
if @emit_file_line_as_literals
n(:str, [ node.loc.expression.source_buffer.name ],
- 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 check_condition
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def check_condition(cond)
case cond.type
when :masgn
if @parser.version <= 23
diagnostic :error, :masgn_as_condition, nil, cond.loc.expression
- 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 accessible
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def accessible(node)
case node.type
when :__FILE__
if @emit_file_line_as_literals
n(:str, [ node.loc.expression.source_buffer.name ],
Method associate
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def associate(begin_t, pairs, end_t)
key_set = Set.new
pairs.each do |pair|
next unless pair.type.eql?(:pair)
- 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 dedent_string
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def dedent_string(node, dedent_level)
if !dedent_level.nil?
dedenter = Lexer::Dedenter.new(dedent_level)
case node.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 check_condition
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_condition(cond)
case cond.type
when :masgn
if @parser.version <= 23
diagnostic :error, :masgn_as_condition, nil, cond.loc.expression
Method begin_body
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def begin_body(compound_stmt, rescue_bodies=[],
else_t=nil, else_=nil,
ensure_t=nil, ensure_=nil)
if rescue_bodies.any?
if else_t
- 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 begin_body
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def begin_body(compound_stmt, rescue_bodies=[],
else_t=nil, else_=nil,
ensure_t=nil, ensure_=nil)
if rescue_bodies.any?
if else_t
Method assignable
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def assignable(node)
case node.type
when :cvar
node.updated(:cvasgn)
Method eh_keyword_map
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def eh_keyword_map(compstmt_e, keyword_t, body_es,
else_t, else_e)
if compstmt_e.nil?
if keyword_t.nil?
begin_l = body_es.first.loc.expression
- 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 condition
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def condition(cond_t, cond, then_t,
if_true, else_t, if_false, end_t)
Method for
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def for(for_t, iterator, in_t, iteratee,
do_t, body, end_t)
Method def_endless_singleton
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def def_endless_singleton(def_t, definee, dot_t,
name_t, args,
assignment_t, body)
Method condition_map
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def condition_map(keyword_t, cond_e, begin_t, body_e, else_t, else_e, end_t)
Method def_singleton
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def def_singleton(def_t, definee, dot_t,
name_t, args,
body, end_t)
Method rescue_body
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def rescue_body(rescue_t,
exc_list, assoc_t, exc_var,
then_t, compound_stmt)
Method rescue_body_map
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def rescue_body_map(keyword_t, exc_list_e, assoc_t,
exc_var_e, then_t,
compstmt_e)
Method check_duplicate_args
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def check_duplicate_args(args, map={})
args.each do |this_arg|
case this_arg.type
when :arg, :optarg, :restarg, :blockarg,
:kwarg, :kwoptarg, :kwrestarg,
- 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 case
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def case(case_t, expr, when_bodies, else_t, else_body, end_t)
Method loop
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def loop(type, keyword_t, cond, do_t, body, end_t)
Method case_match
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def case_match(case_t, expr, in_bodies, else_t, else_body, end_t)
Method begin_body
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def begin_body(compound_stmt, rescue_bodies=[],
else_t=nil, else_=nil,
ensure_t=nil, ensure_=nil)
Method call_method
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def call_method(receiver, dot_t, selector_t,
lparen_t=nil, args=[], rparen_t=nil)
Method send_map
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def send_map(receiver_e, dot_t, selector_t, begin_t=nil, args=[], end_t=nil)
Method def_class
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def def_class(class_t, name,
lt_t, superclass,
body, end_t)
Method block
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def block(method_call, begin_t, args, body, end_t)
_receiver, _selector, *call_args = *method_call
if method_call.type == :yield
diagnostic :error, :block_given_to_yield, nil, method_call.loc.keyword, [loc(begin_t)]
- 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 def_sclass
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def def_sclass(class_t, lshft_t, expr,
body, end_t)
Method in_pattern
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def in_pattern(in_t, pattern, guard, then_t, body)
Method def_method
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def def_method(def_t, name_t, args,
body, end_t)
Method keyword_cmd
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def keyword_cmd(type, keyword_t, lparen_t=nil, args=[], rparen_t=nil)
Method ternary_map
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def ternary_map(begin_e, question_t, mid_e, colon_t, end_e)
Method endless_definition_map
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def endless_definition_map(keyword_t, operator_t, name_t, assignment_t, body_e)
Method diagnostic
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def diagnostic(type, reason, arguments, location, highlights=[])
Method ternary
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def ternary(cond, question_t, if_true, colon_t, if_false)
Method block
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def block(method_call, begin_t, args, body, end_t)
Method eh_keyword_map
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def eh_keyword_map(compstmt_e, keyword_t, body_es,
else_t, else_e)
Method def_endless_method
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def def_endless_method(def_t, name_t, args,
assignment_t, body)
Method match_hash_var_from_str
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def match_hash_var_from_str(begin_t, strings, end_t)
if strings.length > 1
diagnostic :error, :pm_interp_in_var_name, nil, loc(begin_t).join(loc(end_t))
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
Method condition_map
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def condition_map(keyword_t, cond_e, begin_t, body_e, else_t, else_e, end_t)
if end_t
end_l = loc(end_t)
elsif else_e && else_e.loc.expression
end_l = else_e.loc.expression
- 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 collection_map
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def collection_map(begin_t, parts, end_t)
if begin_t.nil? || end_t.nil?
if parts.any?
expr_l = join_exprs(parts.first, parts.last)
elsif !begin_t.nil?
- 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 static_string
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def static_string(nodes)
nodes.map do |node|
case node.type
when :str
node.children[0]
- 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 procarg0
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def procarg0(arg)
if self.class.emit_procarg0
if arg.type == :arg && self.class.emit_arg_inside_procarg0
n(:procarg0, [ arg ],
Source::Map::Collection.new(nil, nil, arg.location.expression))
- 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 binary_op
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def binary_op(receiver, operator_t, arg)
source_map = send_binary_op_map(receiver, operator_t, arg)
if @parser.version == 18
operator = value(operator_t)
- 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 array_pattern
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def array_pattern(lbrack_t, elements, rbrack_t)
return n(:array_pattern, nil, collection_map(lbrack_t, [], rbrack_t)) if elements.nil?
trailing_comma = false
- 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 string_compose
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def string_compose(begin_t, parts, end_t)
if collapse_string_parts?(parts)
if begin_t.nil? && end_t.nil?
parts.first
else
- 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 string_map
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def string_map(begin_t, parts, end_t)
if begin_t && value(begin_t).start_with?('<<')
if parts.any?
expr_l = join_exprs(parts.first, parts.last)
else
- 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 rescue_body_map
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def rescue_body_map(keyword_t, exc_list_e, assoc_t,
exc_var_e, then_t,
compstmt_e)
end_l = compstmt_e.loc.expression if compstmt_e
end_l = loc(then_t) if end_l.nil? && then_t
- 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 keyword_map
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def keyword_map(keyword_t, begin_t, args, end_t)
args ||= []
if end_t
end_l = loc(end_t)
- 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 restarg(star_t, name_t=nil)
if name_t
check_reserved_for_numparam(value(name_t), loc(name_t))
n(:restarg, [ value(name_t).to_sym ],
arg_prefix_map(star_t, name_t))
- 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 25.
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
if self.class.emit_index
n(:index, [ receiver, *indexes ],
index_map(receiver, lbrack_t, rbrack_t))
else
n(:send, [ receiver, :[], *indexes ],
- 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 25.
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 kwrestarg(dstar_t, name_t=nil)
if name_t
check_reserved_for_numparam(value(name_t), loc(name_t))
n(:kwrestarg, [ value(name_t).to_sym ],
- 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 25.
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
if self.class.emit_index
n(:indexasgn, [ receiver, *indexes ],
index_map(receiver, lbrack_t, rbrack_t))
else
# Incomplete method call.
- 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 25.
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