raubarede/Ruiby

View on GitHub

Showing 263 of 263 total issues

Method video has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def video(url=nil,w=300,h=200) 
    begin 
    require "gst"
    require "clutter-gtk"  # gem install clutter-gtk
    require "clutter-gst"  # gem install clutter-gstreamer
Severity: Minor
Found in lib/ruiby_gtk/ruiby_dsl3.rb - About 1 hr to fix

    Method source_editor has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def source_editor(args={},&blk) 
        #return(nil) # loading gtksourceview3 scratch application...
        begin
          require 'gtksourceview3'
        rescue Exception => e
    Severity: Minor
    Found in lib/ruiby_gtk/dsl/editors.rb - About 1 hr to fix

      Method _exe_posix has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def _exe_posix(cmd,to)
          Thread.new(cmd,to) do |cmd,to|
            begin
              PTY.spawn(cmd) do |read,write,pid|
                $ruiby_script_pid= pid
      Severity: Minor
      Found in lib/ruiby_gtk/dsl/script.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 _button_list has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def _button_list()
              @options.each do |name,action| 
                  next unless   action.respond_to?(:call)
                  button(name) {
                      next unless  @grid.index()
      Severity: Minor
      Found in lib/ruiby_gtk/editor.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 _dyn_toggle_button has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def _dyn_toggle_button(text1,text2,var,option={},&blk)
          text2 = "- "+text1 unless text2
          b=ToggleButton.new(label: text1);
          b.signal_connect("clicked") do |w,e| 
            w.label= w.active?() ? text2.to_s : text1.to_s 
      Severity: Minor
      Found in lib/ruiby_gtk/dsl/form_fields.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 draw_pie has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def cv.draw_pie(x0,y0,r,l_ratio_color_txt,with_legend=false)
            lcolor=%w{#F00 #A00 #AA0 #AF0 #AAF #AAA #FAF #AFA #33F #044}
            cv,ctx=@currentCanvasCtx
            start=3.0*Math::PI/2.0
            total=l_ratio_color_txt.inject(0.0) { |sum,(a)| sum+a }
      Severity: Minor
      Found in lib/ruiby_gtk/dsl/canvas.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 test_dialogues has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def test_dialogues()
          $gheader=%w{id first-name last-name age str}
          $gdata= (0..10000).to_a.map {|i| ("%d regis%d aubarede%d %d %s" % [i,i,i,i%99,("*"*(i%30))]).split(/\s+/) }
          a=PopupTable.new("title of dialog",400,200,
              $gheader,
      Severity: Minor
      Found in samples/dialogs.rb - About 1 hr to fix

        Method canvasOld has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def canvasOld(width,height,option={})
            puts "*** DEPRECATED: use canvas do end in place of canvasOld ***"
            autoslot()
            w=DrawingArea.new()
            w.width_request=width
        Severity: Minor
        Found in lib/ruiby_gtk/dsl/canvas.rb - About 1 hr to fix

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                if Ruiby.gtk_version(3)
                  dialog = Gtk::FileChooserDialog.new(
                      :title => title, 
                      :parent => self, 
                      :action => action, 
          Severity: Major
          Found in lib/ruiby_gtk/ruiby_default_dialog3.rb and 1 other location - About 1 hr to fix
          lib/ruiby_gtk/ruiby_default_dialog.rb on lines 116..132

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

          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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                if Ruiby.gtk_version(3)
                  dialog = Gtk::FileChooserDialog.new(
                      :title => title, 
                      :parent => self, 
                      :action => action, 
          Severity: Major
          Found in lib/ruiby_gtk/ruiby_default_dialog.rb and 1 other location - About 1 hr to fix
          lib/ruiby_gtk/ruiby_default_dialog3.rb on lines 170..186

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

          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 @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 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def component()
                stack do
                  htoolbar do
                    toolbar_button("open","ouvrir fichier") {
                      load(ask_file_to_read(".","*.rb"))
            Severity: Minor
            Found in samples/editor.rb - About 1 hr to fix

              Method test_dialog has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def test_dialog()
                stack do
                  stacki {
                    frame("Buttons in frame") {
                      flow { sloti(button("packed with sloti()") {alert("button packed with sloti()")}) 
              Severity: Minor
              Found in samples/test.rb - About 1 hr to fix

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

                  def get_update()
                    Thread.new {
                      begin
                        @lv=get_data
                        gui_invoke { @cv.redraw rescue p $!}
                Severity: Minor
                Found in samples/gadget.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 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 add_ope has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def add_ope(op) 
                      b=case op
                        when /\+|\-|x|#{DIV}/ then button(op) { push(@number.value) if @number.value.size>0 ; @tbc=true; push(op) }
                        when "."              then button(op) { @number.value=(@number.value||"")+"." if @number.value !~ /\./ }
                        when "="              then button(op) { calc(pop(),pop(),@number.value) if @stack.size >= 2 }
                Severity: Minor
                Found in samples/calculator.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 draw_curve1 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  def draw_curve1(curve,i,x0,y0,unit, type, vy)
                    w=@sx-4
                    h=@hcurve
                    @cv.draw_rectangle(x0,y0,@wcurve,h,1,$PLOT0,$PLOT1,2)
                    coul="##{%w{FF4 4F4 6060FF FF6060 44F 4FF}[i]}"
                Severity: Minor
                Found in samples/gadget_trading.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 expose has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  def expose(cv,ctx)
                    ssize= size()
                    @cv.set_size_request(ssize.first-2,ssize.last-2)
                    cx,cy=ssize.first/2,ssize.last/2
                    cy=cx if cy>cx
                Severity: Minor
                Found in samples/gadget_clock.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 source_editor has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  def source_editor(args={},&blk) 
                    #return(nil) # loading gtksourceview3 scratch application...
                    begin
                      require 'gtksourceview3'
                    rescue Exception => e
                Severity: Minor
                Found in lib/ruiby_gtk/dsl/editors.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 get_pixmap has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  def get_pixmap(name)
                    if name=~ /^(famfamfam|crystal|farmfresh)/
                      name=Dir.glob("#{Ruiby::MEDIA}/#{name.split(/\s+/).join("*")}*").first
                    end    
                    if name.index('.') 
                Severity: Minor
                Found in lib/ruiby_gtk/dsl/pixmap.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

                Severity
                Category
                Status
                Source
                Language