incubator-jspwiki-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glen Mazza <glen.ma...@gmail.com>
Subject Sonar complaint: declaring unchecked exceptions in the throws clause
Date Thu, 18 Jul 2013 20:53:43 GMT
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