MPOS/php-mpos

View on GitHub

Showing 1,089 of 1,089 total issues

Function sendChangeConfigEmail has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  public function sendChangeConfigEmail($strType, $userID) {
    $exists = $this->token->doesTokenExist($strType, $userID);
    if ($exists == 0) {
      $token = $this->token->createToken($strType, $userID);
      $aData['token'] = $token;
Severity: Minor
Found in include/classes/user.class.php - 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

              if (empty($filter['type']) || ($filter['type'] != 'Debit_AP' && $filter['type'] != 'Debit_MP' && $filter['type'] != 'TXFee' && $filter['type'] != 'Credit_PPS' && $filter['type'] != 'Fee_PPS' && $filter['type'] != 'Donation_PPS')) {
                $aFilter[] = "( b.confirmations >= " . $this->config['confirmations'] . " OR ISNULL(b.confirmations) )";
              }
Severity: Major
Found in include/classes/transaction.class.php - About 45 mins to fix

    Function setupInlineSubTemplate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function setupInlineSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope, $hash)
        {
            $tpl = new $this->smarty->template_class($template, $this->smarty, $this, $cache_id, $compile_id, $caching, $cache_lifetime);
            $tpl->properties['nocache_hash']  = $hash;
            // get variables from calling scope
    Severity: Minor
    Found in include/smarty/libs/sysplugins/smarty_internal_template.php - 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

    Function createDebitRecord has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      private function createDebitRecord($account_id, $coin_address, $amount, $type) {
        // Calculate and deduct txfee from amount
        $type == 'Debit_MP' ? $txfee = $this->config['txfee_manual'] : $txfee = $this->config['txfee_auto'];
        $amount = $amount - $txfee;
        // Add Debit record
    Severity: Minor
    Found in include/classes/transaction.class.php - 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

    Function generatePin has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      public function generatePin($userID, $current) {
        $this->debug->append("STA " . __METHOD__, 4);
        $username = $this->getUserName($userID);
        $email = $this->getUserEmail($username);
        $strPasswordHash = $this->getUserPasswordHashById($userID);
    Severity: Minor
    Found in include/classes/user.class.php - 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

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

      public function __construct($scheme, $username, $password, $address = "localhost", $certificate_path = '', $debug = false) {
    Severity: Minor
    Found in include/classes/bitcoin.class.php - About 45 mins to fix

      Function getTemplateUid has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function getTemplateUid(Smarty $smarty, $resource_name, $cache_id, $compile_id)
          {
              $uid = '';
              if (isset($resource_name)) {
                  $tpl = new $smarty->template_class($resource_name, $smarty);
      Severity: Minor
      Found in include/smarty/libs/sysplugins/smarty_cacheresource_keyvaluestore.php - 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

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

        public function addTransaction($account_id, $amount, $type='Credit', $block_id=NULL, $coin_address=NULL, $txid=NULL) {
      Severity: Minor
      Found in include/classes/transaction.class.php - About 45 mins to fix

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

          private function buildSeed($data, $year, $month, $day, $hour, $minute) {
        Severity: Minor
        Found in include/classes/csrftoken.class.php - About 45 mins to fix

          Function checkBasic has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            public function checkBasic($user, $type, $token) {
              if (empty($token)) return false;
              $token_now = $this->getBasic($user, $type);
              if ($token_now !== $token) {
                $tokens_check = $this->checkAdditional($user, $type);
          Severity: Minor
          Found in include/classes/csrftoken.class.php - 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

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

              public static function calc($password, $salt, $n, $r, $p, $length)
          Severity: Minor
          Found in include/lib/scrypt.php - About 45 mins to fix

            Function calc has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function calc($password, $salt, $n, $r, $p, $length)
                {
                    if ($n == 0 || ($n & ($n - 1)) != 0) {
                        throw new Exception\InvalidArgumentException("N must be > 0 and a power of 2");
                    }
            Severity: Minor
            Found in include/lib/scrypt.php - 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

            Function getEncodableWordTokens has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function getEncodableWordTokens($string)
                {
                    $tokens = array();
            
                    $encodedToken = '';
            Severity: Minor
            Found in include/lib/swiftmailer/classes/Swift/Mime/Headers/AbstractHeader.php - 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

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

                        $(this._element).find('li.' + this._config.activeClass).has('ul').children('a').addClass('doubleTapToGo');
            public/site_assets/bootstrap/js/plugins/metisMenu/jquery.metisMenu.js on lines 181..181

            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

            Function _safeWordwrap has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                private function _safeWordwrap($string, $length = 75, $le = "\r\n")
                {
                    if (0 >= $length) {
                        return $string;
                    }

            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 toString has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function toString()
                {
                    $string = '';
                    $headers = $this->_headers;
                    if ($this->_canSort()) {
            Severity: Minor
            Found in include/lib/swiftmailer/classes/Swift/Mime/SimpleHeaderSet.php - 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

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

                      $(this._element).find('li.' + this._config.activeClass).has('ul').children('ul').attr('aria-expanded', true).addClass(this._config.collapseClass + ' ' + this._config.collapseInClass);
            public/site_assets/bootstrap/js/plugins/metisMenu/jquery.metisMenu.js on lines 187..187

            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 3 locations. Consider refactoring.
            Open

                    } else if ($(this).attr("id") === 'lastlogin') {
                        var md5lastlogin = $.md5(document.getElementById('lastlogin').innerHTML);
                        $.cookie('lastlogin-box', md5lastlogin, { path: '/' });
                    } else if ($(this).attr("id") === 'backend') {
                        var md5backend = $.md5(document.getElementById('backend').innerHTML);
            Severity: Major
            Found in public/site_assets/bootstrap/js/mpos.js and 2 other locations - About 45 mins to fix
            public/site_assets/bootstrap/js/mpos.js on lines 76..87
            public/site_assets/bootstrap/js/mpos.js on lines 82..87

            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

            Function _appendFootnotes_callback has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function _appendFootnotes_callback($matches) {
                    $node_id = $this->fn_id_prefix . $matches[1];
                    
                    # Create footnote marker only if it has a corresponding footnote *and*
                    # the footnote hasn't been used by another marker.
            Severity: Minor
            Found in include/lib/Michelf/Markdown.php - 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

            Function _bodyToString has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function _bodyToString()
                {
                    $string = '';
            
                    if (isset($this->_body) && empty($this->_immediateChildren)) {
            Severity: Minor
            Found in include/lib/swiftmailer/classes/Swift/Mime/SimpleMimeEntity.php - 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

            Severity
            Category
            Status
            Source
            Language