Merge branch 'pr-748'

This commit is contained in:
Andreas Dangel
2017-11-23 21:27:41 +01:00
3 changed files with 21 additions and 3 deletions

View File

@ -249,6 +249,9 @@ The rule reference documentation has been updated to reflect these changes.
* `accessorCommentRequirement` to specify documentation requirements for getters and setters (default to `ignored`)
* `methodWithOverrideCommentRequirement` to specify documentation requirements for methods annotated with `@Override` (default to `ignored`)
* The Java rule `EmptyCatchBlock` (category `errorprone`, former ruleset `java-empty`) has been changed to ignore
exceptions named `ignore` or `expected` by default. You can still override this behaviour by setting the `allowExceptionNameRegex` property.
#### Deprecated Rules
* The Java rules `NcssConstructorCount`, `NcssMethodCount`, and `NcssTypeCount` (ruleset `java-codesize`) have been

View File

@ -1379,7 +1379,7 @@ or reported.
</value>
</property>
<property name="allowCommentedBlocks" type="Boolean" description="Empty blocks containing comments will be skipped" value="false"/>
<property name="allowExceptionNameRegex" type="String" description="Empty blocks catching exceptions with names matching this regular expression will be skipped" value="^$"/>
<property name="allowExceptionNameRegex" type="String" description="Empty blocks catching exceptions with names matching this regular expression will be skipped" value="^(ignored|expected)$"/>
</properties>
<example>
<![CDATA[

View File

@ -172,9 +172,8 @@ Javadoc comment is not OK
<!-- END Commented blocks -->
<test-code>
<description><![CDATA[
Allow to ignore exceptions by name
Exceptions named "ignored" and "expected" are ignored by default
]]></description>
<rule-property name="allowExceptionNameRegex">^(ignored|expected)$</rule-property>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
@ -184,6 +183,22 @@ public class Foo {
} catch (IllegalArgumentException ignored) {
}
}
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
Allow to ignore exceptions by name
]]></description>
<rule-property name="allowExceptionNameRegex">^idontcare$</rule-property>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
void foo() {
try {
} catch (NullPointerException idontcare) {
}
}
}
]]></code>
</test-code>