plugins/content/templates/user/js/ng/payment/balance-recharge.js

Summary

Maintainability
F
1 wk
Test Coverage

File balance-recharge.js has 606 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function () { 'use strict';

var __NS__ = 'payment.balance.recharge';
__ANGULAR_MODULES__.push( __NS__ );

Severity: Major
Found in plugins/content/templates/user/js/ng/payment/balance-recharge.js - About 1 day to fix

    Function payin has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            payin: function( options ) {
                var $this = this;
                $scope.block_wait     = true;
                $scope.is_submitted   = true;
                $scope.status         = false;
    Severity: Major
    Found in plugins/content/templates/user/js/ng/payment/balance-recharge.js - About 2 hrs to fix

      Function payout has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              payout: function( options ) {
                  var $this = this;
                  $scope.block_wait     = true;
                  $scope.is_submitted   = true;
                  $scope.status         = false;
      Severity: Minor
      Found in plugins/content/templates/user/js/ng/payment/balance-recharge.js - About 1 hr to fix

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

                cancel: function( options ) {
                    var $this = this;
                    $scope.block_wait     = true;
                    $scope.is_submitted   = true;
                    $scope.status         = false;
        Severity: Minor
        Found in plugins/content/templates/user/js/ng/payment/balance-recharge.js - About 1 hr to fix

          Function payout_provider_change has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              $scope.payout_provider_change = function( $event, provider_id, method_id ) {
                  $event.stopPropagation();
                  var action = $scope.action.payout;
                  if( action.provider_id == provider_id && action.method_id == method_id ) {
                      $scope.payout_provider_init();
          Severity: Minor
          Found in plugins/content/templates/user/js/ng/payment/balance-recharge.js - About 1 hr to fix

            Function operation has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    operation: function( options ) {
                        var $this             = this;
                        $scope.block_wait     = true;
                        $scope.is_submitted   = true;
                        $scope.status         = false;
            Severity: Minor
            Found in plugins/content/templates/user/js/ng/payment/balance-recharge.js - About 1 hr to fix

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

                  $scope.amount_change = function( is_currency ) {
                      BalanceApi.timer.cancel();
                      // init calc
                      is_currency = is_currency || false;
                      var form = $scope.form_payment__payin;
              Severity: Minor
              Found in plugins/content/templates/user/js/ng/payment/balance-recharge.js - About 1 hr to fix

                Function from_mysql has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                Date.prototype.from_mysql = function( str ) {
                    if( typeof str === 'string' ) {
                        var is_422 = false;
                        var is_224 = false;
                        if( /^\d{4}[\.\-]\d{1,2}[\.\-]\d{1,2}/.test( str ) ) {
                Severity: Minor
                Found in plugins/content/templates/user/js/ng/payment/balance-recharge.js - About 1 hr to fix

                  Function _timer has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                              $this._timer = $timeout( function() {
                                  var result = PaymentApi.operation( options );
                                  result.$promise.then(
                                      function( r ) {
                                          $scope.block_wait   = false;
                  Severity: Minor
                  Found in plugins/content/templates/user/js/ng/payment/balance-recharge.js - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                            if( is_payout ) {
                                var min = $scope.payment.balance_limit_lower || 0;
                                value -= +min;
                                var _value = ( $scope.action.payout &&
                                    $scope.action.payout.method &&
                    Severity: Major
                    Found in plugins/content/templates/user/js/ng/payment/balance-recharge.js - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                              if( is_payout ) {
                                  value = $scope.payment.payout_limit_min || value;
                                  var _value = ( $scope.action.payout &&
                                      $scope.action.payout.method &&
                                      $scope.action.payout.method.amount &&
                      Severity: Major
                      Found in plugins/content/templates/user/js/ng/payment/balance-recharge.js - About 40 mins to fix

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

                                        function( r ) {
                                            $scope.block_wait   = false;
                                            $scope.is_submitted = false;
                                            if( r.response && r.response.payout ) {
                                                $scope.status            = r.response.cancel.status;
                        plugins/content/templates/user/js/ng/payment/balance-recharge.js on lines 487..507

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

                        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( r ) {
                                            $scope.block_wait   = false;
                                            $scope.is_submitted = false;
                                            if( r.response && r.response.payout ) {
                                                $scope.status            = r.response.payout.status;
                        plugins/content/templates/user/js/ng/payment/balance-recharge.js on lines 532..552

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

                        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

                                } else if( is_224 ) {
                                    if( t.length == 3 ) {
                                        result = new Date( Date.UTC( t[2], t[1] - 1, t[0] ) );
                                    } else if( t.length == 6 ) {
                                        result = new Date( Date.UTC( t[3], t[4] - 1, t[5], t[0] || 0, t[1] || 0, t[2] || 0 ) );
                        plugins/content/templates/user/js/ng/payment/balance-recharge.js on lines 618..630

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

                        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

                                if( is_422 ) {
                                    if( t.length == 3 ) {
                                        result = new Date( Date.UTC( t[0], t[1] - 1, t[2] ) );
                                    } else if( t.length == 6 ) {
                                        result = new Date( Date.UTC( t[0], t[1] - 1, t[2], t[3] || 0, t[4] || 0, t[5] || 0 ) );
                        plugins/content/templates/user/js/ng/payment/balance-recharge.js on lines 624..630

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

                        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 twoDigits(d) {
                                if(0 <= d && d < 10) return "0" + d.toString();
                                if(-10 < d && d < 0) return "-0" + (-1*d).toString();
                                return d.toString();
                            }
                        plugins/content/templates/user/js/ng/payment/balance-recharge.js on lines 646..650

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

                        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 twoDigits(d) {
                                if(0 <= d && d < 10) return "0" + d.toString();
                                if(-10 < d && d < 0) return "-0" + (-1*d).toString();
                                return d.toString();
                            }
                        plugins/content/templates/user/js/ng/payment/balance-recharge.js on lines 637..641

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

                        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

                                    var _value = ( $scope.action.payout &&
                                        $scope.action.payout.method &&
                                        $scope.action.payout.method.amount &&
                                        $scope.action.payout.method.amount.min
                                    ) || 0;
                        plugins/content/templates/user/js/ng/payment/balance-recharge.js on lines 133..137

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

                        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

                                    var _value = ( $scope.action.payout &&
                                        $scope.action.payout.method &&
                                        $scope.action.payout.method.amount &&
                                        $scope.action.payout.method.amount.max
                                    ) || 0;
                        plugins/content/templates/user/js/ng/payment/balance-recharge.js on lines 106..110

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

                        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

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

                                if( is_currency ) {
                                    // currency rate
                                    var currency_rate = $scope.currency_rate( currency );
                                    rate  = currency_rate.rate;
                                    value = currency_rate.value;
                        plugins/content/templates/user/js/ng/payment/balance-recharge.js on lines 113..119

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

                        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

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

                                if( is_currency ) {
                                    // currency rate
                                    var currency_rate = $scope.currency_rate( currency );
                                    rate  = currency_rate.rate;
                                    value = currency_rate.value;
                        plugins/content/templates/user/js/ng/payment/balance-recharge.js on lines 140..146

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

                        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

                            return( this.getUTCFullYear() + "-" + twoDigits(1 + this.getUTCMonth()) + "-" + twoDigits(this.getUTCDate()) );
                        plugins/content/templates/user/js/ng/payment/balance-recharge.js on lines 651..651

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

                        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

                            return this.getUTCFullYear() + "-" + twoDigits(1 + this.getUTCMonth()) + "-" + twoDigits(this.getUTCDate()) + " " + twoDigits(this.getUTCHours()) + ":" + twoDigits(this.getUTCMinutes()) + ":" + twoDigits(this.getUTCSeconds());
                        plugins/content/templates/user/js/ng/payment/balance-recharge.js on lines 642..642

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

                        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

                        There are no issues that match your filters.

                        Category
                        Status