-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: formatter no longer adds whitespace to blank lines #800
Merged
bulldozer-bot
merged 10 commits into
develop
from
ds/dont-add-whitespace-to-blank-lines
Sep 11, 2019
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
502a408
Don't add whitespace to blank lines
dansanduleac 761c98c
Add generated changelog entries
dansanduleac bb2e0b8
actually that one is not necessary
dansanduleac 8c884c4
move those back
dansanduleac 8444023
not failing test...
dansanduleac 061dff6
simplofy
dansanduleac 2439daa
use files to ensure whitespace is not being trimmed by stripIndent / …
dansanduleac 3af86ab
Make test verify that blank lines are removed from comments
dansanduleac 259e2b6
test is finally failing
dansanduleac e33fee4
apply trim whitespace last
dansanduleac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type: fix | ||
fix: | ||
description: 'Don''t add whitespace to blank lines inside comments. Fixes #799' | ||
links: | ||
- https://github.com/palantir/gradle-baseline/pull/800 |
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 |
---|---|---|
|
@@ -52,11 +52,12 @@ public void apply(Project project) { | |
java.removeUnusedImports(); | ||
// use empty string to specify one group for all non-static imports | ||
java.importOrder(""); | ||
java.trimTrailingWhitespace(); | ||
|
||
if (eclipseFormattingEnabled(project)) { | ||
java.eclipse().configFile(project.file(eclipseXml.toString())); | ||
} | ||
|
||
java.trimTrailingWhitespace(); | ||
}); | ||
|
||
// necessary because SpotlessPlugin creates tasks in an afterEvaluate block | ||
|
@@ -65,7 +66,7 @@ public void apply(Project project) { | |
Task spotlessJava = project.getTasks().getByName("spotlessJava"); | ||
Task spotlessApply = project.getTasks().getByName("spotlessApply"); | ||
if (eclipseFormattingEnabled(project) && !Files.exists(eclipseXml)) { | ||
spotlessJava.dependsOn(project.getTasks().findByPath(":baselineUpdateConfig")); | ||
spotlessJava.dependsOn(":baselineUpdateConfig"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is just style - no need to resolve the actual task ourselves since dependsOn takes a string |
||
} | ||
formatTask.dependsOn(spotlessApply); | ||
project.getTasks().withType(JavaCompile.class).configureEach(spotlessJava::mustRunAfter); | ||
|
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
19 changes: 19 additions & 0 deletions
19
...baseline-java/src/test/resources/com/palantir/baseline/blank-lines-in-comments-fixed.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,19 @@ | ||
package test; | ||
|
||
public class Test { | ||
/** | ||
Docstring that looks like a list: | ||
|
||
1. hey | ||
2. there | ||
|
||
with blank line. | ||
*/ | ||
Void test() { | ||
/* | ||
Normal comment | ||
|
||
with blank line. | ||
*/ | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
gradle-baseline-java/src/test/resources/com/palantir/baseline/blank-lines-in-comments.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,19 @@ | ||
package test; | ||
|
||
public class Test { | ||
/** | ||
Docstring that looks like a list: | ||
|
||
1. hey | ||
2. there | ||
|
||
with blank line. | ||
*/ | ||
Void test() { | ||
/* | ||
Normal comment | ||
|
||
with blank line. | ||
*/ | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is gonna be different in an IDE vs from gradlew??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, but formatting from within Intellij didn't produce the whitespace. I suspect that's due to how IntelliJ automatically trims trailing whitespace upon saving.