zold-io/wts.zold.io

View on GitHub

Showing 62 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

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

      function wts_rerate(rate, price, fee) {
        'use strict';
        var txt = $('#zld').val();
        var zld = parseFloat(txt);
        if (zld === NaN) {
      Severity: Major
      Found in assets/js/zld_to_upwork.js and 1 other location - About 4 hrs to fix
      assets/js/zld_to_paypal.js on lines 25..39

      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 133.

      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

      function wts_rerate(rate, price, fee) {
        'use strict';
        var txt = $('#zld').val();
        var zld = parseFloat(txt);
        if (zld === NaN) {
      Severity: Major
      Found in assets/js/zld_to_paypal.js and 1 other location - About 4 hrs to fix
      assets/js/zld_to_upwork.js on lines 25..39

      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 133.

      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 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

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

              unless settings.payouts.allowed?(user.login, amount, limits) || vip?
                consumed = settings.payouts.consumed(user.login)
                settings.telepost.spam(
                  "⚠️ The user #{title_md} from #{anon_ip} with #{amount} payment to UpWork just attempted to go",
                  "over their account limits: \"#{consumed}\", while allowed thresholds are \"#{limits}\";",
            Severity: Major
            Found in front/front_upwork.rb and 1 other location - About 1 hr to fix
            front/front_paypal.rb on lines 76..85

            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 67.

            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

              unless settings.payouts.allowed?(user.login, amount, limits) || vip?
                consumed = settings.payouts.consumed(user.login)
                settings.telepost.spam(
                  "⚠️ The user #{title_md} from #{anon_ip} with #{amount} payment to PayPal just attempted to go",
                  "over their account limits: \"#{consumed}\", while allowed thresholds are \"#{limits}\";",
            Severity: Major
            Found in front/front_paypal.rb and 1 other location - About 1 hr to fix
            front/front_upwork.rb on lines 76..85

            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 67.

            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 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

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

                    limits = settings.toggles.get('system-limits', '512/2048/8196')
                    unless settings.payouts.safe?(amount, limits) || vip?
                      consumed = settings.payouts.system_consumed
                      settings.telepost.spam(
                        "⚠️ The user #{title_md} from #{anon_ip} with #{amount} payment to UpWork just attempted to go",
                  Severity: Major
                  Found in front/front_upwork.rb and 1 other location - About 1 hr to fix
                  front/front_paypal.rb on lines 87..96

                  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 63.

                  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

                    limits = settings.toggles.get('system-limits', '512/2048/8196')
                    unless settings.payouts.safe?(amount, limits) || vip?
                      consumed = settings.payouts.system_consumed
                      settings.telepost.spam(
                        "⚠️ The user #{title_md} from #{anon_ip} with #{amount} payment to PayPal just attempted to go",
                  Severity: Major
                  Found in front/front_paypal.rb and 1 other location - About 1 hr to fix
                  front/front_upwork.rb on lines 87..96

                  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 63.

                  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

                  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
                      Severity
                      Category
                      Status
                      Source
                      Language