heximcz/mxtoolbox

View on GitHub
src/MxToolbox/DataGrid/MxToolboxDataGrid.php

Summary

Maintainability
A
50 mins
Test Coverage

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

    public function cleanPrevResults($checkResponse = true)
    {
        if ($this->isArrayInitialized($this->testStructure)) {
            foreach ($this->testStructure as $index => $blackList) {
                // here is default true because blacklist is loaded from alive file 
Severity: Minor
Found in src/MxToolbox/DataGrid/MxToolboxDataGrid.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 setTestResultArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function setTestResultArray($blacklistHostNamesArray, $alive = true, $ownBlacklist = false)
    {
        if ($this->isArrayInitialized($blacklistHostNamesArray)) {
            $this->testStructure = array();
            foreach ($blacklistHostNamesArray as $index => $blackList) {
Severity: Minor
Found in src/MxToolbox/DataGrid/MxToolboxDataGrid.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 cleanPrevResults has a boolean flag argument $checkResponse, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function cleanPrevResults($checkResponse = true)

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

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

    protected function setTestResultArray($blacklistHostNamesArray, $alive = true, $ownBlacklist = false)

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

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

    protected function setTestResultArray($blacklistHostNamesArray, $alive = true, $ownBlacklist = false)

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 unused local variables such as '$blackList'.
Open

            foreach ($this->testStructure as $index => $blackList) {

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

Avoid excessively long variable names like $blacklistHostNamesArray. Keep variable name length under 20.
Open

    protected function setTestResultArray($blacklistHostNamesArray, $alive = true, $ownBlacklist = false)

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

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

There are no issues that match your filters.

Category
Status