[ checkstyle-Feature Requests-3557394 ] ParameterNumber check after an @Override

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[ checkstyle-Feature Requests-3557394 ] ParameterNumber check after an @Override

Feature Requests item #3557394, was opened at 2012-08-14 06:02
Message generated for change (Tracker Item Submitted) made by nanor05
You can respond by visiting:

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Check
Group: None
Status: Open
Priority: 5
Private: No
Submitted By: Ronan (nanor05)
Assigned to: Nobody/Anonymous (nobody)
Summary: ParameterNumber check after an @Override

Initial Comment:
Hi everyone,

(Initially this was a question asked on the mailing list, see https://sourceforge.net/mailarchive/message.php?msg_id=29660441)

I am using a rule for the parameter number. Nevertheless, I sometimes have to override some methods (in Swing, for example). Those methods may have more parameters than what the rule is configured to allow. I would like this rule to be ignored when applied to an overridden method.

I have looked at suppression filters, but they work either with a configuration file (that you need to maintain) or keywords in the code (which makes you add to your files, text for a specific tool).

Trying to write a custom filter, for what I have understood, it seems to allow reaching text and the lines of it, but you do not have access to a structure as you have in a check. I was worried that using some kind of text regexp on a line would be brittle.

Thus I have written a custom check, inheriting from ParameterNumberCheck class. But I would rather rely on something existing in checkstyle natively.

public class ParameterNumberCheckCustom extends ParameterNumberCheck {

  public void visitToken(DetailAST ast) {
    // if you override a method, you have no power over the (too numerous)
    // number of parameters.
    if (!AnnotationUtility.containsAnnotation(ast, "Override")) {
    } else {
      final String message = "@Override found, skipping ParameterNumber check.";

What do you think? Would some kind of filter be a better idea? What about a parameter for the existing ParameterNumberCheck class?



You can respond by visiting:

Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Checkstyle-devel mailing list
[hidden email]