t1gor/Robots.txt-Parser-Class

View on GitHub

Showing 1,364 of 1,364 total issues

Opening brace should be on a new line
Open

    public function filter($in, $out, &$consumed, $closing) {

Opening brace should be on a new line
Open

    public function filter($in, $out, &$consumed, $closing) {

Opening brace should be on a new line
Open

    private function checkBasicRule(string $rule, string $path): bool {
Severity: Minor
Found in source/RobotsTxtParser.php by phpcodesniffer

Opening brace should be on a new line
Open

    public function getDelay(string $userAgent = "*", string $type = Directive::CRAWL_DELAY) {
Severity: Minor
Found in source/RobotsTxtParser.php by phpcodesniffer

Opening brace should be on a new line
Open

    public function filter($in, $out, &$consumed, $closing) {

Opening brace should be on a new line
Open

    private function checkHttpStatusCodeRule(): bool {
Severity: Minor
Found in source/RobotsTxtParser.php by phpcodesniffer

Opening brace should be on a new line
Open

    protected function prepareRegexRule(string $value): string {
Severity: Minor
Found in source/RobotsTxtParser.php by phpcodesniffer

Opening brace should be on a new line
Open

    public function isDisallowed(string $url, string $userAgent = '*'): bool {
Severity: Minor
Found in source/RobotsTxtParser.php by phpcodesniffer

Opening brace should be on a new line
Open

    public function getContentIterated(): \Generator {

Opening brace should be on a new line
Open

    public static function fromStream($stream): self {

Opening brace should be on a new line
Open

    protected function setStream($stream): GeneratorBasedReader {

Opening brace should be on a new line
Open

    public static function fromString(string $input = ''): self {

Opening brace should be on a new line
Open

    public function getContentRaw(): string {

Opening brace should be on a new line
Open

    public function setEncoding(string $encoding) {

The variable $error_msg is not named in camelCase.
Open

    private function checkHostRule($rule) {
        if (!isset($this->url)) {
            $error_msg = WarmingMessages::INLINED_HOST;
            $this->log($error_msg, [], LogLevel::ERROR);
            return false;
Severity: Minor
Found in source/RobotsTxtParser.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $error_msg is not named in camelCase.
Open

    private function checkHostRule($rule) {
        if (!isset($this->url)) {
            $error_msg = WarmingMessages::INLINED_HOST;
            $this->log($error_msg, [], LogLevel::ERROR);
            return false;
Severity: Minor
Found in source/RobotsTxtParser.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

Define a constant instead of duplicating this literal "{useragent}" 3 times.
Open

                '{useragent}' => $currentUserAgent,

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Remove this commented out code.
Open

//            $bucket->data = preg_replace(Directive::getAllowDisallowRegex(), '', $bucket->data, -1, $skippedAllowanceValues);

Programmers should not comment out code as it bloats programs and reduces readability.

Unused code should be deleted and can be retrieved from source control history if required.

See

  • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
  • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
  • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
  • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

Define a constant instead of duplicating this literal "logger" 5 times.
Open

            if (isset($this->params['logger']) && $this->params['logger'] instanceof LoggerInterface) {

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "{directive}" 3 times.
Open

                '{directive}' => $directive,

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Severity
Category
Status
Source
Language