Skip to content

Commit c2fe3c4

Browse files
DakshRJain737romani
authored andcommitted
Issue #17681: Fix multiple blank line separation
1 parent e23179b commit c2fe3c4

13 files changed

Lines changed: 91 additions & 10 deletions

File tree

config/google-java-format/excluded/compilable-input-paths.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ src/it/resources/com/google/checkstyle/test/chapter4formatting/rule451wheretobre
3838
src/it/resources/com/google/checkstyle/test/chapter4formatting/rule451wheretobreak/InputNoWrappingAfterRecordName2.java
3939
src/it/resources/com/google/checkstyle/test/chapter4formatting/rule452indentcontinuationlines/InputClassWithChainedMethods2.java
4040
src/it/resources/com/google/checkstyle/test/chapter4formatting/rule461verticalwhitespace/InputVerticalWhitespace.java
41+
src/it/resources/com/google/checkstyle/test/chapter4formatting/rule461verticalwhitespace/InputEmptyLineSeparator3.java
4142
src/it/resources/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/InputWhitespaceAroundBasic.java
4243
src/it/resources/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/InputWhitespaceAfterBad.java
4344
src/it/resources/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/InputWhitespaceAfterGood.java

src/it/resources/com/google/checkstyle/test/chapter3filestructure/rule333orderingandspacing/InputOrderingAndSpacing4.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import com.google.common.reflect.Invokable;
1313
import java.util.List;
1414

15-
1615
import java.util.StringTokenizer;
1716
// violation above 'Extra separation in import group before 'java.util.StringTokenizer''
1817

src/it/resources/com/google/checkstyle/test/chapter3filestructure/rule333orderingandspacing/InputOrderingAndSpacing5.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import static java.io.File.createTempFile;
55
// comments
66

7-
87
// comments
98
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
109
// violation above 'Extra separation .* before 'javax.swing.WindowConstants.DISPOSE_ON_CLOSE''

src/it/resources/com/google/checkstyle/test/chapter3filestructure/rule333orderingandspacing/InputOrderingAndSpacingValid.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.google.checkstyle.test.chapter3filestructure.rule333orderingandspacing;
22

3-
// it is not forbidden to have extra lines (more than one) between package and import group
4-
5-
63
import static com.puppycrawl.tools.checkstyle.utils.AnnotationUtil.containsAnnotation;
74
import static com.puppycrawl.tools.checkstyle.utils.AnnotationUtil.getAnnotation;
85

src/it/resources/com/google/checkstyle/test/chapter4formatting/rule43onestatement/InputOneStatementPerLine.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,13 @@ private void foo2() {
242242
// 'Only one statement per line allowed.'
243243
}
244244

245-
246245
/**
247246
* While theoretically being distributed over two lines, this is a sample
248247
* of 2 statements on one line.
249248
*/
250249
int var9 = 1, var10 = 5 // violation 'Each variable declaration must be in its own statement.'
251250
; int var11 = 2; // violation 'Only one statement per line allowed.'
252251

253-
254252
/**
255253
* Multiline for loop statement is legal.
256254
*/
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
EmptyLineSeparator
3+
allowNoEmptyLineBetweenFields = (default)false
4+
allowMultipleEmptyLines = false
5+
allowMultipleEmptyLinesInsideClassMembers = (default)true
6+
tokens = (default)PACKAGE_DEF, IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF, \
7+
STATIC_INIT, INSTANCE_INIT, METHOD_DEF, CTOR_DEF, VARIABLE_DEF, RECORD_DEF, \
8+
COMPACT_CTOR_DEF
9+
10+
11+
*/
12+
13+
14+
15+
16+
package com.google.checkstyle.test.chapter4formatting.rule461verticalwhitespace; //violation ''package' has more than 1 empty lines before'
17+
18+
19+
20+
21+
public class InputEmptyLineSeparator3 {
22+
// violation above ''CLASS_DEF' has more than 1 empty lines before.'
23+
24+
25+
String s = "Hello"; // violation ''VARIABLE_DEF' has more than 1 empty lines before.'
26+
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
EmptyLineSeparator
3+
allowNoEmptyLineBetweenFields = (default)false
4+
allowMultipleEmptyLines = false
5+
allowMultipleEmptyLinesInsideClassMembers = (default)true
6+
tokens = (default)PACKAGE_DEF, IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF, \
7+
STATIC_INIT, INSTANCE_INIT, METHOD_DEF, CTOR_DEF, VARIABLE_DEF, RECORD_DEF, \
8+
COMPACT_CTOR_DEF
9+
10+
11+
*/
12+
13+
package com.google.checkstyle.test.chapter4formatting.rule461verticalwhitespace;
14+
15+
// violation above ''package' has more than 1 empty lines before.'
16+
17+
public class InputFormattedEmptyLineSeparator3 {
18+
// violation above ''CLASS_DEF' has more than 1 empty lines before.'
19+
20+
String s = "Hello"; // violation ''VARIABLE_DEF' has more than 1 empty lines before.'
21+
}

src/it/resources/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/InputNoWhitespaceBeforeEllipsis.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.lang.annotation.ElementType;
44
import java.lang.annotation.Target;
55

6-
6+
//
77
/** some javadoc. */
88
public class InputNoWhitespaceBeforeEllipsis {
99

src/it/resources/com/google/checkstyle/test/chapter4formatting/rule487modifiers/InputModifierOrder.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ strictfp private void doStuff() {}
4949
// violation below ''static' modifier out of order with the JLS suggestions.'
5050
@MyAnnotation2 strictfp static final synchronized private void fooMethod4() {}
5151

52-
5352
// violation below ''final' modifier out of order with the JLS suggestions.'
5453
synchronized final strictfp @MyAnnotation2 static public void fooMethod5() {}
5554

src/it/resources/com/google/checkstyle/test/chapter5naming/rule522classnames/InputClassNames.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class $NoValidName {}
2323
class NoValidName$ {}
2424
// violation above 'Type name 'NoValidName\$' must match pattern'
2525

26-
2726
class ValidName {}
2827

2928
class _ValidName {} // violation 'Type name '_ValidName' must match pattern'

0 commit comments

Comments
 (0)