From b16e96a757ccee5be66fabb8e666823ca3cb558a Mon Sep 17 00:00:00 2001 From: Mauryan Kansara Date: Sun, 7 Jul 2024 23:34:03 +0530 Subject: [PATCH] supplemental: Replaced the older version of google java style guide with newer version and deleted unnecessary test class for Annotations section --- .../AnnotationLocationTest.java | 83 ------------------- .../indentation/CommentsIndentationCheck.java | 2 +- .../naming/AbbreviationAsWordInNameCheck.java | 2 +- .../indentation/CommentsIndentationCheck.xml | 2 +- .../naming/AbbreviationAsWordInNameCheck.xml | 2 +- src/xdocs/checks/misc/commentsindentation.xml | 2 +- .../misc/commentsindentation.xml.template | 2 +- .../naming/abbreviationaswordinname.xml | 2 +- .../abbreviationaswordinname.xml.template | 2 +- .../checks/naming/classtypeparametername.xml | 2 +- .../classtypeparametername.xml.template | 2 +- src/xdocs/google_style.xml | 66 +++++++-------- src/xdocs/index.xml.vm | 2 +- 13 files changed, 44 insertions(+), 127 deletions(-) delete mode 100644 src/it/java/com/google/checkstyle/test/chapter4formatting/rule485annotations/AnnotationLocationTest.java diff --git a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule485annotations/AnnotationLocationTest.java b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule485annotations/AnnotationLocationTest.java deleted file mode 100644 index e91ac726fe4..00000000000 --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule485annotations/AnnotationLocationTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////////// -// checkstyle: Checks Java source code and other text files for adherence to a set of rules. -// Copyright (C) 2001-2024 the original author or authors. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -/////////////////////////////////////////////////////////////////////////////////////////////// - -package com.google.checkstyle.test.chapter4formatting.rule485annotations; - -import org.junit.jupiter.api.Test; - -import com.google.checkstyle.test.base.AbstractGoogleModuleTestSupport; -import com.puppycrawl.tools.checkstyle.api.Configuration; -import com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck; - -public class AnnotationLocationTest extends AbstractGoogleModuleTestSupport { - - @Override - protected String getPackageLocation() { - return "com/google/checkstyle/test/chapter4formatting/rule485annotations"; - } - - @Test - public void testAnnotation() throws Exception { - final Class clazz = AnnotationLocationCheck.class; - getCheckMessage(clazz, "annotation.location.alone"); - final Configuration checkConfig = getModuleConfig("AnnotationLocation", - "AnnotationLocationMostCases"); - - final String msgLocationAlone = "annotation.location.alone"; - final String msgLocation = "annotation.location"; - final String[] expected = { - "3:16: " + getCheckMessage(clazz, msgLocationAlone, "MyAnnotation1"), - "20:9: " + getCheckMessage(clazz, msgLocation, "MyAnnotation1", "8", "4"), - "27:8: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "7", "4"), - "31:9: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "8", "4"), - "32:7: " + getCheckMessage(clazz, msgLocation, "MyAnnotation3", "6", "4"), - "33:11: " + getCheckMessage(clazz, msgLocation, "MyAnnotation4", "10", "4"), - "54:13: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "12", "8"), - "58:13: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "12", "8"), - "78:12: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "11", "8"), - "81:11: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "10", "8"), - "90:2: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "1", "0"), - "93:1: " + getCheckMessage(clazz, msgLocationAlone, "MyAnnotationWithParam"), - }; - - final String filePath = getPath("InputAnnotationLocation.java"); - - final Integer[] warnList = getLinesWithWarn(filePath); - verify(checkConfig, filePath, expected, warnList); - } - - @Test - public void testAnnotationVariables() throws Exception { - final Class clazz = AnnotationLocationCheck.class; - getCheckMessage(clazz, "annotation.location.alone"); - final Configuration checkConfig = getModuleConfig("AnnotationLocation", - "AnnotationLocationVariables"); - - final String msgLocation = "annotation.location"; - final String[] expected = { - "63:8: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "7", "4"), - }; - - final String filePath = getPath("InputAnnotationLocationVariables.java"); - - final Integer[] warnList = getLinesWithWarn(filePath); - verify(checkConfig, filePath, expected, warnList); - } - -} diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/CommentsIndentationCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/CommentsIndentationCheck.java index 0a423b82804..90a40d25615 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/CommentsIndentationCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/CommentsIndentationCheck.java @@ -35,7 +35,7 @@ * Controls the indentation between comments and surrounding code. * Comments are indented at the same level as the surrounding code. * Detailed info about such convention can be found - * + * * here *

*
    diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheck.java index 28e4fb63d8f..6f1f5779110 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheck.java @@ -37,7 +37,7 @@ *

    * Validates abbreviations (consecutive capital letters) length in * identifier name, it also allows to enforce camel case naming. Please read more at - * + * * Google Style Guide to get to know how to avoid long abbreviations in names. *

    *

    '_' is considered as word separator in identifier name.

    diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/indentation/CommentsIndentationCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/indentation/CommentsIndentationCheck.xml index ae4f3ad2dfc..48aceb61872 100644 --- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/indentation/CommentsIndentationCheck.xml +++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/indentation/CommentsIndentationCheck.xml @@ -8,7 +8,7 @@ Controls the indentation between comments and surrounding code. Comments are indented at the same level as the surrounding code. Detailed info about such convention can be found - <a href="https://checkstyle.org/styleguides/google-java-style-20180523/javaguide.html#s4.8.6.1-block-comment-style"> + <a href="https://checkstyle.org/styleguides/google-java-style-20220203/javaguide.html#s4.8.6.1-block-comment-style"> here</a> </p> diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/AbbreviationAsWordInNameCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/AbbreviationAsWordInNameCheck.xml index db101deb46b..d89d3d664bf 100644 --- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/AbbreviationAsWordInNameCheck.xml +++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/naming/AbbreviationAsWordInNameCheck.xml @@ -7,7 +7,7 @@ <p> Validates abbreviations (consecutive capital letters) length in identifier name, it also allows to enforce camel case naming. Please read more at - <a href="https://checkstyle.org/styleguides/google-java-style-20180523/javaguide.html#s5.3-camel-case"> + <a href="https://checkstyle.org/styleguides/google-java-style-20220203/javaguide.html#s5.3-camel-case"> Google Style Guide</a> to get to know how to avoid long abbreviations in names. </p> <p>'_' is considered as word separator in identifier name.</p> diff --git a/src/xdocs/checks/misc/commentsindentation.xml b/src/xdocs/checks/misc/commentsindentation.xml index b323640bb55..29baa8ee0a2 100644 --- a/src/xdocs/checks/misc/commentsindentation.xml +++ b/src/xdocs/checks/misc/commentsindentation.xml @@ -13,7 +13,7 @@ Controls the indentation between comments and surrounding code. Comments are indented at the same level as the surrounding code. Detailed info about such convention can be found - + here

    diff --git a/src/xdocs/checks/misc/commentsindentation.xml.template b/src/xdocs/checks/misc/commentsindentation.xml.template index b4c3ed3be9b..637eb6dc589 100644 --- a/src/xdocs/checks/misc/commentsindentation.xml.template +++ b/src/xdocs/checks/misc/commentsindentation.xml.template @@ -13,7 +13,7 @@ Controls the indentation between comments and surrounding code. Comments are indented at the same level as the surrounding code. Detailed info about such convention can be found - + here

    diff --git a/src/xdocs/checks/naming/abbreviationaswordinname.xml b/src/xdocs/checks/naming/abbreviationaswordinname.xml index 484e38dd8cd..4d06180a095 100644 --- a/src/xdocs/checks/naming/abbreviationaswordinname.xml +++ b/src/xdocs/checks/naming/abbreviationaswordinname.xml @@ -12,7 +12,7 @@

    Validates abbreviations (consecutive capital letters) length in identifier name, it also allows to enforce camel case naming. Please read more at - + Google Style Guide to get to know how to avoid long abbreviations in names.

    diff --git a/src/xdocs/checks/naming/abbreviationaswordinname.xml.template b/src/xdocs/checks/naming/abbreviationaswordinname.xml.template index ffd65a95850..0728b2cc0f4 100644 --- a/src/xdocs/checks/naming/abbreviationaswordinname.xml.template +++ b/src/xdocs/checks/naming/abbreviationaswordinname.xml.template @@ -12,7 +12,7 @@

    Validates abbreviations (consecutive capital letters) length in identifier name, it also allows to enforce camel case naming. Please read more at - + Google Style Guide to get to know how to avoid long abbreviations in names.

    diff --git a/src/xdocs/checks/naming/classtypeparametername.xml b/src/xdocs/checks/naming/classtypeparametername.xml index 76e224cc6ea..6b8c2dafd20 100644 --- a/src/xdocs/checks/naming/classtypeparametername.xml +++ b/src/xdocs/checks/naming/classtypeparametername.xml @@ -78,7 +78,7 @@ class Example2 {

    To configure the check for names that are camel case word with T as suffix - (Google Style): + (Google Style):

    <module name="Checker"> diff --git a/src/xdocs/checks/naming/classtypeparametername.xml.template b/src/xdocs/checks/naming/classtypeparametername.xml.template index 5030d4e4132..48f7fd6ae05 100644 --- a/src/xdocs/checks/naming/classtypeparametername.xml.template +++ b/src/xdocs/checks/naming/classtypeparametername.xml.template @@ -52,7 +52,7 @@

    To configure the check for names that are camel case word with T as suffix - (Google Style): + (Google Style):

    - + 1 Introduction @@ -110,7 +110,7 @@ - + 1.1 Terminology notes -- @@ -126,7 +126,7 @@ - + 1.2 Guide notes -- @@ -143,7 +143,7 @@ - + 2 Source file basics @@ -186,7 +186,7 @@ - + 2.2 File encoding: UTF-8 @@ -319,7 +319,7 @@ - + 3.1 License or copyright information, if present -- @@ -368,7 +368,7 @@ - + 3.3 Import statements @@ -473,7 +473,7 @@ - + 3.3.4 No static import for classes @@ -497,7 +497,7 @@ - + 3.4 Class declaration @@ -539,7 +539,7 @@ - + 3.4.2 Class member ordering -- @@ -592,7 +592,7 @@ - + 4 Formatting @@ -608,7 +608,7 @@ - + 4.1 Braces @@ -816,7 +816,7 @@ - + 4.5 Line-wrapping @@ -901,7 +901,7 @@ - + 4.6 Whitespace @@ -1041,7 +1041,7 @@ - + 4.6.3 Horizontal alignment: never required -- @@ -1056,7 +1056,7 @@ - + 4.7 Grouping parentheses: recommended -- @@ -1071,7 +1071,7 @@ - + 4.8 Specific constructs @@ -1087,7 +1087,7 @@ - + 4.8.1 Enum classes -- @@ -1102,7 +1102,7 @@ - + 4.8.2 Variable declarations ↓ @@ -1172,7 +1172,7 @@ - + 4.8.3 Arrays ↓ @@ -1187,7 +1187,7 @@ - + 4.8.3.1 Array initializers: can be "block-like" -- @@ -1228,7 +1228,7 @@ - + 4.8.4 Switch statements -- @@ -1453,7 +1453,7 @@ - + 4.8.6 Comments ↓ @@ -1548,7 +1548,7 @@ - + 5 Naming @@ -1564,7 +1564,7 @@ - + 5.1 Rules common to all identifiers "5.2 Rules of identifier type" already includes this rule. @@ -1580,7 +1580,7 @@ - + 5.2 Rules by identifier type @@ -1681,7 +1681,7 @@ - + 5.2.4 Constant names @@ -1883,7 +1883,7 @@ - + 5.3 Camel case: defined @@ -1916,7 +1916,7 @@ - + 6 Programming Practices @@ -1932,7 +1932,7 @@ - + 6.1 @Override: always used @@ -1986,7 +1986,7 @@ - + 6.3 Static members: qualified using class @@ -2035,7 +2035,7 @@ - + 7 Javadoc @@ -2051,7 +2051,7 @@ - + 7.1 Formatting diff --git a/src/xdocs/index.xml.vm b/src/xdocs/index.xml.vm index 89c315b6c13..8f943d49025 100644 --- a/src/xdocs/index.xml.vm +++ b/src/xdocs/index.xml.vm @@ -25,7 +25,7 @@ supporting the Sun Code Conventions, - + Google Java Style.