lib/Ajde/Dump.php

Summary

Maintainability
A
25 mins
Test Coverage

The method Ajde_Dump::dump() calls the typical debug function print_r() which is mostly only used during development.
Open

                    isset($item['class']) ? (is_object($item['class']) ? get_class($item['class']) : $item['class']) : '&lt;unknown class&gt; (in <span style=\'font-size: 0.8em;\'>'.print_r($item['args'][0]).'</span>)',
Severity: Minor
Found in lib/Ajde/Dump.php by phpmd

DevelopmentCodeFragment

Since: 2.3.0

Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.

Example

class SuspectCode {

    public function doSomething(array $items)
    {
        foreach ($items as $i => $item) {
            // …

            if ('qafoo' == $item) var_dump($i);

            // …
        }
    }
}

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

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

    public static function dump($var, $expand = true)
    {
        $i = 0;
        $line = null;
        foreach (debug_backtrace() as $item) {
Severity: Minor
Found in lib/Ajde/Dump.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

The method dump has a boolean flag argument $expand, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function dump($var, $expand = true)
Severity: Minor
Found in lib/Ajde/Dump.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

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

Avoid using empty try-catch blocks in dump.
Open

            } catch (Exception $e) {
            }
Severity: Minor
Found in lib/Ajde/Dump.php by phpmd

EmptyCatchBlock

Since: 2.7.0

Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

Example

class Foo {

  public function bar()
  {
      try {
          // ...
      } catch (Exception $e) {} // empty catch block
  }
}

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

Avoid variables with short names like $i. Configured minimum length is 3.
Open

        $i = 0;
Severity: Minor
Found in lib/Ajde/Dump.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

The class Ajde_Dump is not named in CamelCase.
Open

class Ajde_Dump extends Ajde_Object_Static
{
    public static $dump = [];
    public static $warn = [];

Severity: Minor
Found in lib/Ajde/Dump.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

There are no issues that match your filters.

Category
Status