WordPress/WordPress

View on GitHub
wp-includes/sodium_compat/src/Core32/Salsa20.php

Summary

Maintainability
F
1 wk
Test Coverage

Method core_salsa20 has 108 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function core_salsa20($in, $k, $c = null)
    {
        /**
         * @var ParagonIE_Sodium_Core32_Int32 $x0
         * @var ParagonIE_Sodium_Core32_Int32 $x1
Severity: Major
Found in wp-includes/sodium_compat/src/Core32/Salsa20.php - About 4 hrs to fix

    Method salsa20_xor_ic has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function salsa20_xor_ic($m, $n, $ic, $k)
        {
            $mlen = self::strlen($m);
            if ($mlen < 1) {
                return '';
    Severity: Minor
    Found in wp-includes/sodium_compat/src/Core32/Salsa20.php - About 1 hr to fix

      Method salsa20 has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function salsa20($len, $nonce, $key)
          {
              if (self::strlen($key) !== 32) {
                  throw new RangeException('Key must be 32 bytes long');
              }
      Severity: Minor
      Found in wp-includes/sodium_compat/src/Core32/Salsa20.php - About 1 hr to fix

        Function salsa20 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function salsa20($len, $nonce, $key)
            {
                if (self::strlen($key) !== 32) {
                    throw new RangeException('Key must be 32 bytes long');
                }
        Severity: Minor
        Found in wp-includes/sodium_compat/src/Core32/Salsa20.php - 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

        Function salsa20_xor_ic has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function salsa20_xor_ic($m, $n, $ic, $k)
            {
                $mlen = self::strlen($m);
                if ($mlen < 1) {
                    return '';
        Severity: Minor
        Found in wp-includes/sodium_compat/src/Core32/Salsa20.php - 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

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

                for ($i = self::ROUNDS; $i > 0; $i -= 2) {
                    $x4  = $x4->xorInt32($x0->addInt32($x12)->rotateLeft(7));
                    $x8  = $x8->xorInt32($x4->addInt32($x0)->rotateLeft(9));
                    $x12 = $x12->xorInt32($x8->addInt32($x4)->rotateLeft(13));
                    $x0  = $x0->xorInt32($x12->addInt32($x8)->rotateLeft(18));
        Severity: Major
        Found in wp-includes/sodium_compat/src/Core32/Salsa20.php and 1 other location - About 4 days to fix
        wp-includes/sodium_compat/src/Core32/HSalsa20.php on lines 90..130

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

        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

            public static function salsa20_xor_ic($m, $n, $ic, $k)
            {
                $mlen = self::strlen($m);
                if ($mlen < 1) {
                    return '';
        Severity: Major
        Found in wp-includes/sodium_compat/src/Core32/Salsa20.php and 1 other location - About 1 day to fix
        wp-includes/sodium_compat/src/Core/Salsa20.php on lines 186..231

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

        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

            public static function salsa20($len, $nonce, $key)
            {
                if (self::strlen($key) !== 32) {
                    throw new RangeException('Key must be 32 bytes long');
                }
        Severity: Major
        Found in wp-includes/sodium_compat/src/Core32/Salsa20.php and 1 other location - About 1 day to fix
        wp-includes/sodium_compat/src/Core/Salsa20.php on lines 141..173

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

        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 ($c === null) {
                    $x0  = new ParagonIE_Sodium_Core32_Int32(array(0x6170, 0x7865));
                    $x5  = new ParagonIE_Sodium_Core32_Int32(array(0x3320, 0x646e));
                    $x10 = new ParagonIE_Sodium_Core32_Int32(array(0x7962, 0x2d32));
                    $x15 = new ParagonIE_Sodium_Core32_Int32(array(0x6b20, 0x6574));
        Severity: Major
        Found in wp-includes/sodium_compat/src/Core32/Salsa20.php and 1 other location - About 6 hrs to fix
        wp-includes/sodium_compat/src/Core32/HSalsa20.php on lines 66..76

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

        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

                return $x0->toReverseString() .
                    $x1->toReverseString() .
                    $x2->toReverseString() .
                    $x3->toReverseString() .
                    $x4->toReverseString() .
        Severity: Major
        Found in wp-includes/sodium_compat/src/Core32/Salsa20.php and 1 other location - About 1 hr to fix
        wp-includes/sodium_compat/src/Core32/ChaCha20.php on lines 289..304

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

        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