raubarede/Ruiby

View on GitHub

Showing 263 of 263 total issues

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

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

def extract_doc_dsl() 
    glob=File.dirname(__FILE__)+"/../lib/ruiby_gtk/**/*.rb"
  hdoc={}
  Dir[glob].each do |src| next if src =~ /dsl.rb/
    content=File.read(src)
Severity: Minor
Found in samples/make_doc.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

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

  def secure_main()
    if defined?(EM)
        puts "Ruiby mainloop: EM is detected, mainloop while be mixed EM/Gtk"
        EM::run do
          give_tick = proc do
Severity: Minor
Found in lib/Ruiby.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

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

  def _set_accepter(layout,*types)
    if types.size==1
      layout.define_singleton_method(:accept?) do |type|  
         raise("No command   #{type} accepted here, accept=#{types}/") unless types.first==type 
      end
Severity: Minor
Found in lib/ruiby_gtk/dsl/layouts.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

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

    @cv=canvas(self.default_width,self.default_height) {
      on_canvas_draw { |w,ctx|  expose(w,ctx) }
      on_canvas_button_press {|w,e|  [e.x,e.y]  }
      on_canvas_button_motion {|w,e,o| n=[e.x,e.y] ;$app.move_carto(n[0]-o[0],n[1]-o[1]) if o ;n }
      on_canvas_button_release {|w,e,o| n=[e.x,e.y] ;$app.move_carto(n[0]-o[0],n[1]-o[1]) }
Severity: Major
Found in samples/tilesviewer.rb and 1 other location - About 2 hrs to fix
samples/aerial_viewer.rb on lines 152..156

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

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

    @cv=canvas(self.default_width,self.default_height) {
      on_canvas_draw { |w,ctx|  expose(w,ctx) }
      on_canvas_button_press {|w,e|  [e.x,e.y]  }
      on_canvas_button_motion {|w,e,o| n=[e.x,e.y] ;$app.move_carto(n[0]-o[0],n[1]-o[1]) if o ;n }
      on_canvas_button_release {|w,e,o| n=[e.x,e.y] ;$app.move_carto(n[0]-o[0],n[1]-o[1]) }
Severity: Major
Found in samples/aerial_viewer.rb and 1 other location - About 2 hrs to fix
samples/tilesviewer.rb on lines 175..179

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

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

Method dialog_minmax has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def dialog_minmax(wbutton,h,value)
    f1=DynVar.new(h[:param1])
    f2=DynVar.new(h[:param2])
    ok=dialog_async("Saisie Seuils #{h['name']}", response: proc {
      if f1.value<f2.value
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 component has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def component()
    stack do
      a=slot(Image.new( :stock => Gtk::Stock::OPEN, :size => :button))
      sloti(htoolbar do
        toolbar_button("open","ouvrir fichier") {
Severity: Minor
Found in samples/ex.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 formula has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def formula(opoids,poids)
         #--#
     opoids>30 ?  (opoids<82 ? (poids*1.0003) : poids*0.99 ) : ((opoids<10 && opoids>1) ? (100-poids/2) : (poids*0.93))
         #--#
    end
Severity: Minor
Found in samples/gol2.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 dialog_chooser has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def dialog_chooser(title, action, button)
      if Ruiby.gtk_version(3)
        dialog = Gtk::FileChooserDialog.new(
            :title => title, 
            :parent => self, 
Severity: Minor
Found in lib/ruiby_gtk/ruiby_default_dialog3.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 dialog_chooser has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def dialog_chooser(title, action, button)
      if Ruiby.gtk_version(3)
        dialog = Gtk::FileChooserDialog.new(
            :title => title, 
            :parent => self, 
Severity: Minor
Found in lib/ruiby_gtk/ruiby_default_dialog.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 initialize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize(window,title="title?",config,x0,y0)
  $statusIcon=self
  @popup_tray=Menu.new
  @checkMenu={}
  file= (config[:icon] && File.exist?(config[:icon])) ? config[:icon] : nil
Severity: Minor
Found in lib/ruiby_gtk/systray.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_list_grid has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def test_list_grid()
      flow {
        stack {
          frame("CB on List") {
            stacki{
Severity: Minor
Found in samples/test.rb - About 1 hr to fix

    Method test_canvas has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def test_canvas()
         flow do
            stack do
              button("Color") {
                @color=ask_color()
    Severity: Minor
    Found in samples/test.rb - About 1 hr to fix

      Method threader has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def threader(per)
          return unless $__mainwindow__==self
          @queue=Queue.new
          $__queue__=@queue
          ici=self
      Severity: Minor
      Found in lib/ruiby_gtk/ruiby_threader.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 push_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def push_data(h)
          h.each_with_index {|(k,v),i| 
            next unless Hash === v
            begin
              @lcurve[k]=[[100]*150,[100]*150] unless @lcurve[k] && @lcurve[k].size==2
      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 component has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def component()
            stack do
                if ed=source_editor()
                  @edit=slot(ed).editor
                  @edit.buffer.text=File.exists?(@filename) ? File.read(@filename) : @filename
      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 run_window has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def run_window()
          Ruiby.app width: $W, height: $H, title: "Curve" do
          fn=Ruiby::MEDIA+"/famfamfam/chart_curve.png"
          set_icon(fn) if File.exists?(fn)
          set_resizable(true)
      Severity: Minor
      Found in samples/pipeplot.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 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def component()
            stack do
              flow {
                  stacki { space;_button_list;space } if @options["button-orrient"] =~ /^l/i
                  @grid=grid(@captions,100,150)
      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 do_special_actions has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def do_special_actions()
          10.times { |i| log("#{i} "+ ("*"*(i+1))) }
          dialog("Dialog tests") do
            stack do
              labeli "  alert, prompt, file chosser and log  "
      Severity: Minor
      Found in samples/test.rb - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language