Showing 28 of 28 total issues
Method increment_the_branch
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def increment_the_branch( array_to_sub, selector, next_selector )
if selector > next_selector #going up the tree and reset
selectors_to_reset = @substitutions.inject([]){ |m,(k,v)| m << k if k > next_selector; m }
selectors_to_reset.each do | this_selector |
substitutor = @substitutions[this_selector]
- 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
File leaders.rb
has 297 lines of code (exceeds 250 allowed). Consider refactoring. Open
module LegalToMarkdown
extend self
module Leaders
Method get_the_levels
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def get_the_levels
begin
@headers.each do | header, value |
if @deep_leaders
search = "l" + header[-1] + "." if header =~ /level-\d/
- 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 build_jason
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def build_jason
if @content.is_a?(Array)
@content[0] = build_header_and_text_hashs @content[0] unless @content[0].empty?
@content[2] = build_header_and_text_hashs @content[2] unless @content[2].empty?
content_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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def guard_strings strings
strings.scan(/\:(\S.*)$/){ |m| strings = strings.gsub( m[0], " " + m[0] ) }
strings.scan(/^((level-\d+:)(.+)\"*)$/) do |m|
line = m[0]; level = m[1]; field = m[2].strip.delete "\""
if field =~ /[^\.\)]\z/
- 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 66.
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 string_guard strings
strings.scan(/\:(\S.*)$/){ |m| strings = strings.gsub( m[0], " " + m[0] ) }
strings.scan(/^((level-\d+:)(.+)\"*)$/) do |m|
line = m[0]; level = m[1]; field = m[2].strip.delete "\""
if field =~ /[^\.\)]\z/
- 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 66.
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 build_the_block_for_jason
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_the_block_for_jason( arrayed_block )
require 'securerandom'
annotations_hash = {}
provisions_hash = arrayed_block.inject({}) do |block, arrayed_line|
(sub_it, reference, selector, arrayed_line) = block_builder arrayed_line
Method write_it
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def write_it( final_content, writer )
final_content = final_content.gsub(/ +\n/, "\n") if writer == :markdown
require 'json' if writer == :jason
if @output_file && @output_file != "-"
File.open(@output_file, "w") {|f| f.write( final_content ); f.close } if writer == :markdown
- 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 verbose_after_process
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def verbose_after_process source, action
if @verbose
puts
puts Paint["Here's what I found after running the #{action}.", :blue, :bold]
puts Paint['=============================================', :blue]
- 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 clauses_churn_add
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def clauses_churn_add
@clauses_added.each do | mixin |
pattern = /(\[\{\{#{mixin}\}\}\s*?)(.*?\n*?)(\])/m
sub_pattern = /\[\{\{(\S+?)\}\}\s*?/
@content[pattern]
- 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 clauses_churn_delete
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def clauses_churn_delete
@clauses_deleted.each do | mixin |
pattern = /(\[\{\{#{mixin}\}\}\s*?)(.*?\n*?)(\])/m
sub_pattern = /\[\{\{(\S+?)\}\}\s*?/
@content[pattern]
- 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 chew_on_the_block
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def chew_on_the_block
# @substitutions hash example
# {"ll."OR "l2."=>[:type8, "Article ", "(", "1", ")", :no_reset || nil, :no_indent || nil, :preval || :pre || nil],}
@cross_references = {}
arrayed_block = []
- 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 build_the_block_for_jason
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def build_the_block_for_jason( arrayed_block )
require 'securerandom'
annotations_hash = {}
provisions_hash = arrayed_block.inject({}) do |block, arrayed_line|
(sub_it, reference, selector, arrayed_line) = block_builder arrayed_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 log_the_key
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def log_the_key( block, sub_it, reference, selector, arrayed_line, arrayed_block )
Method build_an_annotation
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def build_an_annotation( start, stop, cite, parent, substitution )
Method filter_yaml
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def filter_yaml pattern
# @headers will be a hash, stuff is an array, returns a filtered hash
stuff = pattern.is_a?(Regexp) ? scan_doc(pattern) : pattern
if stuff
stuff_in_yaml = stuff.inject({}) do |hash, elem|
- 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 build_new_yaml_frontmatter
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def build_new_yaml_frontmatter
@content = "\n---\n\n" + @content
replacers = {0=>"Mixins", 1=>"Optional Clauses", 2=>"Structured Headers", 3=>"Properties", 4=>"Document Meta-Data"}
stringy = @yaml_data_as_array.inject("") do |string, section|
unless section.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 text_mixins
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def text_mixins
@headers.each do | mixin, replacer |
unless mixin =~ /level-\d/ or mixin =~ /no-reset/ or mixin =~ /no-indent/ or mixin =~ /level-style/
replacer = replacer.to_s
mixin_pattern = /(\{\{#{mixin}\}\})/
- 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[:type6, value.delete("(" + $1 + ")"), "(", $1, ")"]
Avoid too many return
statements within this method. Open
return[:type9, value.delete("(" + $1 + ")"), "(", $1, ")"]