Showing 209 of 209 total issues
Method substitute_variables
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def substitute_variables(tokens, symbol_table)
return tokens unless symbol_table
tokens.inject([]) do |ret, token|
if token.type == :variable && sub = symbol_table.fetch(token.value)
# variables can themselves contain references to other variables
- 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 deep_symbolize_keys
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def deep_symbolize_keys(arg)
case arg
when Array
arg.map { |elem| deep_symbolize_keys(elem) }
when Hash
- 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 tokenize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def tokenize(text)
text.split(splitter).inject([]) do |ret, token_text|
recognizer = recognizers.find do |recognizer|
recognizer.recognizes?(token_text)
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 dump
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def dump(obj, opts = {})
@options = opts.dup
@options[:indent_size] = 2 if @options[:indent_size].to_i <= 0
@options[:minimum_block_length] = 0 if @options[:minimum_block_length].to_i <= 0
@options.update(
- 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 formats_from_node
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def formats_from_node(formats_node, type, number_system)
formats_node.xpath("#{type}FormatLength").each_with_object({}) do |format_length_node, format_result|
format_nodes = format_length_node.xpath("#{type}Format")
format_key = format_length_node.attribute('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 find_match_comment_after
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def find_match_comment_after(idx)
loop do
return nil if idx > schema.size
if schema[idx].strip.start_with?('<!--@MATCH')
- 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 init_tertiary_constants
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def init_tertiary_constants
@case_switch = @case_first == :upper ? CASE_SWITCH : NO_CASE_SWITCH
if @case_first
@tertiary_mask = KEEP_CASE_MASK
- 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
Avoid too many return
statements within this method. Open
return true, true, is_one_line?(str), is_one_plain_line?(str)
Avoid too many return
statements within this method. Open
return code_point + NON_CJK_OFFSET if code_point < CJK_A_BASE
Avoid too many return
statements within this method. Open
return mz_name
Avoid too many return
statements within this method. Open
return code_point if code_point < CJK_B_LIMIT # non-BMP-CJK
Avoid too many return
statements within this method. Open
return code_point + NON_CJK_OFFSET # non-CJK
Avoid too many return
statements within this method. Open
return code_point + NON_CJK_OFFSET if code_point < CJK_D_BASE
Avoid too many return
statements within this method. Open
return mz_name
Avoid too many return
statements within this method. Open
return partial_location_name_for(tz_metazone.metazone, mz_name)
Avoid too many return
statements within this method. Open
return code_point + NON_CJK_OFFSET if code_point < CJK_C_BASE
Avoid too many return
statements within this method. Open
return code_point - CJK_A_BASE + (CJK_LIMIT - CJK_BASE) + (CJK_COMPAT_USED_LIMIT - CJK_COMPAT_USED_BASE) if code_point < CJK_A_LIMIT
Avoid too many return
statements within this method. Open
return code_point if code_point < CJK_C_LIMIT # non-BMP-CJK
Avoid too many return
statements within this method. Open
return code_point if code_point < CJK_D_LIMIT # non-BMP-CJK
Similar blocks of code found in 2 locations. Consider refactoring. Open
def execute
output_file = File.join(output_path, 'aliases.yml')
FileUtils.mkdir_p(output_path)
File.open(output_file, 'w:utf-8') do |output|
- 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 31.
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