zold-io/wts.zold.io

View on GitHub

Showing 62 of 62 total issues

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

            Avoid too many return statements within this method.
            Open

              return true if settings.config['kyc'].include?(login)
            Severity: Major
            Found in wts.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                return true if settings.config['kyc'].include?(login)
              Severity: Major
              Found in wts.rb - About 30 mins to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                      "Zerocracy development, TID #{user.item.id}:#{txn.id}"
                    )
                    settings.payouts.add(
                Severity: Minor
                Found in front/front_paypal.rb and 1 other location - About 30 mins to fix
                front/front_upwork.rb on lines 125..127

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 32.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                      "Zerocracy development, TID #{user.item.id}:#{txn.id}"
                    )
                    settings.payouts.add(
                Severity: Minor
                Found in front/front_upwork.rb and 1 other location - About 30 mins to fix
                front/front_paypal.rb on lines 126..128

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 32.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                def features(*list)
                  return if @locals[:guser] && vip?
                  list.each do |f|
                    next unless settings.toggles.get("stop:#{f}", 'no') == 'yes'
                    raise WTS::UserError, "E177: This feature \"#{f}\" is temporarily disabled, sorry"
                Severity: Minor
                Found in wts.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

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

                def country(ip = request.ip)
                  settings.zache.get("ip_to_country:#{ip}") do
                    geo = Geoplugin.new(request.ip, ssl: true, key: settings.config['geoplugin_token'])
                    geo.nil? ? '??' : geo.countrycode
                  rescue StandardError
                Severity: Minor
                Found in wts.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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                
                  def delete_failed
                    q = [
                      'SELECT callback.* FROM callback',
                      'JOIN match ON match.callback = callback.id',
                Severity: Minor
                Found in objects/callbacks.rb and 1 other location - About 25 mins to fix
                objects/callbacks.rb on lines 145..155

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 30.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Method acquire has a Cognitive Complexity of 6 (exceeds 5 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 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

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

                def parsed_amount
                  raise WTS::UserError, 'E110: Parameter "amount" is not provided' if params[:amount].nil?
                  param = params[:amount]
                  amount = if /^[0-9]+z$/.match?(param)
                    Zold::Amount.new(zents: param.to_i)
                Severity: Minor
                Found in front/front_pay.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

                Severity
                Category
                Status
                Source
                Language