Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SlevomatCodingStandard.Namespaces.UnusedUses not supporting docblocks or inline comments #1671

Open
n8-dev opened this issue Mar 27, 2024 · 0 comments

Comments

@n8-dev
Copy link

n8-dev commented Mar 27, 2024

Take phpcs.xml of

<?xml version="1.0"?>
<ruleset name="foobar">
    <description>foo</description>

    <exclude-pattern>./vendor/*</exclude-pattern>
    <exclude-pattern>*/thirdparty/*</exclude-pattern>
    <arg value="p"/>
    <arg name="colors"/>
    <arg name="parallel" value="10"/>

    <rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
        <properties>
            <property name="searchAnnotations" type="bool" value="true"/>
            <property name="ignoredAnnotations" type="array">
                <element value="@config"/>
                <element value="@dataProvider"/>
            </property>
        </properties>
    </rule>
</ruleset>

And a file of

<?php

namespace App\Thing;

use App\Foo\Bar;
use App\Long\Path\Item;
use App\Long\Path\OtherItem;

/**
 * Blah blah @see Item::function()
 */
class MyClass
{
    
    /**
     * Lorem ipsum @see Bar::fizz()
     */
    public function doSomething(): bool
    {
        /** @see OtherItem::otherMethod() */
        return false;
    }
}

I am getting the following output...

FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------------------
 5 | ERROR | [x] Type App\Foo\Bar is not used in this file.
   |       |     (SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse)
 6 | ERROR | [x] App\Long\Path\Item is not used in this file.
   |       |     (SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse)
 10| ERROR | [x] App\Long\Path\OtherItem is not used in this file.
   |       |     (SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse)

Shouldn't those be caught by the searchAnnotations = true ?

@n8-dev n8-dev changed the title SlevomatCodingStandard.Namespaces.UnusedUses not supporting docblocks or inline comments SlevomatCodingStandard.Namespaces.UnusedUses not supporting docblocks or inline comments Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant