heximcz/mxtoolbox

View on GitHub

Showing 37 of 37 total issues

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

Function parseDataFromMultiprocessing has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function parseDataFromMultiprocessing()
    {
        if(is_array($this->digOutput) && count($this->digOutput) > 0) {

            foreach ($this->testResult as &$blackList) {
Severity: Minor
Found in src/MxToolbox/NetworkTools/QuickDig.php - About 1 hr 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 getJsonFromDigMultiprocess has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getJsonFromDigMultiprocess($addr, &$testResult)
    {
        $this->ipAddress = $addr;
        $this->testResult = &$testResult;
        $this->netTool->ipValidator($this->ipAddress);
Severity: Minor
Found in src/MxToolbox/NetworkTools/QuickDig.php - About 1 hr to fix

    Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function __construct(NetworkTools $netTool, $addr, $myHostName, $mailFrom, $mailRcptTo)
    Severity: Minor
    Found in src/MxToolbox/NetworkTools/SmtpServerChecks.php - About 35 mins to fix

      Function checkExistPTR has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private function checkExistPTR($addr)
          {
              if (!$this->ipValidator($addr))
                  return false;
              $this->ipAddress = $this->getIpAddressFromDomainName($addr);
      Severity: Minor
      Found in src/MxToolbox/NetworkTools/NetworkTools.php - About 35 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 getJsonFromDigMultiprocess has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getJsonFromDigMultiprocess($addr, &$testResult)
          {
              $this->ipAddress = $addr;
              $this->testResult = &$testResult;
              $this->netTool->ipValidator($this->ipAddress);
      Severity: Minor
      Found in src/MxToolbox/NetworkTools/QuickDig.php - About 35 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 makeAliveBlacklistFile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function makeAliveBlacklistFile(&$aliveBlacklists)
          {
              if (!array_key_exists('blHostName', $aliveBlacklists[0]))
                  throw new MxToolboxRuntimeException("Cannot found index ['blHostName'] in array. Build test array first.");
      
      
      Severity: Minor
      Found in src/MxToolbox/FileSystem/BlacklistsHostnameFile.php - About 35 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

      Remove error control operator '@' on line 130.
      Open

          private function setSmtpConnect($addr)
          {
              $this->smtpConnection = @stream_socket_client($addr . ':' . $this->smtpPort, $errno, $errstr,
                  $this->connTimeout, STREAM_CLIENT_CONNECT);
              if (is_resource($this->smtpConnection)) {

      ErrorControlOperator

      Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

      Example

      function foo($filePath) {
          $file = @fopen($filPath); // hides exceptions
          $key = @$array[$notExistingKey]; // assigns null to $key
      }

      Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

      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 $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

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

          public function cleanBlacklistArray($checkResponse = true)
      Severity: Minor
      Found in src/MxToolbox/MxToolbox.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

      Remove error control operator '@' on line 118.
      Open

          public function deleteAliveBlacklist()
          {
              if (empty($this->blacklistPath))
                  $this->setBlacklistFilePath();
              $blAliveFile = $this->blacklistPath . 'blacklistsAlive.txt';

      ErrorControlOperator

      Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

      Example

      function foo($filePath) {
          $file = @fopen($filPath); // hides exceptions
          $key = @$array[$notExistingKey]; // assigns null to $key
      }

      Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

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

          public function checkIpAddressOnDnsbl($addr, $quick = false)
      Severity: Minor
      Found in src/MxToolbox/MxToolbox.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

      Remove error control operator '@' on line 86.
      Open

          public function makeAliveBlacklistFile(&$aliveBlacklists)
          {
              if (!array_key_exists('blHostName', $aliveBlacklists[0]))
                  throw new MxToolboxRuntimeException("Cannot found index ['blHostName'] in array. Build test array first.");
      
      

      ErrorControlOperator

      Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

      Example

      function foo($filePath) {
          $file = @fopen($filPath); // hides exceptions
          $key = @$array[$notExistingKey]; // assigns null to $key
      }

      Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

      Remove error control operator '@' on line 98.
      Open

          public function makeAliveBlacklistFile(&$aliveBlacklists)
          {
              if (!array_key_exists('blHostName', $aliveBlacklists[0]))
                  throw new MxToolboxRuntimeException("Cannot found index ['blHostName'] in array. Build test array first.");
      
      

      ErrorControlOperator

      Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

      Example

      function foo($filePath) {
          $file = @fopen($filPath); // hides exceptions
          $key = @$array[$notExistingKey]; // assigns null to $key
      }

      Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

      Remove error control operator '@' on line 61.
      Open

          public function setDnsResolverIP($addr)
          {
              if ($this->validateIPAddress($addr) && $fss = @fsockopen('tcp://' . $addr, 53, $errNo, $errStr, 5)) {
                  fclose($fss);
                  $this->dnsResolvers[] = $addr;

      ErrorControlOperator

      Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

      Example

      function foo($filePath) {
          $file = @fopen($filPath); // hides exceptions
          $key = @$array[$notExistingKey]; // assigns null to $key
      }

      Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

      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 setBlacklistFilePath has a boolean flag argument $path, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public function setBlacklistFilePath($path=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

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

          private function searchDigResult($domainName) {
              foreach ($this->digOutput as $item) {
                  if (($firstLine = strtok($item[0], "\n")) !== false) {
                      if ($this->digParser->isDomainNameInString($domainName, $firstLine))
                          return $item[0];
      Severity: Minor
      Found in src/MxToolbox/NetworkTools/QuickDig.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 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

      Severity
      Category
      Status
      Source
      Language