From c2ffb7f1812ab005915c110d1016137e1d2a6fb1 Mon Sep 17 00:00:00 2001 From: Gaurab Dasgupta Date: Wed, 24 Jun 2020 21:41:49 +0530 Subject: [PATCH] Issue #8328: Change name of checkstyle types to be close to real java types - enums --- .../annotation/AnnotationUseStyleCheck.java | 76 ++++++++++--------- .../checks/imports/ImportOrderCheck.java | 3 +- .../AnnotationUseStyleCheckTest.java | 24 +++--- .../checkstyle/internal/XdocsPagesTest.java | 51 +------------ src/xdocs/config.xml | 4 +- src/xdocs/config_annotation.xml | 43 ++++++----- src/xdocs/config_blocks.xml | 6 +- src/xdocs/config_filters.xml | 2 +- src/xdocs/config_imports.xml | 4 +- src/xdocs/config_javadoc.xml | 5 +- src/xdocs/config_misc.xml | 2 +- src/xdocs/config_whitespace.xml | 14 ++-- src/xdocs/property_types.xml | 28 +++---- 13 files changed, 111 insertions(+), 151 deletions(-) diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheck.java index 06755c3c61c..85740f8feed 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheck.java @@ -35,52 +35,54 @@ *

* *

- * To not enforce an element style a {@code ElementStyle.IGNORE} type is provided. + * To not enforce an element style a {@code ElementStyleOption.IGNORE} type is provided. * The desired style can be set through the {@code elementStyle} property. *

*

- * Using the {@code ElementStyle.EXPANDED} style is more verbose. + * Using the {@code ElementStyleOption.EXPANDED} style is more verbose. * The expanded version is sometimes referred to as "named parameters" in other languages. *

*

- * Using the {@code ElementStyle.COMPACT} style is less verbose. + * Using the {@code ElementStyleOption.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 {@code ElementStyle.COMPACT_NO_ARRAY} style is less verbose. - * It is similar to the {@code ElementStyle.COMPACT} style but single value arrays are flagged. + * Using the {@code ElementStyleOption.COMPACT_NO_ARRAY} style is less verbose. + * It is similar to the {@code ElementStyleOption.COMPACT} style but single value arrays are + * flagged. * With annotations a single value array does not need to be placed in an array initializer. *

*

* The ending parenthesis are optional when using annotations with no elements. - * To always require ending parenthesis use the {@code ClosingParens.ALWAYS} type. - * To never have ending parenthesis use the {@code ClosingParens.NEVER} type. - * To not enforce a closing parenthesis preference a {@code ClosingParens.IGNORE} type is provided. + * To always require ending parenthesis use the {@code ClosingParensOption.ALWAYS} type. + * To never have ending parenthesis use the {@code ClosingParensOption.NEVER} type. + * To not enforce a closing parenthesis preference a {@code ClosingParensOption.IGNORE} type is + * provided. * Set this through the {@code closingParens} property. *

*

* Annotations also allow you to specify arrays of elements in a standard format. * As with normal arrays, a trailing comma is optional. - * To always require a trailing comma use the {@code TrailingArrayComma.ALWAYS} type. - * To never have a trailing comma use the {@code TrailingArrayComma.NEVER} type. - * To not enforce a trailing array comma preference a {@code TrailingArrayComma.IGNORE} type + * To always require a trailing comma use the {@code TrailingArrayCommaOption.ALWAYS} type. + * To never have a trailing comma use the {@code TrailingArrayCommaOption.NEVER} type. + * To not enforce a trailing array comma preference a {@code TrailingArrayCommaOption.IGNORE} type * is provided. Set this through the {@code trailingArrayComma} property. *

*

- * By default the {@code ElementStyle} is set to {@code COMPACT_NO_ARRAY}, - * the {@code TrailingArrayComma} is set to {@code NEVER}, - * and the {@code ClosingParens} is set to {@code NEVER}. + * By default the {@code ElementStyleOption} is set to {@code COMPACT_NO_ARRAY}, + * the {@code TrailingArrayCommaOption} is set to {@code NEVER}, + * and the {@code ClosingParensOption} is set to {@code NEVER}. *

*

* According to the JLS, it is legal to include a trailing comma @@ -136,7 +138,7 @@ public final class AnnotationUseStyleCheck extends AbstractCheck { /** * Defines the styles for defining elements in an annotation. */ - public enum ElementStyle { + public enum ElementStyleOption { /** * Expanded example @@ -173,7 +175,7 @@ public enum ElementStyle { * elements in an annotation. * */ - public enum TrailingArrayComma { + public enum TrailingArrayCommaOption { /** * With comma example @@ -201,7 +203,7 @@ public enum TrailingArrayComma { * elements in an annotation. * */ - public enum ClosingParens { + public enum ClosingParensOption { /** * With parens example @@ -269,18 +271,18 @@ public enum ClosingParens { /** * Define the annotation element styles. */ - private ElementStyle elementStyle = ElementStyle.COMPACT_NO_ARRAY; + private ElementStyleOption elementStyle = ElementStyleOption.COMPACT_NO_ARRAY; // defaulting to NEVER because of the strange compiler behavior /** * Define the policy for trailing comma in arrays. */ - private TrailingArrayComma trailingArrayComma = TrailingArrayComma.NEVER; + private TrailingArrayCommaOption trailingArrayComma = TrailingArrayCommaOption.NEVER; /** * Define the policy for ending parenthesis. */ - private ClosingParens closingParens = ClosingParens.NEVER; + private ClosingParensOption closingParens = ClosingParensOption.NEVER; /** * Setter to define the annotation element styles. @@ -288,7 +290,7 @@ public enum ClosingParens { * @param style string representation */ public void setElementStyle(final String style) { - elementStyle = getOption(ElementStyle.class, style); + elementStyle = getOption(ElementStyleOption.class, style); } /** @@ -297,7 +299,7 @@ public void setElementStyle(final String style) { * @param comma string representation */ public void setTrailingArrayComma(final String comma) { - trailingArrayComma = getOption(TrailingArrayComma.class, comma); + trailingArrayComma = getOption(TrailingArrayCommaOption.class, comma); } /** @@ -306,7 +308,7 @@ public void setTrailingArrayComma(final String comma) { * @param parens string representation */ public void setClosingParens(final String parens) { - closingParens = getOption(ClosingParens.class, parens); + closingParens = getOption(ClosingParensOption.class, parens); } /** @@ -348,13 +350,13 @@ public int[] getAcceptableTokens() { @Override public void visitToken(final DetailAST ast) { checkStyleType(ast); - checkCheckClosingParens(ast); + checkCheckClosingParensOption(ast); checkTrailingComma(ast); } /** * Checks to see if the - * {@link ElementStyle AnnotationElementStyle} + * {@link ElementStyleOption AnnotationElementStyleOption} * is correct. * * @param annotation the annotation token @@ -386,7 +388,7 @@ private void checkExpandedStyle(final DetailAST annotation) { annotation.getChildCount(TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR); if (valuePairCount == 0 && hasArguments(annotation)) { - log(annotation, MSG_KEY_ANNOTATION_INCORRECT_STYLE, ElementStyle.EXPANDED); + log(annotation, MSG_KEY_ANNOTATION_INCORRECT_STYLE, ElementStyleOption.EXPANDED); } } @@ -419,7 +421,7 @@ private void checkCompactStyle(final DetailAST annotation) { && ANNOTATION_ELEMENT_SINGLE_NAME.equals( valuePair.getFirstChild().getText())) { log(annotation, MSG_KEY_ANNOTATION_INCORRECT_STYLE, - ElementStyle.COMPACT); + ElementStyleOption.COMPACT); } } @@ -436,7 +438,7 @@ private void checkCompactNoArrayStyle(final DetailAST annotation) { if (arrayInit != null && arrayInit.getChildCount(TokenTypes.EXPR) == 1) { log(annotation, MSG_KEY_ANNOTATION_INCORRECT_STYLE, - ElementStyle.COMPACT_NO_ARRAY); + ElementStyleOption.COMPACT_NO_ARRAY); } // in expanded style with pairs else { @@ -447,7 +449,7 @@ private void checkCompactNoArrayStyle(final DetailAST annotation) { if (nestedArrayInit != null && nestedArrayInit.getChildCount(TokenTypes.EXPR) == 1) { log(annotation, MSG_KEY_ANNOTATION_INCORRECT_STYLE, - ElementStyle.COMPACT_NO_ARRAY); + ElementStyleOption.COMPACT_NO_ARRAY); } ast = ast.getNextSibling(); } @@ -461,7 +463,7 @@ private void checkCompactNoArrayStyle(final DetailAST annotation) { * @param annotation the annotation token */ private void checkTrailingComma(final DetailAST annotation) { - if (trailingArrayComma != TrailingArrayComma.IGNORE) { + if (trailingArrayComma != TrailingArrayCommaOption.IGNORE) { DetailAST child = annotation.getFirstChild(); while (child != null) { @@ -494,7 +496,7 @@ private void logCommaViolation(final DetailAST ast) { // comma can be null if array is empty final DetailAST comma = rCurly.getPreviousSibling(); - if (trailingArrayComma == TrailingArrayComma.ALWAYS) { + if (trailingArrayComma == TrailingArrayCommaOption.ALWAYS) { if (comma == null || comma.getType() != TokenTypes.COMMA) { log(rCurly, MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING); } @@ -510,11 +512,11 @@ else if (comma != null && comma.getType() == TokenTypes.COMMA) { * * @param ast the annotation token */ - private void checkCheckClosingParens(final DetailAST ast) { - if (closingParens != ClosingParens.IGNORE) { + private void checkCheckClosingParensOption(final DetailAST ast) { + if (closingParens != ClosingParensOption.IGNORE) { final DetailAST paren = ast.getLastChild(); - if (closingParens == ClosingParens.ALWAYS) { + if (closingParens == ClosingParensOption.ALWAYS) { if (paren.getType() != TokenTypes.RPAREN) { log(ast, MSG_KEY_ANNOTATION_PARENS_MISSING); } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheck.java index 4cc073c2d38..0085242005b 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheck.java @@ -56,7 +56,8 @@ * *

  • * arrange static imports: ensures the relative order between type imports and static imports - * (see import orders) + * (see + * ImportOrderOption) *
  • * * @@ -1486,7 +1486,7 @@ import java.util.stream.IntStream; option specify policy on the relative order between type imports and static imports. - Import Order Policy + ImportOrderOption under 5.0 diff --git a/src/xdocs/config_javadoc.xml b/src/xdocs/config_javadoc.xml index 1255dab21f7..f7baf69f4d9 100644 --- a/src/xdocs/config_javadoc.xml +++ b/src/xdocs/config_javadoc.xml @@ -478,7 +478,8 @@ public void method(); location Specify the policy on placement of the Javadoc content. - Javadoc Content Location + + JavadocContentLocationOption second_line 8.27 @@ -3241,7 +3242,7 @@ public class TestClass { tagSeverity Specify the severity level when tag is found and printed. - Severity + SeverityLevel info 4.2 diff --git a/src/xdocs/config_misc.xml b/src/xdocs/config_misc.xml index 1d827df169d..4028332d281 100644 --- a/src/xdocs/config_misc.xml +++ b/src/xdocs/config_misc.xml @@ -1417,7 +1417,7 @@ StaticMethodCandidateCheck.name = Static Method Candidate lineSeparator Specify the type of line separator. - Line Separator Policy + LineSeparatorOption lf_cr_crlf 3.1 diff --git a/src/xdocs/config_whitespace.xml b/src/xdocs/config_whitespace.xml index 9985cbbd8aa..17267368948 100644 --- a/src/xdocs/config_whitespace.xml +++ b/src/xdocs/config_whitespace.xml @@ -51,7 +51,7 @@ for ( option Specify policy on how to pad an empty for iterator. - Pad Policy + PadOption nospace 3.4 @@ -148,7 +148,7 @@ for (Iterator foo = very.long.line.iterator(); option Specify policy on how to pad an empty for iterator. - Pad Policy + PadOption nospace 3.0 @@ -823,7 +823,7 @@ Pair<Integer, Integer > p; // violation, ">" preceded with whitespace option Specify policy on how to pad method parameter. - Pad Policy + PadOption nospace 3.4 @@ -1567,7 +1567,7 @@ Lists.charactersOf("foo") option Specify policy on how to wrap lines. - Wrap Operator Policy + WrapOption nl 3.0 @@ -1882,7 +1882,7 @@ class Test { option Specify policy on how to pad parentheses. - Pad Policy + PadOption nospace 3.0 @@ -2163,7 +2163,7 @@ try (Closeable resource = acquire(); ) // no check before right parenthesis option Specify policy on how to wrap lines. - Wrap Operator Policy + WrapOption eol 5.8 @@ -2508,7 +2508,7 @@ float f1; // OK, 1 whitespace option Specify policy on how to pad parentheses. - Pad Policy + PadOption nospace 3.2 diff --git a/src/xdocs/property_types.xml b/src/xdocs/property_types.xml index 83181ca4038..8c00685b1cf 100644 --- a/src/xdocs/property_types.xml +++ b/src/xdocs/property_types.xml @@ -126,7 +126,7 @@

    -
    +

    This type represents the policy for line returns. The following table describes the valid options: @@ -162,7 +162,7 @@

    -
    +

    This type represents the policy for padding with white space. The following table describes the valid options: @@ -191,7 +191,7 @@

    -
    +

    This type represents the policy for wrapping lines. The following table describes the valid options: @@ -231,7 +231,7 @@

    -
    +

    This type represents the policy for checking block statements. The following table describes the valid options: @@ -273,7 +273,7 @@

    -
    +

    This type represents the policy for checking the placement of a left curly brace ('{'). The following table @@ -343,7 +343,7 @@

    -
    +

    This type represents the policy for checking the placement of a right curly brace ('}') in blocks but not blocks of expressions. @@ -506,7 +506,7 @@

    -
    +

    This type represents the severity level of a check violation. The valid options are: @@ -520,14 +520,14 @@

    -
    +

    This type represents the policy for checking imports order. The following table describes the valid options:

    - +
    @@ -613,7 +613,7 @@ -
    +

    This type represents the policy for the styles for defining elements in an annotation. The following table @@ -699,7 +699,7 @@

    -
    +

    This type represents the policy for the styles for the ending parenthesis. The following table describes the valid options: @@ -742,7 +742,7 @@

    -
    +

    This type represents the policy for the styles for the trailing array comma. The following table describes the valid options: @@ -785,14 +785,14 @@

    -
    +

    This type represents policy on placement of the Javadoc content. The following table describes the valid options:

    -
    Option Definition
    +
    Option Definition