zold-io/wts.zold.io

View on GitHub

Showing 47 of 62 total issues

Method pay has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def pay(email, usd, details)
    require 'openssl'
    OpenSSL::SSL.const_set(:VERIFY_PEER, OpenSSL::SSL::VERIFY_NONE)
    gateway = ActiveMerchant::Billing::PaypalAdaptivePayment.new(
      mode: 'live',
Severity: Minor
Found in objects/paypal.rb - About 1 hr to fix

    Method job has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def job(u = user, exclusive: false)
      settings.jobs.gc
      jid = settings.jobs.start(u.login)
      log = WTS::TeeLog.new(user_log(u.login), WTS::DbLog.new(settings.pgsql, jid))
      job = WTS::SafeJob.new(
    Severity: Minor
    Found in front/front_jobs.rb - About 1 hr to fix

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

        def acquire(login = nil)
          row = if login.nil?
            @pgsql.exec(
              [
                'SELECT address FROM asset',
      Severity: Minor
      Found in objects/assets.rb - About 1 hr to fix

        Method allowed? has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def allowed?(login, amount, limits = '64/128/256')
            daily_limit, weekly_limit, monthly_limit = limits.split('/')
            daily_limit = Zold::Amount.new(zld: daily_limit.to_f)
            weekly_limit = Zold::Amount.new(zld: weekly_limit.to_f)
            monthly_limit = Zold::Amount.new(zld: monthly_limit.to_f)
        Severity: Minor
        Found in objects/payouts.rb - About 1 hr to fix

          Method sibit has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def sibit(log: settings.log)
            api = [Sibit::Fake.new]
            if ENV['RACK_ENV'] != 'test'
              http = Sibit::Http.new
              api = settings.toggles.get('sibit:api', 'blockchain').split(',').map do |a|
          Severity: Minor
          Found in front/front_btc.rb - About 1 hr to fix

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

              def match(tid, wallet, prefix, details)
                found = []
                @pgsql.exec('SELECT * FROM callback WHERE wallet = $1 AND prefix = $2', [wallet, prefix]).each do |r|
                  next unless Regexp.new(r['regexp']).match?(details)
                  id = @pgsql.exec(
            Severity: Minor
            Found in objects/callbacks.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 known? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def known?(login = @locals[:guser])
              return false unless login
              return true if %w[yegor256 davvd].include?(login)
              return true if ENV['RACK_ENV'] == 'test'
              return true if login == settings.config['rewards']['login']
            Severity: Minor
            Found in wts.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

            Avoid deeply nested control flow statements.
            Open

                unless friend.item.exists?
                  friend.create(settings.remotes)
                  ops(friend).push
                end
            Severity: Major
            Found in front/front_pay.rb - About 45 mins to fix

              Method add has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def add(login, wallet, prefix, regexp, uri, token = 'none', repeat: false, forever: false)
              Severity: Minor
              Found in objects/callbacks.rb - About 45 mins to fix

                Method pay_hosting_bonuses has a Cognitive Complexity of 8 (exceeds 5 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: Minor
                Found in front/front_bonuses.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

                Avoid deeply nested control flow statements.
                Open

                    raise WTS::UserError, "E115: Invalid GitHub user name: #{bnf.inspect}" unless login =~ /^[a-z0-9-]{3,32}$/
                Severity: Major
                Found in front/front_pay.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                      raise WTS::UserError, 'E116: You can\'t pay yourself' if login == user.login
                  Severity: Major
                  Found in front/front_pay.rb - About 45 mins to fix

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

                      def initialize(item, user, wallets, remotes, copies, log: Zold::Log::NULL, network: 'test')
                    Severity: Minor
                    Found in objects/ops.rb - About 35 mins to fix

                      Method push has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def push
                          if @user.fake?
                            @log.info('It is a fake user, won\'t PUSH to the network')
                            return
                          end
                      Severity: Minor
                      Found in objects/ops.rb - About 35 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 kyc? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def kyc?(login = @locals[:guser])
                        return false unless login
                        return true if ENV['RACK_ENV'] == 'test'
                        return true if login == settings.config['rewards']['login']
                        return true if login == settings.config['exchange']['login']
                      Severity: Minor
                      Found in wts.rb - About 35 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 flash has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def flash(uri, msg, error: false)
                        cookies[:flash_msg] = msg
                        cookies[:flash_color] = error ? 'firebrick' : 'seagreen'
                        redirect(uri, error ? 303 : 302) unless params[:noredirect]
                        msg
                      Severity: Minor
                      Found in wts.rb - About 35 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 pay has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def pay(address, satoshi)
                          batch = {}
                          unspent = 0
                          @pgsql.exec('SELECT * FROM asset WHERE value > 0 ORDER BY value').each do |r|
                            next if r['pvt'].nil?
                      Severity: Minor
                      Found in objects/assets.rb - About 35 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

                      Function wts_recalc has a Cognitive Complexity of 7 (exceeds 5 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 35 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

                      Avoid too many return statements within this method.
                      Open

                        return true if login == settings.config['exchange']['login']
                      Severity: Major
                      Found in wts.rb - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language