raubarede/Ruiby

View on GitHub
lib/ruiby_gtk/dsl/pixmap.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method get_pixbuf has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def get_pixbuf(name)
    @cach_pix={} unless defined?(@cach_pix)
    if @cach_pix.size>100
      puts "purge cached pixbuf (>100)"
      @cach_pix={}
Severity: Minor
Found in lib/ruiby_gtk/dsl/pixmap.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 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

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

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

    Avoid too many return statements within this method.
    Open

          return nil
    Severity: Major
    Found in lib/ruiby_gtk/dsl/pixmap.rb - About 30 mins to fix

      Method get_stockicon_pixbuf has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def get_stockicon_pixbuf(name)
          begin
            icn="#{name.downcase.gsub('_','-')}"
            return Gtk::IconTheme.default().load_icon(icn,16,0)
          rescue Exception => ee
      Severity: Minor
      Found in lib/ruiby_gtk/dsl/pixmap.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

      There are no issues that match your filters.

      Category
      Status