TikiWiki/tiki-manager

View on GitHub
src/Report/Backup.php

Summary

Maintainability
A
1 hr
Test Coverage

getDiskUsage accesses the super-global variable $_ENV.
Open

    private function getDiskUsage(&$used, &$total, &$available)
    {
        $path = escapeshellarg($_ENV['ARCHIVE_FOLDER']);
        $out = `df $path | awk '/^\// {print $3,$2,$4}'`;

Severity: Minor
Found in src/Report/Backup.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

Method getDetails has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function getDetails($instance)
    {
        $archives = $instance->getArchives();

        if (count($archives) > 0) {
Severity: Minor
Found in src/Report/Backup.php - About 1 hr to fix

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

            $humanUsed = $this->humanReadableSize($used, 1);
    Severity: Minor
    Found in src/Report/Backup.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 '$free' which will lead to PHP notices.
    Open

            $availableRatio = $free / $total * 100;
    Severity: Minor
    Found in src/Report/Backup.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 '$used' which will lead to PHP notices.
    Open

            $this->getDiskUsage($used, $total, $free);
    Severity: Minor
    Found in src/Report/Backup.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 '$free' which will lead to PHP notices.
    Open

            $humanFree = $this->humanReadableSize($free, 1);
    Severity: Minor
    Found in src/Report/Backup.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 '$total' which will lead to PHP notices.
    Open

            $availableRatio = $free / $total * 100;
    Severity: Minor
    Found in src/Report/Backup.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 '$total' which will lead to PHP notices.
    Open

            $usedRatio = $used / $total * 100;
    Severity: Minor
    Found in src/Report/Backup.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 '$used' which will lead to PHP notices.
    Open

            $usedRatio = $used / $total * 100;
    Severity: Minor
    Found in src/Report/Backup.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 '$total' which will lead to PHP notices.
    Open

            $this->getDiskUsage($used, $total, $free);
    Severity: Minor
    Found in src/Report/Backup.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 '$total' which will lead to PHP notices.
    Open

            $humanTotal = $this->humanReadableSize($total, 1);
    Severity: Minor
    Found in src/Report/Backup.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 '$free' which will lead to PHP notices.
    Open

            $this->getDiskUsage($used, $total, $free);
    Severity: Minor
    Found in src/Report/Backup.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

    The method getDetails uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $detail = <<<DET
    
    ! {img src=pics/icons/exclamation.png} {$instance->name}
    __Website:__ [{$instance->weburl}]
    Severity: Minor
    Found in src/Report/Backup.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

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

            while ($value >= 1000 && count($unit) > 0) {
                $value /= 1024;
                $used = array_shift($unit);
            }
    Severity: Minor
    Found in src/Report/Backup.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

    There are no issues that match your filters.

    Category
    Status