nilsabegg/sesame

View on GitHub

Showing 61 of 62 total issues

Avoid excessively long variable names like $ratingAmountStringParts. Keep variable name length under 20.
Open

        $ratingAmountStringParts = explode(' ', $ratingAmountString);
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phpmd

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

Avoid excessively long variable names like $stockAmountStringParts. Keep variable name length under 20.
Open

        $stockAmountStringParts = explode(' ', $stockAmountString);
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phpmd

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

Avoid excessively long variable names like $sellerSinceStringParts. Keep variable name length under 20.
Open

        $sellerSinceStringParts = explode(' ', $sellerSinceString);
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phpmd

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

Missing class import via use statement (line '55', column '23').
Open

            throw new \InvalidArgumentException();
Severity: Minor
Found in src/Sesame/Sesame.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

Avoid unused parameters such as '$article'.
Open

    public function renderArticle(Article $article): string
Severity: Minor
Found in src/Sesame/Renderer/JsonRenderer.php by phpmd

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 unused parameters such as '$crawlVariations'.
Open

    public function crawlArticle(string $responseBody, bool $crawlVariations): Article
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phpmd

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

The method renderArticle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            throw new \InvalidArgumentException();
        }
Severity: Minor
Found in src/Sesame/Sesame.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid unused parameters such as '$article'.
Open

    public function renderArticle(Article $article): string
Severity: Minor
Found in src/Sesame/Renderer/XmlRenderer.php by phpmd

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

The method extractProperties uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $properties[$propertyTitle] = $propertyValue;
            }
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Line exceeds 120 characters; contains 185 characters
Open

                'With this option you can control if Sesame will crawl the variations for the article too. Syntax "-cv0" to ignore variations or "--crawlVariations=1" to include them.',

Class extends undeclared class \Symfony\Component\Console\Command\Command
Open

class CrawlArticleCommand extends Command
Severity: Critical
Found in src/Sesame/Command/CrawlArticleCommand.php by phan

Call to method writeln from undeclared class \Symfony\Component\Console\Output\OutputInterface
Open

            $output->writeln($exception->getMessage());
Severity: Critical
Found in src/Sesame/Command/CrawlArticleCommand.php by phan

Parameter $articleCrawler has undeclared type \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

    protected function extractDescription(DomCrawler $articleCrawler): string
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $descriptionHtml = $articleCrawler->filter('#j-product-description');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Parameter $articleCrawler has undeclared type \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

    protected function extractPrice(DomCrawler $articleCrawler): float
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Parameter $articleCrawler has undeclared type \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

    protected function extractPriceDiscount(DomCrawler $articleCrawler): float
Severity: Minor
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Parameter $input has undeclared type \Symfony\Component\Console\Input\InputInterface
Open

    protected function execute(InputInterface $input, OutputInterface $output): int

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $nameHtml = $articleCrawler->filter('h1.product-name');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $sellerHtml = $articleCrawler->filter('#j-store-info-wrap .store-lnk');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan

Call to method filter from undeclared class \Symfony\Component\DomCrawler\Crawler (Did you mean class \Sesame\Crawler\Crawler)
Open

        $priceCurrencyHtml = $articleCrawler->filter('.p-price-content .p-symbol');
Severity: Critical
Found in src/Sesame/Crawler/ArticleCrawler.php by phan
Severity
Category
Status
Source
Language