Skip to content

Commit ff66036

Browse files
committed
Remove redundant Regex escapes
Closes gh-40116
1 parent a4d3123 commit ff66036

File tree

10 files changed

+21
-21
lines changed

10 files changed

+21
-21
lines changed

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/server/DefaultSourceDirectoryUrlFilter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
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 @@ public class DefaultSourceDirectoryUrlFilter implements SourceDirectoryUrlFilter
3333

3434
private static final String[] COMMON_ENDINGS = { "/target/classes", "/bin" };
3535

36-
private static final Pattern URL_MODULE_PATTERN = Pattern.compile(".*\\/(.+)\\.jar");
36+
private static final Pattern URL_MODULE_PATTERN = Pattern.compile(".*/(.+)\\.jar");
3737

3838
private static final Pattern VERSION_PATTERN = Pattern.compile("^-\\d+(?:\\.\\d+)*(?:[.-].+)?$");
3939

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/ImageReference.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
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.
@@ -35,7 +35,7 @@
3535
*/
3636
public final class ImageReference {
3737

38-
private static final Pattern JAR_VERSION_PATTERN = Pattern.compile("^(.*)(\\-\\d+)$");
38+
private static final Pattern JAR_VERSION_PATTERN = Pattern.compile("^(.*)(-\\d+)$");
3939

4040
private static final String LATEST = "latest";
4141

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/JavaPluginActionIntegrationTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
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.
@@ -150,7 +150,7 @@ void applyingJavaPluginCreatesDevelopmentOnlyConfiguration() {
150150
@TestTemplate
151151
void productionRuntimeClasspathIsConfiguredWithAttributesThatMatchRuntimeClasspath() {
152152
String output = this.gradleBuild.build("build").getOutput();
153-
Matcher matcher = Pattern.compile("runtimeClasspath: (\\[.*\\])").matcher(output);
153+
Matcher matcher = Pattern.compile("runtimeClasspath: (\\[.*])").matcher(output);
154154
assertThat(matcher.find()).as("%s found in %s", matcher, output).isTrue();
155155
String attributes = matcher.group(1);
156156
assertThat(output).contains("productionRuntimeClasspath: " + attributes);

spring-boot-project/spring-boot-tools/spring-boot-gradle-test-support/src/main/java/org/springframework/boot/testsupport/gradle/testkit/GradleBuildExtension.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
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.
@@ -36,7 +36,7 @@
3636
*/
3737
public class GradleBuildExtension implements BeforeEachCallback, AfterEachCallback {
3838

39-
private static final Pattern GRADLE_VERSION_PATTERN = Pattern.compile("\\[Gradle .+\\]");
39+
private static final Pattern GRADLE_VERSION_PATTERN = Pattern.compile("\\[Gradle .+]");
4040

4141
private final Dsl dsl = Dsl.GROOVY;
4242

spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
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.
@@ -42,7 +42,7 @@ public class DefaultLaunchScript implements LaunchScript {
4242

4343
private static final int BUFFER_SIZE = 4096;
4444

45-
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("\\{\\{(\\w+)(:.*?)?\\}\\}(?!\\})");
45+
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("\\{\\{(\\w+)(:.*?)?}}(?!})");
4646

4747
private static final Set<String> FILE_PATH_KEYS = Collections.singleton("inlinedConfScript");
4848

spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
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.
@@ -90,7 +90,7 @@ public void addManifest(Manifest manifest) throws IOException {
9090
}
9191

9292
private File getFilePath(String filename) {
93-
String[] paths = filename.split("\\/");
93+
String[] paths = filename.split("/");
9494
File file = this.jarSource;
9595
for (String path : paths) {
9696
file = new File(file, path);

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/groovy/generateGoalsDocumentation.groovy

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ private String format(String input) {
88
.replace("<br>", " ")
99
.replace("\n", " ")
1010
.replace("&quot;", '"')
11-
.replaceAll('\\{@code (.*?)\\}', '`$1`')
12-
.replaceAll('\\{@link (.*?)\\}', '`$1`')
13-
.replaceAll('\\{@literal (.*?)\\}', '`$1`')
11+
.replaceAll('\\{@code (.*?)}', '`$1`')
12+
.replaceAll('\\{@link (.*?)}', '`$1`')
13+
.replaceAll('\\{@literal (.*?)}', '`$1`')
1414
.replaceAll('<a href=."(.*?)".>(.*?)</a>', '\$1[\$2]')
1515
}
1616

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/StandardConfigDataLocationResolver.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
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.
@@ -66,7 +66,7 @@ public class StandardConfigDataLocationResolver
6666

6767
private static final Pattern URL_PREFIX = Pattern.compile("^([a-zA-Z][a-zA-Z0-9*]*?:)(.*$)");
6868

69-
private static final Pattern EXTENSION_HINT_PATTERN = Pattern.compile("^(.*)\\[(\\.\\w+)\\](?!\\[)$");
69+
private static final Pattern EXTENSION_HINT_PATTERN = Pattern.compile("^(.*)\\[(\\.\\w+)](?!\\[)$");
7070

7171
private static final String NO_PROFILE = null;
7272

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
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.
@@ -582,7 +582,7 @@ void testDateformatPatternDefault(CapturedOutput output) {
582582
initialize(loggingInitializationContext, null, null);
583583
this.logger.info("Hello world");
584584
assertThat(getLineWithText(output, "Hello world"))
585-
.containsPattern("\\d{4}-\\d{2}\\-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}([-+]\\d{2}:\\d{2}|Z)");
585+
.containsPattern("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}([-+]\\d{2}:\\d{2}|Z)");
586586
}
587587

588588
@Test

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/server/MimeMappingsTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
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.
@@ -152,7 +152,7 @@ void makeUnmodifiable() {
152152
@Test
153153
void mimeTypesInDefaultMappingsAreCorrectlyStructured() {
154154
String regName = "[A-Za-z0-9!#$&.+\\-^_]{1,127}";
155-
Pattern pattern = Pattern.compile("^" + regName + "\\/" + regName + "$");
155+
Pattern pattern = Pattern.compile("^" + regName + "/" + regName + "$");
156156
assertThat(MimeMappings.DEFAULT).allSatisfy((mapping) -> assertThat(mapping.getMimeType()).matches(pattern));
157157
}
158158

0 commit comments

Comments
 (0)