-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #14911: Added a new section 4.8.5.3 in google style guide imple…
…mentation
- Loading branch information
Showing
5 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...ting/rule4853methodsandconstructorsannotations/MethodsAndConstructorsAnnotationsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/////////////////////////////////////////////////////////////////////////////////////////////// | ||
// 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.rule4853methodsandconstructorsannotations; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import com.google.checkstyle.test.base.AbstractGoogleModuleTestSupport; | ||
|
||
public class MethodsAndConstructorsAnnotationsTest extends AbstractGoogleModuleTestSupport { | ||
|
||
@Override | ||
protected String getPackageLocation() { | ||
return "com/google/checkstyle/test/chapter4formatting/" | ||
+ "rule4853methodsandconstructorsannotations"; | ||
} | ||
|
||
@Test | ||
public void testAnnotation() throws Exception { | ||
final String filePath = getPath("InputMethodsAndConstructorsAnnotations.java"); | ||
|
||
final String[] listOfModules = { | ||
"AnnotationLocationMostCases", | ||
"InvalidJavadocPosition", | ||
}; | ||
|
||
verifyWithGoogleConfigParser(listOfModules, filePath); | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
...ing/rule4853methodsandconstructorsannotations/InputMethodsAndConstructorsAnnotations.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.google.checkstyle.test.chapter4formatting.rule4853methodsandconstructorsannotations; | ||
|
||
public class InputMethodsAndConstructorsAnnotations { | ||
public @interface SomeAnnotation1 { } | ||
|
||
public @interface SomeAnnotation2 { } | ||
|
||
// ********testing methods.*********** | ||
|
||
/** | ||
* testing. | ||
*/ | ||
@SomeAnnotation1 | ||
@SomeAnnotation2 | ||
void test1() {} | ||
|
||
/** | ||
* testing. | ||
*/ | ||
@SomeAnnotation1 void test2() {} | ||
|
||
/** | ||
* testing. | ||
*/ | ||
@SomeAnnotation1 @SomeAnnotation2 | ||
// violation above 'Annotation 'SomeAnnotation2' should be alone on line.' | ||
void test3() {} | ||
|
||
@SomeAnnotation1 | ||
@SomeAnnotation2 | ||
/** // violation 'Javadoc comment is placed in the wrong location.' | ||
* testing. | ||
*/ | ||
void test4() {} | ||
|
||
@SomeAnnotation1 @SomeAnnotation2 | ||
// violation above 'Annotation 'SomeAnnotation2' should be alone on line.' | ||
/** // violation 'Javadoc comment is placed in the wrong location.' | ||
* testing. | ||
*/ | ||
void test5() {} | ||
|
||
@SomeAnnotation1 @SomeAnnotation2 void test6() {} | ||
// violation above 'Annotation 'SomeAnnotation2' should be alone on line.' | ||
|
||
@SuppressWarnings("all") void test7() {} | ||
// violation above 'Annotation 'SuppressWarnings' should be alone on line.' | ||
|
||
// ********testing constructors.********* | ||
|
||
/** | ||
* testing. | ||
*/ | ||
@SomeAnnotation1 | ||
@SomeAnnotation2 | ||
InputMethodsAndConstructorsAnnotations() {} | ||
|
||
/** | ||
* testing. | ||
*/ | ||
@SomeAnnotation1 InputMethodsAndConstructorsAnnotations(float f) {} | ||
|
||
/** | ||
* testing. | ||
*/ | ||
@SomeAnnotation1 @SomeAnnotation2 | ||
// violation above 'Annotation 'SomeAnnotation2' should be alone on line.' | ||
InputMethodsAndConstructorsAnnotations(int x) {} | ||
|
||
@SomeAnnotation1 | ||
@SomeAnnotation2 | ||
/** // violation 'Javadoc comment is placed in the wrong location.' | ||
* testing. | ||
*/ | ||
InputMethodsAndConstructorsAnnotations(String str) {} | ||
|
||
@SomeAnnotation1 @SomeAnnotation2 | ||
// violation above 'Annotation 'SomeAnnotation2' should be alone on line.' | ||
/** // violation 'Javadoc comment is placed in the wrong location.' | ||
* testing. | ||
*/ | ||
InputMethodsAndConstructorsAnnotations(double d) {} | ||
|
||
@SomeAnnotation1 @SomeAnnotation2 InputMethodsAndConstructorsAnnotations(String a, | ||
String b) {} | ||
// violation 2 lines above 'Annotation 'SomeAnnotation2' should be alone on line.' | ||
|
||
@SuppressWarnings("all") InputMethodsAndConstructorsAnnotations(int x, int y) {} | ||
// violation above 'Annotation 'SuppressWarnings' should be alone on line.' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters