raubarede/Ruiby

View on GitHub

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
Severity: Minor
Found in lib/ruiby_gtk/dsl/commands.rb - About 45 mins to fix

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 
Severity: Minor
Found in lib/ruiby_gtk/dsl/canvas.rb - About 45 mins to fix

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
Severity: Minor
Found in samples/canvas.rb and 1 other location - About 40 mins to fix
samples/sketchi.rb on lines 44..49

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

Further Reading

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
Severity: Minor
Found in samples/sketchi.rb and 1 other location - About 40 mins to fix
samples/canvas.rb on lines 65..70

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

Further Reading

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
Severity: Major
Found in lib/ruiby_gtk/dsl/pixmap.rb - About 40 mins to fix

    Method draw_border has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def draw_border(ctx,x,y,pdx,pdy)
    Severity: Minor
    Found in samples/aerial_viewer.rb - About 35 mins to fix

      Method draw_bg has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def draw_bg(cr,w,h,c1,c2)
      Severity: Minor
      Found in samples/fractal.rb - About 35 mins to fix

        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
        Severity: Minor
        Found in samples/canvas.rb - About 35 mins to fix

          Method draw_border has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def draw_border(ctx,x,y,pdx,pdy)
          Severity: Minor
          Found in samples/tilesviewer.rb - About 35 mins to fix

            Method find_into_bbox has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def find_into_bbox(x0,y0,x1,y1,nolayer=1)
            Severity: Minor
            Found in samples/draw.rb - About 35 mins to fix

              Method find_cover_bbox has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def find_cover_bbox(x0,y0,x1,y1,nolayer=1)
              Severity: Minor
              Found in samples/draw.rb - About 35 mins to fix

                Method axes has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def axes(x0,maxx,maxy,pasx,pasy)
                Severity: Minor
                Found in samples/canvas.rb - About 35 mins to fix

                  Method text has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    def text(ctx,fs,x,y,text)
                  Severity: Minor
                  Found in samples/freedom.rb - About 35 mins to fix

                    Method _dyn_toggle_button has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      def _dyn_toggle_button(text1,text2,var,option={},&blk)
                    Severity: Minor
                    Found in lib/ruiby_gtk/dsl/form_fields.rb - About 35 mins to fix

                      Method toggle_button has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        def toggle_button(text1,text2=nil,value=false,option={},&blk)
                      Severity: Minor
                      Found in lib/ruiby_gtk/dsl/form_fields.rb - About 35 mins to fix

                        Method add has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                def add(noc,y0,y1,label,autoscale)
                        Severity: Minor
                        Found in samples/pipeplot.rb - About 35 mins to fix

                          Method draw_tree has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          def draw_tree(cr,x1, y1, angle, depth)
                          Severity: Minor
                          Found in samples/fractal.rb - About 35 mins to fix

                            Method field has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                              def field(tlabel,lwidth,value,option={},&blk)
                            Severity: Minor
                            Found in lib/ruiby_gtk/dsl/form_fields.rb - About 35 mins to fix

                              Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                def initialize(window,title="title?",config,x0,y0)
                              Severity: Minor
                              Found in lib/ruiby_gtk/systray.rb - About 35 mins to fix

                                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 
                                Severity: Minor
                                Found in samples/canvas.rb and 1 other location - About 35 mins to fix
                                samples/sketchi.rb on lines 152..160

                                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

                                Further Reading

                                Severity
                                Category
                                Status
                                Source
                                Language