raubarede/Ruiby

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

Summary

Maintainability
D
1 day
Test Coverage

Method plot has 151 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def plot(width,height,curves,config={})
     plot=canvas(width,height) do
       on_canvas_draw { |w,ctx| w.expose(w,ctx) }
       on_canvas_button_press { |w,event| w.track(event)}
     end
Severity: Major
Found in lib/ruiby_gtk/dsl/plot.rb - About 6 hrs to fix

    Method track has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

         def plot.track(event)
          return unless @config[:tracker]
          x=nil
          lt=@curves.each_with_object([]) {|(name,d),a|
            next unless d[:type]==:curve
    Severity: Minor
    Found in lib/ruiby_gtk/dsl/plot.rb - About 3 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 expose has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

         def plot.expose(w,ctx) 
            return unless @curves
            w.draw_rectangle(0,0,@config[:w],@config[:h],0,nil,@config[:bg],0) if @config[:bg]
            if @config[:grid] 
              dx=dy=(@config[:grid]||"40").to_i
    Severity: Minor
    Found in lib/ruiby_gtk/dsl/plot.rb - About 3 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 add_curve has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

         def plot.add_curve(name,config) 
            c=config.dup
            c[:type] = :curve
            c[:data] ||= [[0,0],[100,100]]
            c[:maxlendata] ||= c[:data].size
    Severity: Minor
    Found in lib/ruiby_gtk/dsl/plot.rb - About 45 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