Re: ParameterNumber check after an @Override

Ronan DANIELLOU <[email protected]> Tue, 14 Aug 2012 15:04:59 +0200
Newsgroups gmane.comp.java.audit.checkstyle.user
Organization Alcatel-Lucent
Message-ID <[email protected]>
Hello Peter,

thanks for your answer.

As a matter of facts, I made it work using inheritance:

public class ParameterNumberCheckCustom extends ParameterNumberCheck {

   @Override
   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")) {
       super.visitToken(ast);
     } else {
       final String message =3D "@Override found, skipping ParameterNumber =

check.";
       System.out.println(message);
     }
   }
}

My concern about maintaining it was not so much about checkstyle by =

itself, but more about the checkstyle plugin for eclipse, which adds XML =

metadata files and other stuff on top of raw checkstyle jar for =

including it in Eclipse.

And as always this kind of small stuff may add one to another in your =

project and in the end you spend too much time taking care of small =

maintenance tasks.

Thus I would rather rely on something existing in checkstyle, and =

hopefully which will then exist in checkstyle plugin for eclipse later.

Feature request has been added:
https://sourceforge.net/tracker/?func=3Ddetail&aid=3D3557394&group_id=3D297=
21&atid=3D397081

Thanks,

R.

Le 13/08/2012 14:08, Wippermann, Peter, Vodafone DE a =E9crit :
> Hi Ronan,
>
> Very good idea, I really encourage you to submit this as a feature reques=
t! You could attach your sources to speed up things a little bit ;-)
>
> Regarding the maintenance of your custom check: It depends on your implem=
entation how much effort has to be put into maintenance.
> Did you implement your custom check as a delegation to the original check=
? I mean something like this: http://en.wikipedia.org/wiki/Delegation_patte=
rn#Simple
> In that case all updates to the original check would become active in you=
r check without the need to build and deliver your custom class again.
>
> Best regards,
> Peter Wippermann
>
> P.S. I find it quite interesting how many users, who publish on this list=
, are actually from the TelCo (or associated) business! :-)
>
>
>
> -----Urspr=FCngliche Nachricht-----
> Von: Ronan DANIELLOU [mailto:[email protected]]
> Gesendet: Freitag, 10. August 2012 17:58
> An: [email protected]
> Betreff: [Checkstyle-user] ParameterNumber check after an @Override
>
> Hi everyone,
>
> I am using a rule for the parameter number. Nevertheless, I sometimes hav=
e 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 thi=
s rule to be ignored when applied to an overridden method.
>
> Does it make sense? If so, how may I do this? I have looked at suppressio=
n 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 st=
ructure 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. This works. But I would have to maintain it in my project locally fo=
r future checkstyle releases.
>
> Thus, is there another better way to do it?
> Do you think this request should become a feature request?
>
> Thanks.
>
> R.
>
> -------------------------------------------------------------------------=
-----
> 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 inc=
lude endpoint security, mobile security and the latest in malware threats. =
http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Checkstyle-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/checkstyle-user
>
> -------------------------------------------------------------------------=
-----
> 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-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/checkstyle-user
>

-- =

Ronan DANIELLOU
Alcatel-Lucent Submarine Networks
Software engineer
Centre de Villarceaux
Route de Villejust
Bureau: S 1.067
91620 NOZAY
France
Phone: +33 1 3077 2757
E-mail: [email protected]

---------------------------------------------------------------------------=
---
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/