diff --git a/checkstyle_checks.xml b/checkstyle_checks.xml
index 87b29b5e9..3454f211d 100755
--- a/checkstyle_checks.xml
+++ b/checkstyle_checks.xml
@@ -164,11 +164,7 @@
elementStyle property.
*
closingParens property.
*
*
@@ -74,7 +74,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
* require a trailing comma use the {@link TrailingArrayComma#ALWAYS ALWAYS}
* type. To never have a trailing comma use the
* {@link TrailingArrayComma#NEVER NEVER} type. To not enforce a trailing
- * array comma preference a {@link TrailingArrayComma#MIXED MIXED} type
+ * array comma preference a {@link TrailingArrayComma#IGNORE IGNORE} type
* is provided. Set this through the trailingArrayComma property.
*
*
@@ -129,14 +129,14 @@ public final class AnnotationUseStyleCheck extends Check
//has more than one option type.
/** @see #setElementStyle(String) */
- private ElementStyle mStyle = ElementStyle.EXPANDED;
+ private ElementStyle mStyle = ElementStyle.COMPACT_NO_ARRAY;
//defaulting to NEVER because of the strange compiler behavior
/** @see #setTrailingArrayComma(String) */
private TrailingArrayComma mComma = TrailingArrayComma.NEVER;
/** @see #setClosingParans(String) */
- private ClosingParens mParens = ClosingParens.ALWAYS;
+ private ClosingParens mParens = ClosingParens.NEVER;
/**
* Sets the ElementStyle from a string.
@@ -230,7 +230,7 @@ public final class AnnotationUseStyleCheck extends Check
*/
private void checkStyleType(final DetailAST aAnnotation)
{
- if (ElementStyle.MIXED.equals(this.mStyle)
+ if (ElementStyle.IGNORE.equals(this.mStyle)
|| this.mStyle == null)
{
return;
@@ -337,7 +337,7 @@ public final class AnnotationUseStyleCheck extends Check
*/
private void checkTrailingComma(final DetailAST aAnnotation)
{
- if (TrailingArrayComma.MIXED.equals(this.mComma)
+ if (TrailingArrayComma.IGNORE.equals(this.mComma)
|| this.mComma == null)
{
return;
@@ -400,7 +400,7 @@ public final class AnnotationUseStyleCheck extends Check
*/
private void checkCheckClosingParens(final DetailAST aAST)
{
- if (ClosingParens.MIXED.equals(this.mParens)
+ if (ClosingParens.IGNORE.equals(this.mParens)
|| this.mParens == null)
{
return;
@@ -423,9 +423,7 @@ public final class AnnotationUseStyleCheck extends Check
}
/**
- * Defines the styles for defining
- * elements in an annotation.
- *
+ * Defines the styles for defining elements in an annotation.
* @author Travis Schneeberger
*/
public static enum ElementStyle {
@@ -456,7 +454,7 @@ public final class AnnotationUseStyleCheck extends Check
/**
* mixed styles.
*/
- MIXED,
+ IGNORE,
}
/**
@@ -484,7 +482,7 @@ public final class AnnotationUseStyleCheck extends Check
/**
* mixed styles.
*/
- MIXED,
+ IGNORE,
}
/**
@@ -512,6 +510,6 @@ public final class AnnotationUseStyleCheck extends Check
/**
* mixed styles.
*/
- MIXED,
+ IGNORE,
}
}
diff --git a/src/tests/com/puppycrawl/tools/checkstyle/AllCheckstyleTests.java b/src/tests/com/puppycrawl/tools/checkstyle/AllCheckstyleTests.java
index 1881955c9..cab2114a1 100644
--- a/src/tests/com/puppycrawl/tools/checkstyle/AllCheckstyleTests.java
+++ b/src/tests/com/puppycrawl/tools/checkstyle/AllCheckstyleTests.java
@@ -1,5 +1,7 @@
package com.puppycrawl.tools.checkstyle;
+import com.puppycrawl.tools.checkstyle.checks.annotation.AllAnnotationTests;
+
import com.puppycrawl.tools.checkstyle.api.AllApiTests;
import com.puppycrawl.tools.checkstyle.checks.AllChecksTests;
import com.puppycrawl.tools.checkstyle.checks.blocks.AllBlocksTests;
@@ -31,7 +33,7 @@ import org.junit.runners.Suite;
AllImportsTests.class, AllIndentationTests.class, AllJavadocTests.class,
AllMetricsTests.class, AllModifierTests.class, AllNamingTests.class,
AllSizesTests.class, AllWhitespaceTests.class, AllFilterTests.class,
- AllGrammarTests.class, AllRegexpTests.class})
+ AllGrammarTests.class, AllRegexpTests.class, AllAnnotationTests.class})
public class AllCheckstyleTests
{
}
diff --git a/src/tests/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleTest.java b/src/tests/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleTest.java
index 4feb93041..9abdb0172 100644
--- a/src/tests/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleTest.java
+++ b/src/tests/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleTest.java
@@ -18,8 +18,8 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
public void testParansAlways() throws Exception {
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
checkConfig.addAttribute("closingParens", "ALWAYS");
- checkConfig.addAttribute("elementStyle", "MIXED");
- checkConfig.addAttribute("trailingArrayComma", "MIXED");
+ checkConfig.addAttribute("elementStyle", "ignore");
+ checkConfig.addAttribute("trailingArrayComma", "ignore");
final String[] expected = {
"3: Annotation must have closing parenthesis.",
"18: Annotation must have closing parenthesis.",
@@ -37,8 +37,8 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
public void testParansNever() throws Exception {
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
checkConfig.addAttribute("closingParens", "NEVER");
- checkConfig.addAttribute("elementStyle", "MIXED");
- checkConfig.addAttribute("trailingArrayComma", "MIXED");
+ checkConfig.addAttribute("elementStyle", "ignore");
+ checkConfig.addAttribute("trailingArrayComma", "ignore");
final String[] expected = {
"13: Annotation cannot have closing parenthesis.",
"30: Annotation cannot have closing parenthesis.",
@@ -56,9 +56,9 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
public void testStyleExpanded() throws Exception {
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
- checkConfig.addAttribute("closingParens", "MIXED");
+ checkConfig.addAttribute("closingParens", "ignore");
checkConfig.addAttribute("elementStyle", "EXPANDED");
- checkConfig.addAttribute("trailingArrayComma", "MIXED");
+ checkConfig.addAttribute("trailingArrayComma", "ignore");
final String[] expected = {
"5: Annotation style must be 'EXPANDED'.",
"12: Annotation style must be 'EXPANDED'.",
@@ -79,9 +79,9 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
@Test
public void testStyleCompact() throws Exception {
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
- checkConfig.addAttribute("closingParens", "MIXED");
+ checkConfig.addAttribute("closingParens", "ignore");
checkConfig.addAttribute("elementStyle", "COMPACT");
- checkConfig.addAttribute("trailingArrayComma", "MIXED");
+ checkConfig.addAttribute("trailingArrayComma", "ignore");
final String[] expected = {
"43: Annotation style must be 'COMPACT'.",
"47: Annotation style must be 'COMPACT'.",
@@ -97,9 +97,9 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
@Test
public void testStyleCompactNoArray() throws Exception {
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
- checkConfig.addAttribute("closingParens", "MIXED");
+ checkConfig.addAttribute("closingParens", "ignore");
checkConfig.addAttribute("elementStyle", "COMPACT_NO_ARRAY");
- checkConfig.addAttribute("trailingArrayComma", "MIXED");
+ checkConfig.addAttribute("trailingArrayComma", "ignore");
final String[] expected = {
"5: Annotation style must be 'COMPACT_NO_ARRAY'.",
"20: Annotation style must be 'COMPACT_NO_ARRAY'.",
@@ -114,8 +114,8 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
@Test
public void testCommaAlwaysViolations() throws Exception {
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
- checkConfig.addAttribute("closingParens", "MIXED");
- checkConfig.addAttribute("elementStyle", "MIXED");
+ checkConfig.addAttribute("closingParens", "ignore");
+ checkConfig.addAttribute("elementStyle", "ignore");
checkConfig.addAttribute("trailingArrayComma", "ALWAYS");
final String[] expected = {
"3:20: Annotation array values must contain trailing comma.",
@@ -139,8 +139,8 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
@Test
public void testCommaAlwaysNoViolations() throws Exception {
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
- checkConfig.addAttribute("closingParens", "MIXED");
- checkConfig.addAttribute("elementStyle", "MIXED");
+ checkConfig.addAttribute("closingParens", "ignore");
+ checkConfig.addAttribute("elementStyle", "ignore");
checkConfig.addAttribute("trailingArrayComma", "ALWAYS");
final String[] expected = {
};
@@ -151,8 +151,8 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
@Test
public void testCommaNeverViolations() throws Exception {
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
- checkConfig.addAttribute("closingParens", "MIXED");
- checkConfig.addAttribute("elementStyle", "MIXED");
+ checkConfig.addAttribute("closingParens", "ignore");
+ checkConfig.addAttribute("elementStyle", "ignore");
checkConfig.addAttribute("trailingArrayComma", "NEVER");
final String[] expected = {
"9:32: Annotation array values cannot contain trailing comma.",
@@ -171,8 +171,8 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
@Test
public void testCommaNeverNoViolations() throws Exception {
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
- checkConfig.addAttribute("closingParens", "MIXED");
- checkConfig.addAttribute("elementStyle", "MIXED");
+ checkConfig.addAttribute("closingParens", "ignore");
+ checkConfig.addAttribute("elementStyle", "ignore");
checkConfig.addAttribute("trailingArrayComma", "NEVER");
final String[] expected = {
};
@@ -183,9 +183,9 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
@Test
public void testEverythingMixed() throws Exception {
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
- checkConfig.addAttribute("closingParens", "MIXED");
- checkConfig.addAttribute("elementStyle", "MIXED");
- checkConfig.addAttribute("trailingArrayComma", "MIXED");
+ checkConfig.addAttribute("closingParens", "ignore");
+ checkConfig.addAttribute("elementStyle", "ignore");
+ checkConfig.addAttribute("trailingArrayComma", "ignore");
final String[] expected = {
};
diff --git a/src/xdocs/config_annotations.xml b/src/xdocs/config_annotations.xml
index fac556a9c..084803dc9 100644
--- a/src/xdocs/config_annotations.xml
+++ b/src/xdocs/config_annotations.xml
@@ -22,104 +22,38 @@
- Annotations have three element styles starting with the - least verbose. -
- Using the - EXPANDED - style is more verbose. The expanded version is sometimes - referred to as "named parameters" in other languages. -
-- Using the - COMPACT - style is less verbose. This style can only be used when - there is an element called 'value' which is either the - sole element or all other elements have default values. -
-- Using the - COMPACT_NO_ARRAY - style is less verbose. It is similar to the - COMPACT - style but single value arrays are flagged. With - annotations a single value array does not need to be - placed in an array initializer. This style can only be - used when there is an element called 'value' which is - either the sole element or all other elements have - default values. + Defines the annotation element styles.
- To configure the check to enforce an EXPANDED style, with a - trailing array comma set to NEVER and always including the closing + To configure the check to enforce an + expanded style, with a + trailing array comma set to never + and always including the closing parenthesis.
Verifies that both the java.lang.Deprecated annotation is - present and the @deprecated javadoc tag is present when + present and the @deprecated Javadoc tag is present when either is present.
- This property represents the policy for checking entity beans - according to whether the beans have bean-managed persistence, - container-managed persistence, or mixed persistence: -
- -| Option | -Definition | -
| bean | -The beans have bean-managed persistence. | -
| container | -The beans have container-managed persistence. | -
| mixed | -- The beans have mixed bean-managed and container-managed - persistence. - | -
This property represents the policy for checking imports order. @@ -357,7 +324,7 @@
import static a.b.C.*;
import a.b.D;
@@ -405,5 +372,139 @@
+ This property represents the policy for the styles for defining + elements in an annotation. The following table + describes the valid options: +
+ +| Option | +Definition | +
| expanded | +
+ The expanded version is sometimes referred to as "named parameters"
+ in other languages. Example:
+ @SuppressWarnings(value={"unchecked","unused",})
+ |
+
| compact | +
+ This style can only be used when there is an element called 'value'
+ which is either the sole element or all other elements have default
+ values. Examples:
+ @SuppressWarnings({"unchecked","unused",})
+ and:
+ @SuppressWarnings("unchecked")
+ |
+
| compact_no_array | +
+ It is similar to the compact style but
+ single value arrays are flagged. With annotations a single value
+ array does not need to be placed in an array initializer.
+ This style can only be used when there is an element called 'value'
+ which is either the sole element or all other elements have
+ default values.
+ Example: @SuppressWarnings("unchecked")
+ |
+
| ignore | ++ Anything goes. + | +
+ This property represents the policy for the styles for the ending + parenthesis. The following table describes the valid options: +
+ +| Option | +Definition | +
| always | +
+ Example:
+ @Deprecated()+ |
+
| never | +
+ Example:
+ @Deprecated+ |
+
| ignore | ++ Anything goes. + | +
+ This property represents the policy for the styles for the trailing + array comma. The following table describes the valid options: +
+ +| Option | +Definition | +
| always | +
+ Example:
+ @SuppressWarnings(value={"unchecked","unused",})
+ |
+
| never | +
+ Example:
+ @SuppressWarnings(value={"unchecked","unused"})
+ |
+
| ignore | ++ Anything goes. + | +