MPOS/php-mpos

View on GitHub
include/lib/scrypt.php

Summary

Maintainability
C
1 day
Test Coverage

File scrypt.php has 325 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
Severity: Minor
Found in include/lib/scrypt.php - About 3 hrs to fix

    Method salsa208Core64 has 79 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected static function salsa208Core64($b)
        {
            $b32 = array();
            for ($i = 0; $i < 16; $i++) {
                list(, $b32[$i]) = unpack("V", substr($b, $i * 4, 4));
    Severity: Major
    Found in include/lib/scrypt.php - About 3 hrs to fix

      Method salsa208Core32 has 79 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected static function salsa208Core32($b)
          {
              $b32 = array();
              for ($i = 0; $i < 16; $i++) {
                 list(, $b32[$i]) = unpack("V", substr($b, $i * 4, 4));
      Severity: Major
      Found in include/lib/scrypt.php - About 3 hrs to fix

        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

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

              public static function calc($hash, $password, $salt, $iterations, $length)
          Severity: Minor
          Found in include/lib/scrypt.php - About 35 mins to fix

            Function scryptBlockMix has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                protected static function scryptBlockMix($b, $r)
                {
                    $x = substr($b, -64);
                    $even = '';
                    $odd = '';
            Severity: Minor
            Found in include/lib/scrypt.php - 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

            There are no issues that match your filters.

            Category
            Status