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)
- Read upRead up
- Exclude checks
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) {
- Read upRead up
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);
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(NetworkTools $netTool, $addr, $myHostName, $mailFrom, $mailRcptTo)
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);
- Read upRead up
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);
- Read upRead up
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.");
- Read upRead up
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)) {
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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';
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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.");
- Read upRead up
- Exclude checks
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.");
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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];
- Read upRead up
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
- Read upRead up
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"