source/Parser/DirectiveProcessors/HostProcessor.php
Avoid unused parameters such as '$prevLine'. Open
Open
public function process(string $line, array & $root, string & $currentUserAgent = '*', string $prevLine = '') {
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid using static access to class '\t1gor\RobotsTxtParser\Parser\HostName' in method 'process'. Open
Open
'{ipAddress}' => HostName::isIpAddress($entry) ? ' (IP address is not a valid hostname)' : '',
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\t1gor\RobotsTxtParser\Parser\HostName' in method 'process'. Open
Open
if (HostName::isValid($entry)) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Opening brace of a class must be on the line after the definition Open
Open
class HostProcessor extends AbstractDirectiveProcessor implements DirectiveProcessorInterface {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (HostName::isValid($entry)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$this->log(strtr('{directive} with value {faulty} dropped for {useragent} as invalid{ipAddress}', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
]));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'{ipAddress}' => HostName::isIpAddress($entry) ? ' (IP address is not a valid hostname)' : '',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$parts = explode(':', $line);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function process(string $line, array & $root, string & $currentUserAgent = '*', string $prevLine = '') {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$entry = implode(':', $trimmed);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'{directive}' => Directive::HOST,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getDirectiveName(): string {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return Directive::HOST;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
array_shift($parts);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$root[$currentUserAgent][Directive::HOST] = $entry;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'{faulty}' => $entry,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$trimmed = array_map('trim', $parts);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'{useragent}' => $currentUserAgent,
- Exclude checks
Opening brace should be on a new line Open
Open
public function process(string $line, array & $root, string & $currentUserAgent = '*', string $prevLine = '') {
- Exclude checks
Opening brace should be on a new line Open
Open
public function getDirectiveName(): string {
- Exclude checks