Showing 263 of 263 total issues
Method delete
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def delete(w)
if $__mainthread__ != Thread.current
gui_invoke { delete(w) }
return
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 bbox
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def cv.bbox(lxy)
xmin,ymin=lxy[0..1]
xmax,ymax=lxy[0..1]
lxy.each_slice(2) {|x,y|
xmin=x if x<xmin ;ymin=y if y<ymin
- 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
toolbar_button("Save","Save buffer to file...") {
@file=ask_file_to_write(".","*.rb") unless File.exists?(@file)
@title.text=@file
content=@edit.buffer.text
File.open(@file,"wb") { |f| f.write(content) } if @file && content && content.size>2
- 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 38.
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
button_icon_text "Save","Save buffer to file..." do
@file=ask_file_to_write(".","*.rb") unless File.exists?(@file)
@title.text=@file
content=@edit.buffer.text
File.open(@file,"wb") { |f| f.write(content) } if @file && content && content.size>2
- 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 38.
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
Consider simplifying this complex logical expression. Open
if filename && px && py && bidon && dim && File.exist?(filename)
dim=dim.to_i
@cach_pix[filename]=Gdk::Pixbuf.new(:file =>filename) unless @cach_pix[filename]
x0= dim*px.to_i
y0= dim*py.to_i
Method draw_border
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def draw_border(ctx,x,y,pdx,pdy)
Method draw_bg
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def draw_bg(cr,w,h,c1,c2)
Method cscale
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def cscale(l,x,y,cx,cy=nil) trans(scale(trans(l,-x,-y),cx,cy),x,y) end
Method draw_border
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def draw_border(ctx,x,y,pdx,pdy)
Method find_into_bbox
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def find_into_bbox(x0,y0,x1,y1,nolayer=1)
Method find_cover_bbox
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def find_cover_bbox(x0,y0,x1,y1,nolayer=1)
Method axes
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def axes(x0,maxx,maxy,pasx,pasy)
Method text
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def text(ctx,fs,x,y,text)
Method _dyn_toggle_button
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _dyn_toggle_button(text1,text2,var,option={},&blk)
Method toggle_button
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def toggle_button(text1,text2=nil,value=false,option={},&blk)
Method add
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add(noc,y0,y1,label,autoscale)
Method draw_tree
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def draw_tree(cr,x1, y1, angle, depth)
Method field
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def field(tlabel,lwidth,value,option={},&blk)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(window,title="title?",config,x0,y0)
Similar blocks of code found in 2 locations. Consider refactoring. Open
def fload(file,content)
if File.exists?(file) && content==nil
content=File.read(file)
end
return unless content!=nil
- 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 36.
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