raubarede/Ruiby

View on GitHub
samples/gadget_trading.rb

Summary

Maintainability
F
4 days
Test Coverage

File gadget_trading.rb has 465 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'json'
require 'httpclient'
require 'yahoo-finance'
require 'Ruiby'                       unless Dir.exists?("../lib/ruiby_dsl")
require_relative '../lib/Ruiby.rb' if Dir.exists?("../lib/ruiby_dsl")
Severity: Minor
Found in samples/gadget_trading.rb - About 7 hrs to fix

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

    def get_update(app)
      return if Thread.list.size>2
      Thread.new {
        now=Time.now
        if  $first || $fr_ouverture.member?(Time.now.hour)
    Severity: Minor
    Found in samples/gadget_trading.rb - About 4 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 read has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def read(t0,t1,lcotes)
          date0,date1=t0.gmtime.strftime("%Y_%m"),t1.gmtime.strftime("%Y_%m")
          t0gmt,t1gmt=t0.gmtime.to_i,t1.gmtime.to_i
          lvalues=(0..lcotes.size-1).map {[]}
          (date0..date1).each do |date| 
    Severity: Minor
    Found in samples/gadget_trading.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 expose_trading has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

      def expose_trading(cv,ctx)
        return if $hcotes.size<1
        top=Time.now
        @sx,@sy=size()
        @wcurve=@sx/@nb_col
    Severity: Minor
    Found in samples/gadget_trading.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 expose_trading has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def expose_trading(cv,ctx)
        return if $hcotes.size<1
        top=Time.now
        @sx,@sy=size()
        @wcurve=@sx/@nb_col
    Severity: Major
    Found in samples/gadget_trading.rb - About 2 hrs to fix

      Method show has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def show(app)
            app.instance_eval do
              #======================== dialog choix cotes et periode
              profondeur=DynVar.new(1)
              ok=dialog("Cotes") do
      Severity: Major
      Found in samples/gadget_trading.rb - About 2 hrs to fix

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

            def show(app)
              app.instance_eval do
                #======================== dialog choix cotes et periode
                profondeur=DynVar.new(1)
                ok=dialog("Cotes") do
        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 draw_curve1 has 36 lines of code (exceeds 25 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

          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 dialog_minmax has 28 lines of code (exceeds 25 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

            Method get_data_yahoo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def get_data_yahoo(lcotes)
              fields=[
                :name,
                :last_trade_price,:last_trade_time,
                :volume,:previous_close,
            Severity: Minor
            Found in samples/gadget_trading.rb - About 1 hr 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 calc_alarme has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def calc_alarme(cote,values)
                 return [false,false] unless values["last"]
                 value=values["last"].to_f
                 p1=cote[:param1]
                 p2=cote[:param2]
                Severity: Minor
                Found in samples/gadget_trading.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