N0rthernL1ghts/hosts-parser

View on GitHub

Showing 8 of 8 total issues

Avoid variables with short names like $ip. Configured minimum length is 3.
Open

    public function __construct(string $ip, array $domains, int $line)
Severity: Minor
Found in src/Host.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

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

Avoid variables with short names like $ip. Configured minimum length is 3.
Open

    protected $ip;
Severity: Minor
Found in src/Host.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

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

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

    public function __construct(HostsFile $hostsFile, bool $strictSyntax = false)
Severity: Minor
Found in src/Parser.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

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

    public function parseAll(bool $forceLarge = false): array
Severity: Minor
Found in src/Parser.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

Possibly zero references to use statement for classlike/namespace HostsFileException (\NorthernLights\HostsFileParser\Exception\HostsFileException)
Open

use NorthernLights\HostsFileParser\Exception\HostsFileException;
Severity: Minor
Found in src/HostsFile.php by phan

Rename "$splFile" which has the same name as the field declared at line 23.
Open

        $splFile = new SplFileObject($this->filename, 'rb');
Severity: Major
Found in src/HostsFile.php by sonar-php

Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

Noncompliant Code Example

class Foo {
  public $myField;

  public function doSomething() {
    $myField = 0;
    ...
  }
}

See

Assigning null to property but \NorthernLights\HostsFileParser\HostsFile->splFile is \SplFileObject
Open

        $this->splFile = null;
Severity: Minor
Found in src/HostsFile.php by phan

Saw an @param annotation for filename, but it was not found in the param list of function __construct(\NorthernLights\HostsFileParser\HostsFile $hostsFile, bool|false $strictSyntax = null)
Open

     * @param HostsFile $filename
Severity: Info
Found in src/Parser.php by phan
Severity
Category
Status
Source
Language