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 for ExcessivePublicCount #409

Closed
juliangut opened this Issue Nov 4, 2016 · 9 comments

Comments

Projects
None yet
2 participants
@juliangut

juliangut commented Nov 4, 2016

Warning suppression for ExcessivePublicCount doesn't seem to be working properly at least for static methods

/**
 * @SuppressWarnings(PHPMD.ExcessivePublicCount)
 */
class IntensivePublicStaticMethodClass
{
    public static function aMethod() {}
    public static function bMethod() {}
    public static function cMethod() {}
    public static function dMethod() {}
    public static function eMethod() {}
    ...
}

@ravage84 ravage84 added the Bug label Nov 4, 2016

@ravage84 ravage84 added this to the 2.5.0 milestone Nov 4, 2016

@ravage84

This comment has been minimized.

Member

ravage84 commented Nov 4, 2016

Have you tried TooManyPublicMethods instead?

@juliangut

This comment has been minimized.

juliangut commented Nov 4, 2016

Indeed it works @ravage84

Anyway shouldn't ExcessivePublicCount work as well? Maybe not in my case as this class only has public static methods and no attribute at all?

@ravage84

This comment has been minimized.

Member

ravage84 commented Nov 4, 2016

I guess it should and suppression should work, too.

Can you try to suppress everthing for testing?

/**
 * @SuppressWarnings(PHPMD)
 */
@juliangut

This comment has been minimized.

juliangut commented Nov 4, 2016

I tried and @SuppressWarnings(PHPMD) does suppress the warning

@ravage84

This comment has been minimized.

Member

ravage84 commented Nov 4, 2016

Odd, either the whole suppression does not work for you or something else is broken.
Can you try to replicate it on another machine etc.?

Try to suppress some other case, e.g. short variable name.

@juliangut

This comment has been minimized.

juliangut commented Nov 4, 2016

I've made a quick test class with lots of code smells to test the all this suppressions

/**
 * @SuppressWarnings(PHPMD)
 * @SuppressWarnings(PHPMD.UnusedPrivateField)
 * @SuppressWarnings(PHPMD.UnusedLocalVariable)
 * @SuppressWarnings(PHPMD.UnusedPrivateMethod)
 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
 * @SuppressWarnings(PHPMD.ShortVariable)
 * @SuppressWarnings(PHPMD.LongVariable)
 * @SuppressWarnings(PHPMD.ShortMethodName)
 * @SuppressWarnings(PHPMD.ConstantNamingConventions)
 * @SuppressWarnings(PHPMD.BooleanGetMethodName)
 * @SuppressWarnings(PHPMD.ExitExpression)
 * @SuppressWarnings(PHPMD.EvalExpression)
 * @SuppressWarnings(PHPMD.Superglobals)
 * @SuppressWarnings(PHPMD.CamelCaseClassName)
 * @SuppressWarnings(PHPMD.CamelCasePropertyName)
 * @SuppressWarnings(PHPMD.CamelCaseMethodName)
 * @SuppressWarnings(PHPMD.CamelCaseParameterName)
 * @SuppressWarnings(PHPMD.CamelCaseVariableName)
 * @SuppressWarnings(PHPMD.CyclomaticComplexity)
 * @SuppressWarnings(PHPMD.NPathComplexity)
 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
 * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
 * @SuppressWarnings(PHPMD.ExcessiveClassLength)
 * @SuppressWarnings(PHPMD.ExcessivePublicCount)
 * @SuppressWarnings(PHPMD.TooManyFields)
 * @SuppressWarnings(PHPMD.TooManyMethods)
 * @SuppressWarnings(PHPMD.TooManyPublicMethods)
 * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
 */

Among all of them the only one that doesn't suppress the warning is @SuppressWarnings(PHPMD.ExcessivePublicCount), don't think it has anything to do with my machine

@juliangut

This comment has been minimized.

juliangut commented Nov 23, 2016

An update. I've just tried with another project in several different machines and definitively @SuppressWarnings(PHPMD.ExcessivePublicCount) is not working

@ravage84

This comment has been minimized.

Member

ravage84 commented Nov 23, 2016

Thanks for the feedback.
Tried to track down the suppression code by looking at the classes. Didn't find anything.
I guess I will need to debug it.
Not sure when I have time for that.

@ravage84 ravage84 modified the milestones: 2.5.0, 2.6.0 Nov 24, 2016

@ravage84 ravage84 modified the milestones: 2.6.0, 2.7.0 Jan 30, 2017

@ravage84 ravage84 modified the milestones: 2.6.1, 2.7.0 Jun 3, 2017

@ravage84

This comment has been minimized.

Member

ravage84 commented Jun 14, 2017

Similar but not completyl same issue was mentioned in #493

eeree added a commit to eeree/phpmd that referenced this issue Jun 14, 2017

ravage84 added a commit that referenced this issue Jun 15, 2017

Merge pull request #495 from eeree/issue-409
SuppressWarnings for ExcessivePublicCount #409
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment