Skip to content

Commit ea04858

Browse files
author
Vincent Potucek
committed
[openrewrite] NoWhitespaceBefore
1 parent c997379 commit ea04858

File tree

150 files changed

+461
-512
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+461
-512
lines changed

.github/workflows/claude.yml

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,74 +5,62 @@ on:
55
types: [created]
66
pull_request_review_comment:
77
types: [created]
8-
issues:
9-
types: [opened, assigned]
108
pull_request_review:
119
types: [submitted]
10+
issues:
11+
types: [opened, assigned]
1212

1313
jobs:
14-
check-team-membership:
14+
claude:
15+
# Only run if @claude is mentioned in the triggering content
16+
# For issues (opened/assigned), checks the issue body or title
17+
# For comments/reviews, checks the comment/review body
18+
if: contains(github.event.comment.body || github.event.review.body || github.event.issue.body || github.event.issue.title || '', '@claude')
1519
runs-on: ubuntu-latest
16-
outputs:
17-
is-team-member: ${{ steps.check-membership.outputs.is-member }}
20+
permissions:
21+
contents: read
22+
pull-requests: read
23+
issues: read
24+
id-token: write
1825
steps:
1926
- name: Check team membership
2027
id: check-membership
2128
uses: actions/github-script@v8
2229
with:
2330
script: |
2431
try {
25-
// Get username - prioritize sender (the person who triggered the event)
26-
const username = github.event?.sender?.login ||
27-
github.event?.comment?.user?.login;
28-
32+
// Get the user who triggered the event
33+
const username = context.payload.sender?.login;
34+
2935
if (!username) {
30-
console.log('Could not determine username from event payload');
31-
console.log(`Event type: ${github.event_name}`);
32-
console.log(`Event payload keys: ${Object.keys(github.event).join(', ')}`);
33-
return false;
36+
core.setFailed('Could not determine username from event');
37+
return;
3438
}
35-
36-
console.log(`Checking team membership for user: ${username} (triggered by ${github.event_name} event)`);
37-
39+
40+
console.log(`Checking if ${username} is a member of diffplug/spotless`);
41+
3842
const { data } = await github.rest.teams.getMembershipForUserInOrg({
3943
org: 'diffplug',
4044
team_slug: 'spotless',
4145
username: username
4246
});
43-
console.log(`User ${username} membership status: ${data.state}`);
44-
return data.state === 'active';
47+
48+
if (data.state !== 'active') {
49+
core.setFailed(`User ${username} is not an active team member`);
50+
} else {
51+
console.log(`✓ ${username} is an active team member`);
52+
}
4553
} catch (error) {
46-
const username = github.event.sender?.login || github.event.comment?.user?.login || 'unknown user';
47-
console.log(`User ${username} is not a member of the Spotless team or error occurred: ${error.message}`);
48-
return false;
54+
// User is not a team member or API error
55+
core.setFailed(`Access denied: ${error.message}`);
4956
}
5057
51-
claude:
52-
needs: check-team-membership
53-
if: |
54-
needs.check-team-membership.outputs.is-team-member == 'true' &&
55-
(
56-
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
57-
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
58-
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
59-
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
60-
)
61-
runs-on: ubuntu-latest
62-
permissions:
63-
contents: read
64-
pull-requests: read
65-
issues: read
66-
id-token: write
67-
steps:
6858
- name: Checkout repository
6959
uses: actions/checkout@v5
7060
with:
7161
fetch-depth: 1
7262

7363
- name: Run Claude Code
74-
id: claude
7564
uses: anthropics/claude-code-action@beta
7665
with:
77-
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
78-
66+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

gradle/rewrite.gradle

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,9 @@
11
apply plugin: 'org.openrewrite.rewrite'
22

33
rewrite {
4-
activeRecipe(
5-
'org.openrewrite.gradle.GradleBestPractices',
6-
'org.openrewrite.java.RemoveUnusedImports',
7-
'org.openrewrite.java.format.RemoveTrailingWhitespace',
8-
'org.openrewrite.java.migrate.UpgradeToJava17',
9-
'org.openrewrite.java.recipes.JavaRecipeBestPractices',
10-
'org.openrewrite.java.recipes.RecipeTestingBestPractices',
11-
'org.openrewrite.java.security.JavaSecurityBestPractices',
12-
'org.openrewrite.staticanalysis.EqualsAvoidsNull',
13-
'org.openrewrite.staticanalysis.JavaApiBestPractices',
14-
'org.openrewrite.staticanalysis.LowercasePackage',
15-
'org.openrewrite.staticanalysis.MissingOverrideAnnotation',
16-
'org.openrewrite.staticanalysis.ModifierOrder',
17-
'org.openrewrite.staticanalysis.NoFinalizer',
18-
'org.openrewrite.staticanalysis.NoToStringOnStringType',
19-
'org.openrewrite.staticanalysis.NoValueOfOnStringType',
20-
'org.openrewrite.staticanalysis.RemoveUnusedLocalVariables',
21-
'org.openrewrite.staticanalysis.RemoveUnusedPrivateFields',
22-
'org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods',
23-
'org.openrewrite.staticanalysis.UnnecessaryCloseInTryWithResources',
24-
'org.openrewrite.staticanalysis.UnnecessaryExplicitTypeArguments',
25-
'org.openrewrite.staticanalysis.UnnecessaryParentheses',
26-
'org.openrewrite.staticanalysis.UnnecessaryReturnAsLastStatement',
27-
'tech.picnic.errorprone.refasterrules.BigDecimalRulesRecipes',
28-
'tech.picnic.errorprone.refasterrules.CharSequenceRulesRecipes',
29-
'tech.picnic.errorprone.refasterrules.ClassRulesRecipes',
30-
'tech.picnic.errorprone.refasterrules.CollectionRulesRecipes',
31-
'tech.picnic.errorprone.refasterrules.ComparatorRulesRecipes',
32-
'tech.picnic.errorprone.refasterrules.FileRulesRecipes',
33-
'tech.picnic.errorprone.refasterrules.MicrometerRulesRecipes',
34-
'tech.picnic.errorprone.refasterrules.PatternRulesRecipes',
35-
'tech.picnic.errorprone.refasterrules.PreconditionsRulesRecipes',
36-
'tech.picnic.errorprone.refasterrules.PrimitiveRulesRecipes',
37-
'tech.picnic.errorprone.refasterrules.StreamRulesRecipes',
38-
'tech.picnic.errorprone.refasterrules.TimeRulesRecipes'
39-
//'org.openrewrite.staticanalysis.CodeCleanup', bug
40-
//'org.openrewrite.staticanalysis.CommonStaticAnalysis', bug
41-
//'org.openrewrite.staticanalysis.UnnecessaryThrows', bug
42-
)
4+
activeRecipe('org.openrewrite.java.format.NoWhitespaceBefore')
435
exclusions.addAll(
6+
'**.dirty.java',
447
'**_gradle_node_plugin_example_**',
458
'**gradle/changelog.gradle',
469
'**gradle/java-publish.gradle',
@@ -50,7 +13,10 @@ rewrite {
5013
'**lib/build.gradle',
5114
'**package-info.java',
5215
'**plugin-maven/build.gradle',
53-
'**settings.gradle'
16+
'**settings.gradle',
17+
'**special-tests.gradle',
18+
'**FormatterProperties.java',
19+
'**testlib/src/main/resources**'
5420
)
5521
exportDatatables = true
5622
failOnDryRunResults = true

lib-extra/src/groovy/java/com/diffplug/spotless/extra/glue/groovy/GrEclipseFormatterStepImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ public boolean errorsDetected() {
130130
synchronized (GroovyLogManager.manager) {
131131
GroovyLogManager.manager.removeLogger(this);
132132
}
133-
return 0 != errors.size();
133+
return !errors.isEmpty();
134134
}
135135

136136
@Override
137137
public String toString() {
138138
StringBuilder string = new StringBuilder();
139139
if (1 < errors.size()) {
140140
string.append("Multiple problems detected during step execution:");
141-
} else if (0 == errors.size()) {
141+
} else if (errors.isEmpty()) {
142142
string.append("Step sucesfully executed.");
143143
}
144144
for (Throwable error : errors) {

lib-extra/src/jdt/java/com/diffplug/spotless/extra/glue/jdt/DefaultJavaElementComparator.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,23 +164,26 @@ private int category(BodyDeclaration bodyDeclaration) {
164164
return CONSTRUCTORS_INDEX;
165165
}
166166
int flags = method.getModifiers();
167-
if (Modifier.isStatic(flags))
167+
if (Modifier.isStatic(flags)) {
168168
return STATIC_METHODS_INDEX;
169-
else
169+
} else {
170170
return METHOD_INDEX;
171+
}
171172
}
172173
case ASTNode.FIELD_DECLARATION: {
173-
if (JdtFlags.isStatic(bodyDeclaration))
174+
if (JdtFlags.isStatic(bodyDeclaration)) {
174175
return STATIC_FIELDS_INDEX;
175-
else
176+
} else {
176177
return FIELDS_INDEX;
178+
}
177179
}
178180
case ASTNode.INITIALIZER: {
179181
int flags = bodyDeclaration.getModifiers();
180-
if (Modifier.isStatic(flags))
182+
if (Modifier.isStatic(flags)) {
181183
return STATIC_INIT_INDEX;
182-
else
184+
} else {
183185
return INIT_INDEX;
186+
}
184187
}
185188
case ASTNode.TYPE_DECLARATION:
186189
case ASTNode.ENUM_DECLARATION:
@@ -280,7 +283,7 @@ public int compare(BodyDeclaration bodyDeclaration1, BodyDeclaration bodyDeclara
280283
int length2 = parameters2.size();
281284

282285
int len = Math.min(length1, length2);
283-
for (int i = 0; i < len; i++) {
286+
for (int i = 0;i < len;i++) {
284287
SingleVariableDeclaration param1 = parameters1.get(i);
285288
SingleVariableDeclaration param2 = parameters2.get(i);
286289
cmp = buildSignature(param1.getType()).compareTo(buildSignature(param2.getType()));

lib-extra/src/jdt/java/com/diffplug/spotless/extra/glue/jdt/JdtFlags.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,21 @@ class JdtFlags {
3333
static final int VISIBILITY_CODE_INVALID = -1;
3434

3535
static boolean isStatic(BodyDeclaration bodyDeclaration) {
36-
if (isNestedInterfaceOrAnnotation(bodyDeclaration))
36+
if (isNestedInterfaceOrAnnotation(bodyDeclaration)) {
3737
return true;
38+
}
3839
int nodeType = bodyDeclaration.getNodeType();
3940
if (nodeType != ASTNode.METHOD_DECLARATION
4041
&& nodeType != ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION
41-
&& isInterfaceOrAnnotationMember(bodyDeclaration))
42+
&& isInterfaceOrAnnotationMember(bodyDeclaration)) {
4243
return true;
43-
if (bodyDeclaration instanceof EnumConstantDeclaration)
44+
}
45+
if (bodyDeclaration instanceof EnumConstantDeclaration) {
4446
return true;
45-
if (bodyDeclaration instanceof EnumDeclaration && bodyDeclaration.getParent() instanceof AbstractTypeDeclaration)
47+
}
48+
if (bodyDeclaration instanceof EnumDeclaration && bodyDeclaration.getParent() instanceof AbstractTypeDeclaration) {
4649
return true;
50+
}
4751
return Modifier.isStatic(bodyDeclaration.getModifiers());
4852
}
4953

@@ -60,8 +64,9 @@ private static boolean isProtected(BodyDeclaration bodyDeclaration) {
6064
}
6165

6266
private static boolean isPublic(BodyDeclaration bodyDeclaration) {
63-
if (isInterfaceOrAnnotationMember(bodyDeclaration))
67+
if (isInterfaceOrAnnotationMember(bodyDeclaration)) {
6468
return true;
69+
}
6570
return Modifier.isPublic(bodyDeclaration.getModifiers());
6671
}
6772

@@ -80,14 +85,15 @@ private static boolean isNestedInterfaceOrAnnotation(BodyDeclaration bodyDeclara
8085
}
8186

8287
static int getVisibilityCode(BodyDeclaration bodyDeclaration) {
83-
if (isPublic(bodyDeclaration))
88+
if (isPublic(bodyDeclaration)) {
8489
return Modifier.PUBLIC;
85-
else if (isProtected(bodyDeclaration))
90+
} else if (isProtected(bodyDeclaration)) {
8691
return Modifier.PROTECTED;
87-
else if (isPackageVisible(bodyDeclaration))
92+
} else if (isPackageVisible(bodyDeclaration)) {
8893
return Modifier.NONE;
89-
else if (isPrivate(bodyDeclaration))
94+
} else if (isPrivate(bodyDeclaration)) {
9095
return Modifier.PRIVATE;
96+
}
9197
Assert.isTrue(false);
9298
return VISIBILITY_CODE_INVALID;
9399
}

lib-extra/src/main/java/com/diffplug/spotless/extra/EclipseBasedStepBuilder.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ public EclipseBasedStepBuilder(String formatterName, String formatterStepExt, Pr
7878

7979
/** Returns the FormatterStep (whose state will be calculated lazily). */
8080
public FormatterStep build() {
81-
var roundtrippableState = new EclipseStep(formatterVersion, formatterStepExt, FileSignature.promise(settingsFiles), JarState.promise(() -> {
82-
return JarState.withoutTransitives(dependencies, jarProvisioner);
83-
}));
81+
var roundtrippableState = new EclipseStep(formatterVersion, formatterStepExt, FileSignature.promise(settingsFiles), JarState.promise(() -> JarState.withoutTransitives(dependencies, jarProvisioner)));
8482
return FormatterStep.create(formatterName + formatterStepExt, roundtrippableState,
8583
EclipseStep::state, stateToFormatter);
8684
}

lib-extra/src/main/java/com/diffplug/spotless/extra/EquoBasedStepBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public abstract class EquoBasedStepBuilder {
6161
private File cacheDirectory;
6262

6363
/** Initialize valid default configuration, taking latest version */
64-
public EquoBasedStepBuilder(
64+
protected EquoBasedStepBuilder(
6565
String formatterName,
6666
Provisioner mavenProvisioner,
6767
@Nullable String defaultVersion,

lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,15 @@ public String endingFor(File file) {
177177

178178
static class RuntimeInit {
179179
/** /etc/gitconfig (system-global), ~/.gitconfig (each might-not exist). */
180-
final FileBasedConfig systemConfig, userConfig;
180+
final FileBasedConfig systemConfig;
181+
final FileBasedConfig userConfig;
181182

182183
/** Repository specific config, can be $GIT_COMMON_DIR/config, project/.git/config or .git/worktrees/<id>/config.worktree if enabled by extension */
183184
final Config repoConfig;
184185

185186
/** Global .gitattributes file pointed at by systemConfig or userConfig, and the file in the repo. */
186-
final @Nullable File globalAttributesFile, repoAttributesFile;
187+
final @Nullable File globalAttributesFile;
188+
final @Nullable File repoAttributesFile;
187189

188190
/** git worktree root, might not exist if we're not in a git repo. */
189191
final @Nullable File workTree;
@@ -235,7 +237,7 @@ private Runtime atRuntime() {
235237
}
236238

237239
/** https://github.com/git/git/blob/1fe8f2cf461179c41f64efbd1dc0a9fb3b7a0fb1/Documentation/gitattributes.txt */
238-
static class Runtime {
240+
static final class Runtime {
239241
/** .git/info/attributes (and the worktree with that file) */
240242
final List<AttributesRule> infoRules;
241243

lib-extra/src/main/java/com/diffplug/spotless/extra/GitRatchet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public boolean isClean(Project project, ObjectId treeSha, File file) throws IOEx
6262
return isClean(project, treeSha, relativePath);
6363
}
6464

65-
private Map<Repository, DirCache> dirCaches = new HashMap<>();
65+
private final Map<Repository, DirCache> dirCaches = new HashMap<>();
6666

6767
/**
6868
* This is the highest-level method, which all the others serve. Given the sha

lib-extra/src/main/java/com/diffplug/spotless/extra/cpp/EclipseCdtFormatterStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public final class EclipseCdtFormatterStep {
3838
private EclipseCdtFormatterStep() {}
3939

4040
private static final String NAME = "eclipse cdt formatter";
41-
private static final Jvm.Support<String> JVM_SUPPORT = Jvm.<String> support(NAME).add(17, "11.6");
41+
private static final Jvm.Support<String> JVM_SUPPORT = Jvm.<String>support(NAME).add(17, "11.6");
4242

4343
public static String defaultVersion() {
4444
return JVM_SUPPORT.getRecommendedFormatterVersion();

0 commit comments

Comments
 (0)