zold-io/wts.zold.io

View on GitHub

Showing 47 of 62 total issues

File front_btc.rb has 562 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'glogin'
require 'obk'
require 'retriable_proxy'
require 'sibit'
require 'sibit/bestof'
Severity: Major
Found in front/front_btc.rb - About 1 day to fix

    File wts.rb has 498 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    $stdout.sync = true
    
    require 'backtrace'
    require 'concurrent'
    require 'get_process_mem'
    Severity: Minor
    Found in wts.rb - About 7 hrs to fix

      Method pay_hosting_bonuses has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def pay_hosting_bonuses(boss, jid, log)
        bonus = Zold::Amount.new(zld: 1.0)
        ops(boss, log: log).remove
        ops(boss, log: log).pull
        latest = boss.wallet(&:txns).reverse.find { |t| t.amount.negative? }
      Severity: Major
      Found in front/front_bonuses.rb - About 2 hrs to fix

        Method svg has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

          def svg(keys, div, digits, title: '')
            sets = {}
            min = Time.now
            max = Time.now + (STEPS * 24 * 60 * 60)
            keys.each do |k|
        Severity: Minor
        Found in objects/graph.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 update has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

          def update(max: 400)
            if @remotes.all.empty?
              @log.debug('The list of remote nodes is empty, can\'t update payables')
              return
            end
        Severity: Minor
        Found in objects/payables.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 pull has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def pull(id = @item.id)
            if @user.fake?
              @log.info("It is a fake user with wallet ID #{id}, won't PULL from the network")
              remove
              rsa = OpenSSL::PKey::RSA.new(2048)
        Severity: Minor
        Found in objects/ops.rb - About 1 hr to fix

          Function wts_recalc has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function wts_recalc() {
            'use strict';
            wts_info('Loading rates...')
            $.ajax({
              dataType: 'json',
          Severity: Minor
          Found in assets/js/quick.js - About 1 hr to fix

            Method update has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def update(max: 400)
                if @remotes.all.empty?
                  @log.debug('The list of remote nodes is empty, can\'t update payables')
                  return
                end
            Severity: Minor
            Found in objects/payables.rb - About 1 hr to fix

              Method markdown has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def markdown
                  price = @sibit.price
                  rate = WTS::Rate.new(@toggles).to_f
                  coverage = @ticks.latest('Coverage') / 100_000_000
                  deficit = @ticks.latest('Deficit') / 100_000_000
              Severity: Minor
              Found in front/daily_summary.rb - About 1 hr to fix

                Method svg has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def svg(keys, div, digits, title: '')
                    sets = {}
                    min = Time.now
                    max = Time.now + (STEPS * 24 * 60 * 60)
                    keys.each do |k|
                Severity: Minor
                Found in objects/graph.rb - About 1 hr to fix

                  Function wts_step4 has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function wts_step4(token) {
                    'use strict';
                    $.ajax({
                      dataType: 'text',
                      url: '/confirmed?noredirect=1',
                  Severity: Minor
                  Found in assets/js/quick.js - About 1 hr to fix

                    Method monitor has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def monitor(seen, max: 1)
                        raise "Wrong BTC address '#{seen}'" unless seen.length == 64
                        nxt = @sibit.next_of(seen)
                        return seen if nxt.nil?
                        return seen unless nxt.start_with?('00000000')
                    Severity: Minor
                    Found in objects/assets.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 start has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def start(id, seconds = 60, pause: 5)
                        @threads[id] = Thread.new do
                          sleep(pause) # to let the main script load all Ruby methods
                          loop do
                            sleep([[seconds - age(id), 0].max, 5 * 60].min)
                    Severity: Minor
                    Found in objects/daemons.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 pay has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def pay(keygap, bnf, amount, details)
                        raise WTS::UserError, 'E187: Payment amount can\'t be zero' if amount.zero?
                        raise WTS::UserError, 'E188: Payment amount can\'t be negative' if amount.negative?
                        raise "The user #{@user.login} is not registered yet" unless @item.exists?
                        raise "The account #{@user.login} is not confirmed yet" unless @user.confirmed?
                    Severity: Minor
                    Found in objects/ops.rb - About 1 hr to fix

                      Method ping has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def ping
                          q = [
                            'SELECT callback.*, match.id AS mid',
                            'FROM callback',
                            'JOIN match ON callback.id = match.callback'
                      Severity: Minor
                      Found in objects/callbacks.rb - About 1 hr to fix

                        Method pay has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def pay(keygap, bnf, amount, details)
                            raise WTS::UserError, 'E187: Payment amount can\'t be zero' if amount.zero?
                            raise WTS::UserError, 'E188: Payment amount can\'t be negative' if amount.negative?
                            raise "The user #{@user.login} is not registered yet" unless @item.exists?
                            raise "The account #{@user.login} is not confirmed yet" unless @user.confirmed?
                        Severity: Minor
                        Found in objects/ops.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 send_payouts_api has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def send_payouts_api(email, usd, details)
                            PayPal::SDK.configure(
                              mode: 'live',
                              client_id: @config[:id],
                              client_secret: @config[:secret],
                        Severity: Minor
                        Found in objects/paypal.rb - About 1 hr to fix

                          Function success has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              success: function(json) {
                                var rate = json.usd_rate;
                                var btc = parseFloat($('#btc').val());
                                if (btc > 999) {
                                  wts_error('That\'s too much');
                          Severity: Minor
                          Found in assets/js/quick.js - About 1 hr to fix

                            Function success has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                success: function(text) {
                                  if (text === 'yes') {
                                    wts_info('The keygap of ' + token + ' is already confirmed (existing account)');
                                    wts_step5(token);
                                  } else {
                            Severity: Minor
                            Found in assets/js/quick.js - About 1 hr to fix

                              Method pay_taxes has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def pay_taxes(keygap)
                                  raise "The user #{@user.login} is not registered yet" unless @item.exists?
                                  raise "The account #{@user.login} is not confirmed yet" unless @user.confirmed?
                                  if @user.fake?
                                    @log.info('It is a fake user, won\'t pay taxes')
                              Severity: Minor
                              Found in objects/ops.rb - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language