incubator-jspwiki-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "van Dalen, Andre" <andre.van.da...@atos.net>
Subject RE: Sonar complaint: declaring unchecked exceptions in the throws clause
Date Fri, 19 Jul 2013 11:25:54 GMT
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:glen.mazza@gmail.com] 
Sent: 18 July 2013 22:54
To: jspwiki-dev@incubator.apache.org
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

Mime
View raw message