Skip to content

Commit 722390e

Browse files
author
Vincent Potucek
committed
[openrewrite] fixup claude permissions
1 parent 90d5c7b commit 722390e

File tree

152 files changed

+530
-580
lines changed

Some content is hidden

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

152 files changed

+530
-580
lines changed

gradle/rewrite.gradle

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

33
rewrite {
4-
activeRecipe('com.diffplug.spotless.openrewrite.SanityCheck')
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+
)
543
exclusions.addAll(
6-
'**.dirty.java',
744
'**_gradle_node_plugin_example_**',
845
'**gradle/changelog.gradle',
946
'**gradle/java-publish.gradle',
@@ -13,9 +50,7 @@ rewrite {
1350
'**lib/build.gradle',
1451
'**package-info.java',
1552
'**plugin-maven/build.gradle',
16-
'**settings.gradle',
17-
'**special-tests.gradle',
18-
'**testlib/src/main/resources**'
53+
'**settings.gradle'
1954
)
2055
exportDatatables = true
2156
failOnDryRunResults = true

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 DiffPlug
2+
* Copyright 2016-2023 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -130,15 +130,15 @@ public boolean errorsDetected() {
130130
synchronized (GroovyLogManager.manager) {
131131
GroovyLogManager.manager.removeLogger(this);
132132
}
133-
return !errors.isEmpty();
133+
return 0 != errors.size();
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 (errors.isEmpty()) {
141+
} else if (0 == errors.size()) {
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: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,26 +164,23 @@ 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-
}
172171
}
173172
case ASTNode.FIELD_DECLARATION: {
174-
if (JdtFlags.isStatic(bodyDeclaration)) {
173+
if (JdtFlags.isStatic(bodyDeclaration))
175174
return STATIC_FIELDS_INDEX;
176-
} else {
175+
else
177176
return FIELDS_INDEX;
178-
}
179177
}
180178
case ASTNode.INITIALIZER: {
181179
int flags = bodyDeclaration.getModifiers();
182-
if (Modifier.isStatic(flags)) {
180+
if (Modifier.isStatic(flags))
183181
return STATIC_INIT_INDEX;
184-
} else {
182+
else
185183
return INIT_INDEX;
186-
}
187184
}
188185
case ASTNode.TYPE_DECLARATION:
189186
case ASTNode.ENUM_DECLARATION:

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024-2025 DiffPlug
2+
* Copyright 2024 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@
3333
import org.eclipse.jdt.core.dom.AST;
3434
import org.eclipse.jdt.internal.core.SortElementsOperation;
3535

36-
public final class EclipseJdtSortMembers {
36+
public class EclipseJdtSortMembers {
3737

3838
private static final Pattern PATTERN_DO_NOT_SORT_FIELDS = Pattern.compile("@SortMembers:doNotSortFields\\s*=\\s*(false|true)");
3939
private static final Pattern PATTERN_ENABLED = Pattern.compile("@SortMembers:enabled\\s*=\\s*(false|true)");
@@ -244,6 +244,4 @@ static SortProperties from(Map<String, String> properties) {
244244
return new SortProperties(enabled, membersOrder, doNotSortFields, sortByVisibility, visibilityOrder);
245245
}
246246
}
247-
248-
private EclipseJdtSortMembers() {}
249247
}

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

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,22 @@
2828
/**
2929
* This class is derived and adapted code from the Eclipse JDT project (Derivative Works according to EPL 2.0 license).
3030
*/
31-
final class JdtFlags {
31+
class JdtFlags {
3232

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-
}
3938
int nodeType = bodyDeclaration.getNodeType();
4039
if (nodeType != ASTNode.METHOD_DECLARATION
4140
&& nodeType != ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION
42-
&& isInterfaceOrAnnotationMember(bodyDeclaration)) {
41+
&& isInterfaceOrAnnotationMember(bodyDeclaration))
4342
return true;
44-
}
45-
if (bodyDeclaration instanceof EnumConstantDeclaration) {
43+
if (bodyDeclaration instanceof EnumConstantDeclaration)
4644
return true;
47-
}
48-
if (bodyDeclaration instanceof EnumDeclaration && bodyDeclaration.getParent() instanceof AbstractTypeDeclaration) {
45+
if (bodyDeclaration instanceof EnumDeclaration && bodyDeclaration.getParent() instanceof AbstractTypeDeclaration)
4946
return true;
50-
}
5147
return Modifier.isStatic(bodyDeclaration.getModifiers());
5248
}
5349

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

6662
private static boolean isPublic(BodyDeclaration bodyDeclaration) {
67-
if (isInterfaceOrAnnotationMember(bodyDeclaration)) {
63+
if (isInterfaceOrAnnotationMember(bodyDeclaration))
6864
return true;
69-
}
7065
return Modifier.isPublic(bodyDeclaration.getModifiers());
7166
}
7267

@@ -85,18 +80,15 @@ private static boolean isNestedInterfaceOrAnnotation(BodyDeclaration bodyDeclara
8580
}
8681

8782
static int getVisibilityCode(BodyDeclaration bodyDeclaration) {
88-
if (isPublic(bodyDeclaration)) {
83+
if (isPublic(bodyDeclaration))
8984
return Modifier.PUBLIC;
90-
} else if (isProtected(bodyDeclaration)) {
85+
else if (isProtected(bodyDeclaration))
9186
return Modifier.PROTECTED;
92-
} else if (isPackageVisible(bodyDeclaration)) {
87+
else if (isPackageVisible(bodyDeclaration))
9388
return Modifier.NONE;
94-
} else if (isPrivate(bodyDeclaration)) {
89+
else if (isPrivate(bodyDeclaration))
9590
return Modifier.PRIVATE;
96-
}
9791
Assert.isTrue(false);
9892
return VISIBILITY_CODE_INVALID;
9993
}
100-
101-
private JdtFlags() {}
10294
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ 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(() -> JarState.withoutTransitives(dependencies, jarProvisioner)));
81+
var roundtrippableState = new EclipseStep(formatterVersion, formatterStepExt, FileSignature.promise(settingsFiles), JarState.promise(() -> {
82+
return JarState.withoutTransitives(dependencies, jarProvisioner);
83+
}));
8284
return FormatterStep.create(formatterName + formatterStepExt, roundtrippableState,
8385
EclipseStep::state, stateToFormatter);
8486
}

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-
protected EquoBasedStepBuilder(
64+
public EquoBasedStepBuilder(
6565
String formatterName,
6666
Provisioner mavenProvisioner,
6767
@Nullable String defaultVersion,

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

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

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

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

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

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

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

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 final Map<Repository, DirCache> dirCaches = new HashMap<>();
65+
private 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/GitWorkarounds.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2025 DiffPlug
2+
* Copyright 2020-2023 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -202,7 +202,7 @@ private static IOException emptyFile(File commonDir) {
202202
return new IOException("Empty 'commondir' file: " + commonDir.getAbsolutePath());
203203
}
204204

205-
@SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
205+
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
206206
@Override
207207
public FileRepositoryBuilder readEnvironment(SystemReader sr) {
208208
super.readEnvironment(sr);

0 commit comments

Comments
 (0)