raubarede/Ruiby

View on GitHub
samples/draw.rb

Summary

Maintainability
F
4 days
Test Coverage

File draw.rb has 834 lines of code (exceeds 250 allowed). Consider refactoring.
Open

puts "Not terminted !!!!!"

require_relative '../lib/ruiby'

############################### Complete ruiby dsl for vector widget
Severity: Major
Found in samples/draw.rb - About 2 days to fix

    Class VCanvas_editable has 43 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class VCanvas_editable < VCanvas
        def initialize(win,w,h,options)
          super
          @current=nil
          @select={}
    Severity: Minor
    Found in samples/draw.rb - About 5 hrs to fix

      Method component has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def component()          
          stack do
            ################## Menu
            menu_bar do
              menu("File") {
      Severity: Major
      Found in samples/draw.rb - About 3 hrs to fix

        Class VElem has 26 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class VElem
            def initialize() @lpoints=[];@style={} end
            def bbox()
              @lpoints.inject(Bbox.new){ |bb,p| bb << [p[0],p[1]] }
            end
        Severity: Minor
        Found in samples/draw.rb - About 3 hrs to fix

          Method sel_align has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def sel_align(direction,sens)
                return  unless has_selection?()
                lv=@select[:list]
                bx0,by0,bx1,by1=Group.new(lv).bbox.values
                lv.each { |v| 
          Severity: Minor
          Found in samples/draw.rb - About 2 hrs 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

          Consider simplifying this complex logical expression.
          Open

                if @select.size>0 && @select[:list] && @select[:list].size>0
                  @select[:list].each { |v| v.set_style(options) }
                else
                  @cstyle={
                    :stroke_width=>options[:width] || 1,
          Severity: Critical
          Found in samples/draw.rb - About 1 hr to fix

            Method component has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              def component()          
                stack do
                  ################## Menu
                  menu_bar do
                    menu("File") {
            Severity: Minor
            Found in samples/draw.rb - About 1 hr 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 select_mouse_up has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def select_mouse_up(e)   
                  if @lasso
                    @lasso.order
                    l=find_into_bbox(*@lasso.lpoints.flatten)
                    l=find_cover_bbox(*@lasso.lpoints.flatten) if l.size==0
            Severity: Minor
            Found in samples/draw.rb - About 1 hr 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 pt_in_bbox? has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def pt_in_bbox?(x,y, x0,y0,x1,y1)
            Severity: Minor
            Found in samples/draw.rb - About 45 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 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 << has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def <<(a,b=nil,c=nil,d=nil)
                        if b==nil
                          Bbox === a ? add_bbox(a) : Array===a ? add_point(*a) : raise("error param bbox << ...")
                        elsif c==nil
                          add_point(a,b)
                  Severity: Minor
                  Found in samples/draw.rb - About 35 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 frename has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def frename() 
                      return unless @filename
                      fn=ask_file_to_write(".","*.svg")
                      if fn && File.exists?(@filename)
                        @filename,fn=fn,@filename
                  Severity: Minor
                  Found in samples/draw.rb - About 25 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

                      def prt(*txt) puts "%-80s | %s" % [txt.map { |o| String===o ? o : o.inspect}.join(", ")[0..79],caller[0].to_s.split(/\//)[-1]] end
                  Severity: Minor
                  Found in samples/draw.rb and 1 other location - About 25 mins to fix
                  samples/draw.rb on lines 86..86

                  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 29.

                  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

                      def prt2(*txt) puts "%-80s | %s" % [txt.map { |o| String===o ? o : o.inspect}.join(", ")[0..79],caller[1].to_s.split(/\//)[-1]] end
                  Severity: Minor
                  Found in samples/draw.rb and 1 other location - About 25 mins to fix
                  samples/draw.rb on lines 85..85

                  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 29.

                  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

                  There are no issues that match your filters.

                  Category
                  Status