Skip to content

Commit 651dbe4

Browse files
committed
chore: formatting, missing license headers
1 parent 1e7af31 commit 651dbe4

23 files changed

Lines changed: 171 additions & 109 deletions

src/main/java/com/github/jimschubert/rewrite/docker/AddOrUpdateDirective.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
package com.github.jimschubert.rewrite.docker;
1616

1717
import com.github.jimschubert.rewrite.docker.tree.Docker;
18-
import lombok.*;
18+
import lombok.EqualsAndHashCode;
19+
import lombok.NoArgsConstructor;
20+
import lombok.RequiredArgsConstructor;
21+
import lombok.Value;
1922
import org.openrewrite.*;
2023
import org.openrewrite.internal.ListUtils;
2124
import org.openrewrite.marker.SearchResult;

src/main/java/com/github/jimschubert/rewrite/docker/AsDockerfile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* <p>
3333
* For example, if you have a file named "Dockerfile.dev" and you want to treat it as a Dockerfile, you can use this recipe.
3434
* <p>
35-
*
35+
* <p>
3636
* The idea for this recipe came from a discussion on the OpenRewrite Slack channel, where it was suggested to
3737
* <a href="https://github.com/openrewrite/rewrite/pull/3993#issuecomment-2227376531">force load via recipe</a>.
3838
*/
@@ -43,7 +43,7 @@
4343
public class AsDockerfile extends Recipe {
4444
@Option(displayName = "File pattern",
4545
description = "A file path glob expression to match from the project root. Blank/null matches all." +
46-
"Supports multiple patterns separated by a semicolon `;`.",
46+
"Supports multiple patterns separated by a semicolon `;`.",
4747
required = false,
4848
example = ".github/workflows/*.yml")
4949
String filePattern;

src/main/java/com/github/jimschubert/rewrite/docker/Assertions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static SourceSpecs dockerfile(@Language("dockerfile") @Nullable String be
4545
}
4646

4747
public static SourceSpecs dockerfile(@Language("dockerfile") @Nullable String before, @Language("dockerfile") @Nullable String after,
48-
Consumer<SourceSpec<Docker.Document>> spec) {
48+
Consumer<SourceSpec<Docker.Document>> spec) {
4949
SourceSpec<Docker.Document> doc = new SourceSpec<>(Docker.Document.class, null, DockerParser.builder(), before, s -> after);
5050
doc.path("Dockerfile");
5151
spec.accept(doc);

src/main/java/com/github/jimschubert/rewrite/docker/ChangeImage.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@
1515
package com.github.jimschubert.rewrite.docker;
1616

1717
import com.github.jimschubert.rewrite.docker.tree.Docker;
18-
import lombok.*;
18+
import lombok.EqualsAndHashCode;
19+
import lombok.NoArgsConstructor;
20+
import lombok.RequiredArgsConstructor;
21+
import lombok.Value;
1922
import org.jspecify.annotations.Nullable;
20-
import org.openrewrite.*;
23+
import org.openrewrite.ExecutionContext;
24+
import org.openrewrite.Option;
25+
import org.openrewrite.Recipe;
26+
import org.openrewrite.TreeVisitor;
2127

2228
import java.util.regex.Matcher;
2329
import java.util.regex.Pattern;
@@ -41,18 +47,18 @@ public class ChangeImage extends Recipe {
4147
@Nullable
4248
@Option(displayName = "New version",
4349
description = "The new version (tag or digest) for the image found by `oldImage`. Can be format `:tagName`, `@digest`, or `tagName`. " +
44-
"If not provided, the version will be left as-is. " +
45-
"To unset a tag, newImage must not contain a tag, and newVersion must be set to an empty string.",
50+
"If not provided, the version will be left as-is. " +
51+
"To unset a tag, newImage must not contain a tag, and newVersion must be set to an empty string.",
4652
example = ":latest",
4753
required = false)
4854
String newVersion;
4955

5056
@Nullable
5157
@Option(displayName = "New platform",
5258
description = "The new platform for the image found by `matchImage`. Can be full format " +
53-
"(`--platform=linux/amd64`), partial (`linux/amd64`)" +
54-
"If not provided, the platform will be left as-is. " +
55-
"To unset a platform, newPlatform must be set to an empty string.",
59+
"(`--platform=linux/amd64`), partial (`linux/amd64`)" +
60+
"If not provided, the platform will be left as-is. " +
61+
"To unset a platform, newPlatform must be set to an empty string.",
5662
example = "--platform=linux/amd64",
5763
required = false)
5864
String newPlatform;

src/main/java/com/github/jimschubert/rewrite/docker/DockerIsoVisitor.java

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
* An isomorphic visitor for Dockerfile ASTs.
2222
* Each visit method returns the same type as the input, but with the children visited.
2323
* This visitor should be preferred over {@link DockerVisitor} when visiting the Dockerfile LST.
24-
* @see <a href="https://docs.openrewrite.org/concepts-and-explanations/visitors#isomorphic-vs-non-isomorphic-visitors">OpenRewrite docs: Visitor</a>
24+
*
2525
* @param <T>
26+
* @see <a href="https://docs.openrewrite.org/concepts-and-explanations/visitors#isomorphic-vs-non-isomorphic-visitors">OpenRewrite docs: Visitor</a>
2627
*/
2728
public class DockerIsoVisitor<T> extends DockerVisitor<T> {
2829
@Override
2930
public Docker.Document visitDocument(Docker.Document dockerfile, T ctx) {
30-
return (Docker.Document)super.visitDocument(dockerfile, ctx);
31+
return (Docker.Document) super.visitDocument(dockerfile, ctx);
3132
}
3233

3334
@Override
@@ -37,106 +38,106 @@ public Space visitSpace(Space space, T t) {
3738

3839
@Override
3940
public Docker.Stage visitStage(Docker.Stage stage, T t) {
40-
return (Docker.Stage)super.visitStage(stage, t);
41+
return (Docker.Stage) super.visitStage(stage, t);
4142
}
4243

4344
@Override
4445
public Docker.From visitFrom(Docker.From from, T t) {
45-
return (Docker.From)super.visitFrom(from, t);
46+
return (Docker.From) super.visitFrom(from, t);
4647
}
4748

4849
@Override
4950
public Docker.Comment visitComment(Docker.Comment comment, T t) {
50-
return (Docker.Comment)super.visitComment(comment, t);
51+
return (Docker.Comment) super.visitComment(comment, t);
5152
}
5253

5354
@Override
5455
public Docker.Directive visitDirective(Docker.Directive directive, T t) {
55-
return (Docker.Directive)super.visitDirective(directive, t);
56+
return (Docker.Directive) super.visitDirective(directive, t);
5657
}
5758

5859
@Override
5960
public Docker.Run visitRun(Docker.Run run, T t) {
60-
return (Docker.Run)super.visitRun(run, t);
61+
return (Docker.Run) super.visitRun(run, t);
6162
}
6263

6364
@Override
6465
public Docker.Cmd visitCmd(Docker.Cmd cmd, T t) {
65-
return (Docker.Cmd)super.visitCmd(cmd, t);
66+
return (Docker.Cmd) super.visitCmd(cmd, t);
6667
}
6768

6869
@Override
6970
public Docker.Label visitLabel(Docker.Label label, T t) {
70-
return (Docker.Label)super.visitLabel(label, t);
71+
return (Docker.Label) super.visitLabel(label, t);
7172
}
7273

7374
@Override
7475
public Docker.Maintainer visitMaintainer(Docker.Maintainer maintainer, T t) {
75-
return (Docker.Maintainer)super.visitMaintainer(maintainer, t);
76+
return (Docker.Maintainer) super.visitMaintainer(maintainer, t);
7677
}
7778

7879
@Override
7980
public Docker.Expose visitExpose(Docker.Expose expose, T t) {
80-
return (Docker.Expose)super.visitExpose(expose, t);
81+
return (Docker.Expose) super.visitExpose(expose, t);
8182
}
8283

8384
@Override
8485
public Docker.Env visitEnv(Docker.Env env, T t) {
85-
return (Docker.Env)super.visitEnv(env, t);
86+
return (Docker.Env) super.visitEnv(env, t);
8687
}
8788

8889
@Override
8990
public Docker.Add visitAdd(Docker.Add add, T t) {
90-
return (Docker.Add)super.visitAdd(add, t);
91+
return (Docker.Add) super.visitAdd(add, t);
9192
}
9293

9394
@Override
9495
public Docker.Copy visitCopy(Docker.Copy copy, T t) {
95-
return (Docker.Copy)super.visitCopy(copy, t);
96+
return (Docker.Copy) super.visitCopy(copy, t);
9697
}
9798

9899
@Override
99100
public Docker.Entrypoint visitEntrypoint(Docker.Entrypoint entrypoint, T t) {
100-
return (Docker.Entrypoint)super.visitEntrypoint(entrypoint, t);
101+
return (Docker.Entrypoint) super.visitEntrypoint(entrypoint, t);
101102
}
102103

103104
@Override
104105
public Docker.Volume visitVolume(Docker.Volume volume, T t) {
105-
return (Docker.Volume)super.visitVolume(volume, t);
106+
return (Docker.Volume) super.visitVolume(volume, t);
106107
}
107108

108109
@Override
109110
public Docker.User visitUser(Docker.User user, T t) {
110-
return (Docker.User)super.visitUser(user, t);
111+
return (Docker.User) super.visitUser(user, t);
111112
}
112113

113114
@Override
114115
public Docker.Workdir visitWorkdir(Docker.Workdir workdir, T t) {
115-
return (Docker.Workdir)super.visitWorkdir(workdir, t);
116+
return (Docker.Workdir) super.visitWorkdir(workdir, t);
116117
}
117118

118119
@Override
119120
public Docker.Arg visitArg(Docker.Arg arg, T t) {
120-
return (Docker.Arg)super.visitArg(arg, t);
121+
return (Docker.Arg) super.visitArg(arg, t);
121122
}
122123

123124
@Override
124125
public Docker.OnBuild visitOnBuild(Docker.OnBuild onBuild, T t) {
125-
return (Docker.OnBuild)super.visitOnBuild(onBuild, t);
126+
return (Docker.OnBuild) super.visitOnBuild(onBuild, t);
126127
}
127128

128129
@Override
129130
public Docker.StopSignal visitStopSignal(Docker.StopSignal stopSignal, T t) {
130-
return (Docker.StopSignal)super.visitStopSignal(stopSignal, t);
131+
return (Docker.StopSignal) super.visitStopSignal(stopSignal, t);
131132
}
132133

133134
@Override
134135
public Docker.Healthcheck visitHealthcheck(Docker.Healthcheck healthcheck, T t) {
135-
return (Docker.Healthcheck)super.visitHealthcheck(healthcheck, t);
136+
return (Docker.Healthcheck) super.visitHealthcheck(healthcheck, t);
136137
}
137138

138139
@Override
139140
public Docker.Shell visitShell(Docker.Shell shell, T t) {
140-
return (Docker.Shell)super.visitShell(shell, t);
141+
return (Docker.Shell) super.visitShell(shell, t);
141142
}
142143
}

src/main/java/com/github/jimschubert/rewrite/docker/DockerParser.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ public class DockerParser implements Parser {
3232
@Override
3333
public Stream<SourceFile> parseInputs(Iterable<Parser.Input> sources, @Nullable Path relativeTo, ExecutionContext ctx) {
3434
ParsingEventListener parsingListener = ParsingExecutionContextView.view(ctx).getParsingListener();
35-
return acceptedInputs(sources).map(input ->{
35+
return acceptedInputs(sources).map(input -> {
3636
parsingListener.startedParsing(input);
3737
try (EncodingDetectingInputStream is = input.getSource(ctx)) {
3838
DockerfileParser parser = new DockerfileParser();
3939

4040
Docker.Document document = parser.parse(is)
4141
.withFileAttributes(input.getFileAttributes())
42-
.withSourcePath(input.getPath());
42+
.withSourcePath(input.getPath());
4343

4444
parsingListener.parsed(input, document);
4545

@@ -59,15 +59,17 @@ public Stream<SourceFile> parseInputs(Iterable<Parser.Input> sources, @Nullable
5959
public boolean accept(Path path) {
6060
String fileName = path.toString();
6161
return fileName.endsWith(".dockerfile") || fileName.equalsIgnoreCase("dockerfile") ||
62-
fileName.endsWith(".containerfile") || fileName.equalsIgnoreCase("containerfile");
62+
fileName.endsWith(".containerfile") || fileName.equalsIgnoreCase("containerfile");
6363
}
6464

6565
@Override
6666
public Path sourcePathFromSourceText(Path prefix, String sourceCode) {
6767
return prefix.resolve("Dockerfile");
6868
}
6969

70-
public static Builder builder() { return new Builder(); }
70+
public static Builder builder() {
71+
return new Builder();
72+
}
7173

7274
public static class Builder extends Parser.Builder {
7375
public Builder() {

src/main/java/com/github/jimschubert/rewrite/docker/DockerParsingException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
public class DockerParsingException extends Exception {
2020
private final Path sourcePath;
21+
2122
public DockerParsingException(Path sourcePath, String message, Throwable t) {
2223
super(message, t);
2324
this.sourcePath = sourcePath;

src/main/java/com/github/jimschubert/rewrite/docker/DockerVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public <T> DockerRightPadded<T> visitDockerRightPadded(DockerRightPadded<T> righ
240240
} else if (t instanceof Docker.KeyArgs) {
241241
Docker.KeyArgs args = (Docker.KeyArgs) right.getElement();
242242
//noinspection unchecked
243-
t = (T)args.withPrefix(visitSpace(args.getPrefix(), p))
243+
t = (T) args.withPrefix(visitSpace(args.getPrefix(), p))
244244
.withKey(visitAndCast(args.getKey(), p))
245245
.withValue(visitAndCast(args.getValue(), p))
246246
.withQuoting(args.getQuoting());

src/main/java/com/github/jimschubert/rewrite/docker/ModifyLiteral.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public class ModifyLiteral extends Recipe {
3535

3636
@Option(displayName = "Replacement text",
3737
description = "The replacement text for the matched text. " +
38-
"This will replace the full literal text, or a single matching group defined in `matchText`. " +
39-
"Be careful as this may result in an invalid Dockerfile.",
38+
"This will replace the full literal text, or a single matching group defined in `matchText`. " +
39+
"Be careful as this may result in an invalid Dockerfile.",
4040
example = "java-21")
4141
String replacementText;
4242

@@ -64,7 +64,7 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
6464

6565
if (n.getTree().getMarkers().findFirst(Modified.class).filter(
6666
m -> m.matchText.equals(matchText) && m.replacementText.equals(replacementText)
67-
).isPresent()) {
67+
).isPresent()) {
6868
return n.getTree();
6969
}
7070

src/main/java/com/github/jimschubert/rewrite/docker/NameAllStages.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
package com.github.jimschubert.rewrite.docker;
1616

1717
import com.github.jimschubert.rewrite.docker.tree.Docker;
18-
import lombok.*;
18+
import lombok.EqualsAndHashCode;
19+
import lombok.RequiredArgsConstructor;
20+
import lombok.Value;
21+
import lombok.With;
1922
import org.openrewrite.ExecutionContext;
2023
import org.openrewrite.NlsRewrite;
2124
import org.openrewrite.Recipe;

0 commit comments

Comments
 (0)