According to this post, 
http://stackoverflow.com/questions/10971968/turning-sonar-off-for-certain-code,
you can either use the FindBugs annotations or use // NOSONAR on the line where 
you want to suppress a warning.

JSPWiki is a WebApp to some users, but to people developing their own plugins 
and extensions the JSPWiki engine
is an API too :-)

        regards, Andre

-----Original Message-----
From: Glen Mazza [mailto:[email protected]] 
Sent: 19 July 2013 22:11
To: [email protected]
Subject: Re: Sonar complaint: declaring unchecked exceptions in the throws 
clause


I don't think there are such things as annotations to quiet Sonar -- instead, 
you just disable the test. The question is whether to limit the documentation 
to just the JavaDoc or explicitly include them in the Throws clause.  I think 
the Javadocs are sufficient--that's all the java.lang.String you mention is 
doing apparently.  JSPWiki is not exactly an API that people are coding with, 
it's just a webapp.

Glen

On 07/19/2013 07:25 AM, van Dalen, Andre wrote:
> Hi Glen,
>
> I would have Sonar ignore these warnings, and see if it is possible to 
> annotate the source with a suppression
> for the cases that are checked and deemed a correct use of an unchecked 
> exception.
> After that the Sonar warning can be enabled again. For library-type methods 
> unchecked exceptions are the norm imho
> (look at the String javadoc). As you say, the exceptions that are thrown 
> should document themselves so removing
> the throw clauses from code and javadoc is not the way to go.
>
>       regards, Andre
>
> -----Original Message-----
> From: Glen Mazza [mailto:[email protected]]
> Sent: 18 July 2013 22:54
> To: [email protected]
> Subject: Sonar complaint: declaring unchecked exceptions in the throws clause
>
>
> Hi Team, in 40-44 cases (which isn't all that much), Sonar is reporting that 
> we're unnecessarily declaring unchecked (Runtime-derived) exceptions such as 
> MissingResourceException and IllegalArgumentException in the "throws" clause, 
> as listed here:
>
> https://analysis.apache.org/drilldown/issues/139724?&rule=checkstyle%3Acom.puppycrawl.tools.checkstyle.checks.coding.RedundantThrowsCheck&rule_sev=MINOR&severity=MINOR#
> (click on TextUtil, InternationalizationManager in the lower-right corner).
>
> These can be kind of nice because it becomes better self-documenting that 
> way, although prevailing opinion[1] seems to be that RuntimeExceptions should 
> be those outside of anybody's control, and checked (must declare in the 
> throws clause) exceptions should be used instead when the exception is 
> something somebody can do something about.
>
> What I'd like to do is remove them from the "throws" clause--quieting 
> Sonar--but keep them in the Javadoc above, so they're still documented.
> (Alternatively, what I can do is disable this check--have Sonar ignore
> it.)  Later, for these exceptions, we may wish to move to checked exceptions 
> if any of these are something a developer do something about, while leaving 
> IllegalArgumentException, etc., for programming errors outside of any user's 
> control.  WDYT?
>
> Thanks,
> Glen
>
> [1] http://docs.oracle.com/javase/tutorial/essential/exceptions/runtime.html

Reply via email to