raubarede/Ruiby

View on GitHub

Showing 263 of 263 total issues

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

      button("Goto...") { 
        prompt("Longitude ?",@lon0.to_s) { |lon|  
          prompt("Latitude  ?",@lat0.to_s) { |lat| 
            if ask("#{lon.to_f} ; #{lat.to_f}\n Validation ?")
              @lonRef,@latRef=lon.to_f,lat.to_f
Severity: Minor
Found in samples/tilesviewer.rb and 1 other location - About 1 hr to fix
samples/aerial_viewer.rb on lines 164..173

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

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 script has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def script(caption="Parameters",nb_column=2,hctx=nil) 
    $script_pid=nil
    @ctx=make_StockDynObject("ctx",hctx) if hctx
    stack do
      stacki do
Severity: Minor
Found in lib/ruiby_gtk/dsl/script.rb - About 55 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 apply_options has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def apply_options(w,options)
      w.set_size_request(*options[:size])                                 if options[:size] 
      w.set_border_width(options[:margins])                               if options[:margins]  
      w.width_request=(options[:width].to_i)                              if options[:width]
      w.height_request=(options[:height].to_i)                            if options[:height]
Severity: Minor
Found in lib/ruiby_gtk/ruiby_dsl3.rb - About 55 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 sdata has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def sdata(prefix,str0)
  str=if $short
    str0&&(str0.length>800 ?  str0.slice(0..800) + " ..." : str0)
  else
    str0||""
Severity: Minor
Found in samples/spygui.rb - About 55 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 make_example has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def make_example(hdoc,filename)
  count= $hexample.size
  src=File.dirname(__FILE__)+"/"+filename
  ifn="media/snapshot_#{filename}.png"
  system('ruby',src,"take-a-snapshot") if ARGV.size==0 || (! File.exists?(ifn))
Severity: Minor
Found in samples/make_doc.rb - About 55 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 video has a Cognitive Complexity of 9 (exceeds 5 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 55 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 execute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def execute(err=true,text=nil)
    @content= text ? text : @edit.buffer.text
    clear_append_to(@demo) {
      frame { stack {
      eval(@content,binding() ,"<script>",1) 
Severity: Minor
Found in samples/sketchi.rb - About 55 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 bench has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def bench(code)
     begin
        eval( "class Test ; def self.test()  #{([code]*100).join(" ; ")} ;  end ; end ",$global)
        __i=0
        istep=100 # number of Test.test() in the while()
Severity: Minor
Found in samples/benchi.rb - About 55 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 _set_gradient has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def cv._set_gradient(cv,cr,acolor,lxy)
      type,sens,*data=acolor
      return unless type && sens && data && data.size>=2
      cr.set_source_rgba(*Ruiby_dsl.cv_color_html("#FFF"))
      if type =~ /^g/
Severity: Minor
Found in lib/ruiby_gtk/dsl/canvas.rb - About 55 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 _process_terminal_key has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def _process_terminal_key(w,ev,termBuffer)
    char=(ev.keyval.chr rescue nil)
    #p ["%08X" % ev.keyval , char]
    up=65362
    down=65364
Severity: Minor
Found in lib/ruiby_gtk/ruiby_terminal.rb - About 55 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 button has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def button(text,option={},&blk)
    if text && text[0,1]=="#"
      b=Button.new(:label => nil, :mnemonic => nil, :stock_id => nil);
      text,tooltip=text[1..-1].split("//")
      b.set_image( get_image(text) )
Severity: Minor
Found in lib/ruiby_gtk/dsl/label_button_image.rb - About 55 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 tree_grid has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def tree_grid(names,w=0,h=0,options={})
    scrolled_win = Gtk::ScrolledWindow.new
    scrolled_win.set_policy(:automatic,:automatic)
    scrolled_win.set_width_request(w) if w>0
    scrolled_win.set_height_request(h)  if h>0
Severity: Minor
Found in lib/ruiby_gtk/dsl/list_grid.rb - About 55 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 _check_append has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def _check_append(name,w,wref)
    raise("#{name}(w,r) : Widget ref not created!") unless wref
    raise("#{name}(w,r) : new Widget not created!") unless w
    parent=wref.parent
    raise("#{name}(w,r): r=#{parent.inspect} is not a XBox or Frame !") unless !parent || parent.kind_of?(Container)
Severity: Minor
Found in lib/ruiby_gtk/dsl/commands.rb - About 55 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 prompt has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def prompt(txt,value="") 
     dialog = Dialog.new(
      title: "Message",
      parent: self,
      flags: [Dialog::DESTROY_WITH_PARENT],
Severity: Minor
Found in lib/ruiby_gtk/ruiby_default_dialog3.rb - About 55 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

        stacki {haccordion {
          aitem("entry 1") {
              alabel("xeee1") { alert("x1") }
              alabel("xeee2") { alert("x2") }
              alabel("xeee3") { alert("x3") }
Severity: Minor
Found in samples/accordion.rb and 1 other location - About 55 mins to fix
samples/accordion.rb on lines 18..32

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

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 get_image_from has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def get_image_from(name,size=:button)
    if name.index('.') 
      return Image.new(file: name) if File.exists?(name)
      return _sub_image(name) if name.index("[")
      alert("unknown icone #{name}")
Severity: Minor
Found in lib/ruiby_gtk/dsl/pixmap.rb - About 55 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

      accordion {
        aitem("entry 1") {
            alabel("xeee1") { alert("x1") }
            alabel("xeee2") { alert("x2") }
            alabel("xeee3") { alert("x3") }
Severity: Minor
Found in samples/accordion.rb and 1 other location - About 55 mins to fix
samples/accordion.rb on lines 37..51

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

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 draw_aig has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def draw_aig(cv,x,y,r,pos,width,color)
Severity: Major
Found in samples/gadget_clock.rb - About 50 mins to fix

    Method draw_curve1 has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def draw_curve1(curve,i,x0,y0,unit, type, vy)
    Severity: Major
    Found in samples/gadget_trading.rb - About 50 mins to fix

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

          def initialize(title,width=350,height=600,captions=[["oups"]],data=[["no data"]],options={},&bloc)
      Severity: Major
      Found in lib/ruiby_gtk/editor.rb - About 50 mins to fix
        Severity
        Category
        Status
        Source
        Language