Showing 53 of 53 total issues
Method trim_blank
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def trim_blank
return true if (h==0)
h_test = @height
h_test = 3 if (h_test>=3)
view = get_cell_view
Method move_units
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.move_units(units)
isrc = []
idest = []
len = units.length
ltop = -1.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 spread_context
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def spread_context(units, del, active)
if (del>0 && active != nil)
# forward
mark = -del-1
skips = 0
Method move_without_extras
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.move_without_extras(src, dest)
return nil if (src.length!=dest.length)
return [] if (src.length<=1)
len = src.length
- 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 render
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def render(rows)
return if (rows.width==0||rows.height==0)
render = self
render.begin_table()
change_row = -1
Method mark_spaces
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.mark_spaces(sl, sr)
return sl if (sl==sr)
return sl if (sl.nil? || sr.nil?)
slc = sl.gsub(" ","")
src = sr.gsub(" ","")
- 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 get_separator
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_separator(t, t2, root)
sep = root
w = t.width
h = t.height
view = t.get_cell_view
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (active[i]==0||active[i]==3)
if (mark-i<=del+skips)
active[i] = 2
elsif (mark-i==del+1+skips)
active[i] = 3
- 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 49.
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 (active[i]==0||active[i]==3)
if (i-mark<=del+skips)
active[i] = 2
elsif (i-mark==del+1+skips)
active[i] = 3
- 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 49.
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 mark_spaces
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.mark_spaces(sl, sr)
return sl if (sl==sr)
return sl if (sl.nil? || sr.nil?)
slc = sl.gsub(" ","")
src = sr.gsub(" ","")
Method move_units
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.move_units(units)
isrc = []
idest = []
len = units.length
ltop = -1.0
Method examine_cell
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.examine_cell(x, y, value, vcol, vrow, vcorner, cell)
Avoid deeply nested control flow statements. Open
offset = cell.conflicted ? 1 : 0
Method has_same_columns_2
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def has_same_columns_2(a, b)
if (a.width!=b.width)
return false
end
if (a.height==0 || b.height==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 to_order
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def to_order
if @order_cache
if @reference
if !@order_cache_has_reference
@order_cache = 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
Avoid deeply nested control flow statements. Open
if (tokens.length>=2)
pretty_tokens[0] = mark_spaces(tokens[0],tokens[1])
pretty_tokens[1] = mark_spaces(tokens[1],tokens[0])
end
Avoid deeply nested control flow statements. Open
if (part!=full)
if (cell.value.index(full))
div = full
cat = "conflict"
cell.conflicted = true
Avoid deeply nested control flow statements. Open
cell.pvalue = tokens[0] if (cell.conflicted)
Avoid deeply nested control flow statements. Open
if (tokens.length>=3)
ref = pretty_tokens[0]
pretty_tokens[0] = mark_spaces(ref,tokens[2])
pretty_tokens[2] = mark_spaces(tokens[2],ref)
end
Avoid deeply nested control flow statements. Open
if (tokens.length == 0)
pretty_tokens = ['','']
end