TikiWiki/tiki-manager

View on GitHub
src/Libs/Helpers/Checksum.php

Summary

Maintainability
F
3 days
Test Coverage

handleCheckResult accesses the super-global variable $_ENV.
Open

    public static function handleCheckResult(Instance $instance, Version $version, $array)
    {
        if (! $_ENV['INTERACTIVE']) {
            return; // skip
        }
Severity: Minor
Found in src/Libs/Helpers/Checksum.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

handleCheckResult accesses the super-global variable $_ENV.
Open

    public static function handleCheckResult(Instance $instance, Version $version, $array)
    {
        if (! $_ENV['INTERACTIVE']) {
            return; // skip
        }
Severity: Minor
Found in src/Libs/Helpers/Checksum.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

handleCheckResult accesses the super-global variable $_ENV.
Open

    public static function handleCheckResult(Instance $instance, Version $version, $array)
    {
        if (! $_ENV['INTERACTIVE']) {
            return; // skip
        }
Severity: Minor
Found in src/Libs/Helpers/Checksum.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

handleCheckResult accesses the super-global variable $_ENV.
Open

    public static function handleCheckResult(Instance $instance, Version $version, $array)
    {
        if (! $_ENV['INTERACTIVE']) {
            return; // skip
        }
Severity: Minor
Found in src/Libs/Helpers/Checksum.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

handleCheckResult accesses the super-global variable $_ENV.
Open

    public static function handleCheckResult(Instance $instance, Version $version, $array)
    {
        if (! $_ENV['INTERACTIVE']) {
            return; // skip
        }
Severity: Minor
Found in src/Libs/Helpers/Checksum.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Function handleCheckResult has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

    public static function handleCheckResult(Instance $instance, Version $version, $array)
    {
        if (! $_ENV['INTERACTIVE']) {
            return; // skip
        }
Severity: Minor
Found in src/Libs/Helpers/Checksum.php - About 1 day 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 handleCheckResult has 194 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function handleCheckResult(Instance $instance, Version $version, $array)
    {
        if (! $_ENV['INTERACTIVE']) {
            return; // skip
        }
Severity: Major
Found in src/Libs/Helpers/Checksum.php - About 7 hrs to fix

    The method handleCheckResult() has an NPath complexity of 90288. The configured NPath complexity threshold is 200.
    Open

        public static function handleCheckResult(Instance $instance, Version $version, $array)
        {
            if (! $_ENV['INTERACTIVE']) {
                return; // skip
            }
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    NPathComplexity

    Since: 0.1

    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

    Example

    class Foo {
        function bar() {
            // lots of complicated code
        }
    }

    Source https://phpmd.org/rules/codesize.html#npathcomplexity

    The method handleCheckResult() has 258 lines of code. Current threshold is set to 100. Avoid really long methods.
    Open

        public static function handleCheckResult(Instance $instance, Version $version, $array)
        {
            if (! $_ENV['INTERACTIVE']) {
                return; // skip
            }
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    The method handleCheckResult() has a Cyclomatic Complexity of 39. The configured cyclomatic complexity threshold is 10.
    Open

        public static function handleCheckResult(Instance $instance, Version $version, $array)
        {
            if (! $_ENV['INTERACTIVE']) {
                return; // skip
            }
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    CyclomaticComplexity

    Since: 0.1

    Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

    Example

    // Cyclomatic Complexity = 11
    class Foo {
    1   public function example() {
    2       if ($a == $b) {
    3           if ($a1 == $b1) {
                    fiddle();
    4           } elseif ($a2 == $b2) {
                    fiddle();
                } else {
                    fiddle();
                }
    5       } elseif ($c == $d) {
    6           while ($c == $d) {
                    fiddle();
                }
    7        } elseif ($e == $f) {
    8           for ($n = 0; $n < $h; $n++) {
                    fiddle();
                }
            } else {
                switch ($z) {
    9               case 1:
                        fiddle();
                        break;
    10              case 2:
                        fiddle();
                        break;
    11              case 3:
                        fiddle();
                        break;
                    default:
                        fiddle();
                        break;
                }
            }
        }
    }

    Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

    Avoid using undefined variables such as '$new' which will lead to PHP notices.
    Open

            while ($input != 's' && count($new)) {
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$mod' which will lead to PHP notices.
    Open

                            unset($mod[$file]);
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$new' which will lead to PHP notices.
    Open

                            unset($new[$file]);
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$new' which will lead to PHP notices.
    Open

                            $version->recordFile($new[$file], $file, $app);
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$del' which will lead to PHP notices.
    Open

            $delFlat = array_keys($del);
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$del' which will lead to PHP notices.
    Open

                            unset($del[$file]);
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$del' which will lead to PHP notices.
    Open

                            unset($del[$file]);
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$new' which will lead to PHP notices.
    Open

                            unset($new[$file]);
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$del' which will lead to PHP notices.
    Open

            while ($input != 's' && count($del)) {
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$new' which will lead to PHP notices.
    Open

            $newFlat = array_keys($new);
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$mod' which will lead to PHP notices.
    Open

                            $version->replaceFile($mod[$file], $file, $app);
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$mod' which will lead to PHP notices.
    Open

                            unset($mod[$file]);
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$mod' which will lead to PHP notices.
    Open

                            if ($mod[$file] != $hash) {
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$del' which will lead to PHP notices.
    Open

                            if ($del[$file] != $hash) {
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$mod' which will lead to PHP notices.
    Open

            while ($input != 's' && count($mod)) {
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$mod' which will lead to PHP notices.
    Open

                                if ($mod[$file] != $hash) {
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$mod' which will lead to PHP notices.
    Open

            $modFlat = array_keys($mod);
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$mod' which will lead to PHP notices.
    Open

                                unset($mod[$file]);
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using TikiManager\Libs\Helpers\count() function in while loops.
    Open

            while ($input != 's' && count($new)) {
                $io->writeln("New files found on remote host:");
                foreach ($newFlat as $key => $file) {
                    $io->writeln("\t[$key] $file");
                }
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    CountInLoopExpression

    Since: 2.7.0

    Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.

    Example

    class Foo {
    
      public function bar()
      {
        $array = array();
    
        for ($i = 0; count($array); $i++) {
          // ...
        }
      }
    }

    Source https://phpmd.org/rules/design.html#countinloopexpression

    Avoid using TikiManager\Libs\Helpers\count() function in while loops.
    Open

            while ($input != 's' && count($mod)) {
                $io->writeln("Modified files were found on remote host:");
    
                foreach ($modFlat as $key => $file) {
                    $io->writeln("\t[$key] $file");
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    CountInLoopExpression

    Since: 2.7.0

    Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.

    Example

    class Foo {
    
      public function bar()
      {
        $array = array();
    
        for ($i = 0; count($array); $i++) {
          // ...
        }
      }
    }

    Source https://phpmd.org/rules/design.html#countinloopexpression

    Avoid using TikiManager\Libs\Helpers\count() function in while loops.
    Open

            while ($input != 's' && count($del)) {
                $io->writeln("<comment>Deleted files were found on remote host:</comment>");
                foreach ($delFlat as $key => $file) {
                    $io->writeln("\t[$key] $file");
                }
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phpmd

    CountInLoopExpression

    Since: 2.7.0

    Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.

    Example

    class Foo {
    
      public function bar()
      {
        $array = array();
    
        for ($i = 0; count($array); $i++) {
          // ...
        }
      }
    }

    Source https://phpmd.org/rules/design.html#countinloopexpression

    Argument #2 of this call to \stripos is typically a literal or constant but isn't, but argument #1 (which is typically a variable) is a literal or constant. The arguments may be in the wrong order.
    Open

                } while ((strlen($input) == 0) || (stripos('pvdas', $input[0]) === false));
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phan

    Argument #2 of this call to \stripos is typically a literal or constant but isn't, but argument #1 (which is typically a variable) is a literal or constant. The arguments may be in the wrong order.
    Open

                while (stripos('pvcerus', $input[0]) === false) {
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phan

    Argument #2 of this call to \stripos is typically a literal or constant but isn't, but argument #1 (which is typically a variable) is a literal or constant. The arguments may be in the wrong order.
    Open

                while (stripos('drs', $input[0]) === false) {
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phan

    Possibly zero references to use statement for classlike/namespace SymfonyStyle (\Symfony\Component\Console\Style\SymfonyStyle)
    Open

    use Symfony\Component\Console\Style\SymfonyStyle;
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php by phan

    Call with 3 arg(s) to \TikiManager\Application\Version::recordFile() which only takes 2 arg(s) defined at /code/src/Application/Version.php:162
    Open

                            $version->recordFile($new[$file], $file, $app);
    Severity: Info
    Found in src/Libs/Helpers/Checksum.php by phan

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

                    case 'r':
                        $app = $instance->getApplication();
                        $access = $instance->getBestAccess('filetransfer');
    
                        foreach ($files as $file) {
    Severity: Major
    Found in src/Libs/Helpers/Checksum.php and 1 other location - About 3 hrs to fix
    src/Libs/Helpers/Checksum.php on lines 246..264

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

    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

                    case 'r':
                        $app = $instance->getApplication();
                        $access = $instance->getBestAccess('filetransfer');
    
                        foreach ($files as $file) {
    Severity: Major
    Found in src/Libs/Helpers/Checksum.php and 1 other location - About 3 hrs to fix
    src/Libs/Helpers/Checksum.php on lines 181..199

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

    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

                    case 'u':
                        $app = $instance->getApplication();
    
                        query('BEGIN TRANSACTION');
    
    
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php and 1 other location - About 55 mins to fix
    src/Libs/Helpers/Checksum.php on lines 77..91

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

    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

                    case 'a':
                        $app = $instance->getApplication();
    
                        query('BEGIN TRANSACTION');
    
    
    Severity: Minor
    Found in src/Libs/Helpers/Checksum.php and 1 other location - About 55 mins to fix
    src/Libs/Helpers/Checksum.php on lines 201..215

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

    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