SuppressWarnings for ExcessivePublicCount #409

juliangut opened this Issue Nov 4, 2016 · 8 comments


None yet

2 participants


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 commented Nov 4, 2016

Have you tried TooManyPublicMethods instead?


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 commented Nov 4, 2016

I guess it should and suppression should work, too.

Can you try to suppress everthing for testing?

 * @SuppressWarnings(PHPMD)

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

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.


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


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


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 milestone: 2.5.0, 2.6.0 Nov 24, 2016
@ravage84 ravage84 modified the milestone: 2.6.0, 2.7.0 Jan 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment