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

@SuppressWarnings("design") not work? #513

Open
MichalJanicki opened this Issue Aug 15, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@MichalJanicki

MichalJanicki commented Aug 15, 2017

Hi,

I have one question about SuppressWarnings. In manual is written that to suppress all warnings from rule set just add such annotation @SuppressWarnings("unused").

I have that class (code below) and when add annotatyion @SuppressWarnings("unused") and run command php vendor/bin/phpmd ./../code/test/ text unusedcode,design i get the following result:

/code/test/test.php:18 The method useEval() contains an eval expression.

So everything is ok but when i replace in annotation "unused" to "design" and run command php vendor/bin/phpmd ./../code/test/ text unusedcode,design i get:

/code/test/test.php:10	Avoid unused private fields such as '$unusedPrivateField'.
/code/test/test.php:12	Avoid unused parameters such as '$unusedFormalParameter'.
/code/test/test.php:14	Avoid unused local variables such as '$unusedLocalVariable'.
/code/test/test.php:16	Avoid unused private methods such as 'useEval'.
/code/test/test.php:18	The method useEval() contains an eval expression.

The question is: SuppressWarnings not working for design role set (so it is bug)? Or maybe I'm doing something wrong?

Applies to PHPMD ver 2.6

Test class:

<?php

/**
 *
 * @SuppressWarnings("design")
 */

class Bar {

    private $unusedPrivateField = 42;

    public function foo($unusedFormalParameter = 23)
    {
        $unusedLocalVariable = 17;
    }
    private function useEval()
    {
        eval("echo 'eval'");
    }
}
@ravage84

This comment has been minimized.

Show comment
Hide comment
@ravage84

ravage84 Aug 16, 2017

Member

We got reports that the suppression dos not work in all cases, recently. It might be a bug. Thanks for reporting, e.g. #510

Member

ravage84 commented Aug 16, 2017

We got reports that the suppression dos not work in all cases, recently. It might be a bug. Thanks for reporting, e.g. #510

@ravage84 ravage84 added the Bug label Aug 16, 2017

@ravage84 ravage84 added this to the 2.6.1 milestone Aug 16, 2017

@ravage84

This comment has been minimized.

Show comment
Hide comment
@ravage84

ravage84 Oct 12, 2017

Member

Could be connected to #522

Member

ravage84 commented Oct 12, 2017

Could be connected to #522

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment