Skip to content

Commit 4b929ae

Browse files
authored
Merge pull request #694 from git-commit-id/dependabot/maven/com.puppycrawl.tools-checkstyle-10.13.0
Bump com.puppycrawl.tools:checkstyle from 8.25 to 10.13.0
2 parents a0dc3ea + 385773e commit 4b929ae

35 files changed

+2478
-1863
lines changed

.github/.checkstyle/checkstyle-suppressions.xml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,15 @@
55
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
66

77
<suppressions>
8-
<suppress checks="JavadocStyle" files=".*\.java" />
8+
<suppress checks="AbbreviationAsWordInName" files=".*\.java" />
99
<suppress checks="SummaryJavadoc" files=".*\.java" />
10+
<suppress checks="MissingJavadocMethod" files=".*\.java" />
11+
<suppress checks="MissingJavadocType" files=".*\.java" />
1012
<suppress checks="JavadocParagraph" files=".*\.java" />
11-
<suppress checks="JavadocMethod" files=".*\.java" />
1213
<suppress checks="JavadocTagContinuationIndentation" files=".*\.java" />
13-
<suppress checks="SingleLineJavadoc" files=".*\.java" />
14-
15-
<suppress checks="LineLength" files=".*\.java" />
16-
<suppress checks="OperatorWrap" files=".*\.java" />
17-
<suppress checks="ParameterName" files=".*\.java" />
18-
<suppress checks="AvoidStarImport" files=".*\.java" />
19-
<suppress checks="MemberName" files=".*\.java" />
14+
<suppress checks="VariableDeclarationUsageDistance" files=".*\.java" />
2015
<suppress checks="LocalVariableName" files=".*\.java" />
21-
<suppress checks="MethodName" files=".*\.java" />
22-
<suppress checks="CustomImportOrder" files=".*\.java" />
2316
<suppress checks="OverloadMethodsDeclarationOrder" files=".*\.java" />
24-
<suppress checks="VariableDeclarationUsageDistance" files=".*\.java" />
25-
26-
<suppress checks="AbbreviationAsWordInName" files="NativeAndJGitProviderTest\.java" lines="90"/>
17+
<suppress checks="LineLength" files="GitCommitIdMojoIntegrationTest.java" />
2718

2819
</suppressions>

.github/.checkstyle/google_checks_checkstyle_8.25.xml renamed to .github/.checkstyle/google_checks_checkstyle_10.13.0.xml

Lines changed: 143 additions & 39 deletions
Large diffs are not rendered by default.

.github/.checkstyle/java.header

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* This file is part of git-commit-id-maven-plugin by Konrad 'ktoso' Malawski <[email protected]>
2+
* This file is part of git-commit-id-maven-plugin
3+
* Originally invented by Konrad 'ktoso' Malawski <[email protected]>
34
*
45
* git-commit-id-maven-plugin is free software: you can redistribute it and/or modify
56
* it under the terms of the GNU Lesser General Public License as published by

pom.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@
490490
<properties>
491491
<maven-checkstyle-plugin.version>3.3.1</maven-checkstyle-plugin.version>
492492
<!-- if you update the checkstyle version make sure you update the google_checks.xml inside the repository -->
493-
<checkstyle.version>8.25</checkstyle.version>
493+
<checkstyle.version>10.13.0</checkstyle.version>
494494
<checkstyle.config.path>${basedir}/.github/.checkstyle</checkstyle.config.path>
495495
</properties>
496496
<build>
@@ -525,7 +525,10 @@
525525
<configuration>
526526
<configLocation>${checkstyle.config.path}/google_checks_checkstyle_${checkstyle.version}.xml</configLocation>
527527
<suppressionsLocation>${checkstyle.config.path}/checkstyle-suppressions.xml</suppressionsLocation>
528-
<propertyExpansion>samedir=${checkstyle.config.path}</propertyExpansion>
528+
<propertyExpansion>
529+
samedir=${checkstyle.config.path}
530+
org.checkstyle.google.suppressionfilter.config=${checkstyle.config.path}/checkstyle-suppressions.xml
531+
</propertyExpansion>
529532
<includeTestSourceDirectory>true</includeTestSourceDirectory>
530533
<encoding>${project.reporting.outputEncoding}</encoding>
531534
<consoleOutput>true</consoleOutput>

src/main/java/pl/project13/maven/git/GitCommitIdMojo.java

Lines changed: 881 additions & 925 deletions
Large diffs are not rendered by default.

src/main/java/pl/project13/maven/git/GitDirLocator.java

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* This file is part of git-commit-id-maven-plugin by Konrad 'ktoso' Malawski <[email protected]>
2+
* This file is part of git-commit-id-maven-plugin
3+
* Originally invented by Konrad 'ktoso' Malawski <[email protected]>
34
*
45
* git-commit-id-maven-plugin is free software: you can redistribute it and/or modify
56
* it under the terms of the GNU Lesser General Public License as published by
@@ -17,27 +18,31 @@
1718

1819
package pl.project13.maven.git;
1920

20-
import org.apache.maven.project.MavenProject;
21-
import org.eclipse.jgit.lib.Constants;
22-
23-
import javax.annotation.Nonnull;
24-
import javax.annotation.Nullable;
25-
import java.io.*;
21+
import java.io.BufferedReader;
22+
import java.io.File;
23+
import java.io.FileReader;
24+
import java.io.IOException;
2625
import java.nio.file.Path;
2726
import java.util.List;
27+
import javax.annotation.Nonnull;
28+
import javax.annotation.Nullable;
29+
import org.apache.maven.project.MavenProject;
30+
import org.eclipse.jgit.lib.Constants;
2831

2932
/**
30-
* This class encapsulates logic to locate a valid .git directory of the currently used project.
31-
* If it's not already specified, this logic will try to find it.
33+
* This class encapsulates logic to locate a valid .git directory of the currently used project. If
34+
* it's not already specified, this logic will try to find it.
3235
*/
3336
public class GitDirLocator {
3437
final MavenProject mavenProject;
3538
final List<MavenProject> reactorProjects;
3639

3740
/**
3841
* Constructor to encapsulates all references required to locate a valid .git directory
42+
*
3943
* @param mavenProject The currently used (maven) project.
40-
* @param reactorProjects The list of reactor projects (sub-projects) of the current (maven) project.
44+
* @param reactorProjects The list of reactor projects (sub-projects) of the current (maven)
45+
* project.
4146
*/
4247
public GitDirLocator(MavenProject mavenProject, List<MavenProject> reactorProjects) {
4348
this.mavenProject = mavenProject;
@@ -46,10 +51,12 @@ public GitDirLocator(MavenProject mavenProject, List<MavenProject> reactorProjec
4651

4752
/**
4853
* Attempts to lookup a valid .git directory of the currently used project.
49-
* @param manuallyConfiguredDir A user has the ability to configure a git-directory with the {@code dotGitDirectory}
50-
* configuration setting. By default it should be simply {@code ${project.basedir}/.git}
51-
* @return A valid .git directory, or {@code null} if none could be found under the user specified location or within
52-
* the project or it's reactor projects.
54+
*
55+
* @param manuallyConfiguredDir A user has the ability to configure a git-directory with the
56+
* {@code dotGitDirectory} configuration setting. By default it should be simply {@code
57+
* ${project.basedir}/.git}
58+
* @return A valid .git directory, or {@code null} if none could be found under the user specified
59+
* location or within the project or it's reactor projects.
5360
*/
5461
@Nullable
5562
public File lookupGitDirectory(@Nonnull File manuallyConfiguredDir) {
@@ -142,8 +149,8 @@ private File processGitDirFile(@Nonnull File file) {
142149
}
143150

144151
/**
145-
* If the file looks like the location of a worktree, return the .git folder of the git repository of the worktree.
146-
* If not, return the file as is.
152+
* If the file looks like the location of a worktree, return the .git folder of the git repository
153+
* of the worktree. If not, return the file as is.
147154
*/
148155
static File resolveWorktree(File fileLocation) {
149156
Path parent = fileLocation.toPath().getParent();
@@ -158,8 +165,11 @@ static File resolveWorktree(File fileLocation) {
158165

159166
/**
160167
* Helper method to validate that the specified {@code File} is an existing directory.
161-
* @param fileLocation The {@code File} that should be checked if it's actually an existing directory.
162-
* @return {@code true} if the specified {@code File} is an existing directory, {@false} otherwise.
168+
*
169+
* @param fileLocation The {@code File} that should be checked if it's actually an existing
170+
* directory.
171+
* @return {@code true} if the specified {@code File} is an existing directory, {@false}
172+
* otherwise.
163173
*/
164174
private static boolean isExistingDirectory(@Nullable File fileLocation) {
165175
return fileLocation != null && fileLocation.exists() && fileLocation.isDirectory();

src/main/java/pl/project13/maven/git/PropertiesReplacer.java

Lines changed: 85 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* This file is part of git-commit-id-maven-plugin by Konrad 'ktoso' Malawski <[email protected]>
2+
* This file is part of git-commit-id-maven-plugin
3+
* Originally invented by Konrad 'ktoso' Malawski <[email protected]>
34
*
45
* git-commit-id-maven-plugin is free software: you can redistribute it and/or modify
56
* it under the terms of the GNU Lesser General Public License as published by
@@ -17,39 +18,44 @@
1718

1819
package pl.project13.maven.git;
1920

21+
import java.util.List;
22+
import java.util.Optional;
23+
import java.util.Properties;
24+
import java.util.regex.Pattern;
2025
import org.apache.maven.plugin.PluginParameterExpressionEvaluator;
2126
import pl.project13.core.log.LogInterface;
2227

23-
import java.util.*;
24-
import java.util.regex.Pattern;
25-
2628
/**
27-
* This class encapsulates logic to perform property replacements.
28-
* For a use-case refer to https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/317.
29+
* This class encapsulates logic to perform property replacements. For a use-case refer to
30+
* https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/317.
2931
*/
3032
public class PropertiesReplacer {
3133
private final LogInterface log;
3234
private final PluginParameterExpressionEvaluator expressionEvaluator;
3335

3436
/**
3537
* Constructor to encapsulates all references required to perform property replacements.
38+
*
3639
* @param log The logger to log any messages
37-
* @param expressionEvaluator Maven's PluginParameterExpressionEvaluator
38-
* (see https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/413 why it's needed)
40+
* @param expressionEvaluator Maven's PluginParameterExpressionEvaluator (see
41+
* https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/413 why it's needed)
3942
*/
40-
public PropertiesReplacer(LogInterface log, PluginParameterExpressionEvaluator expressionEvaluator) {
43+
public PropertiesReplacer(
44+
LogInterface log, PluginParameterExpressionEvaluator expressionEvaluator) {
4145
this.log = log;
4246
this.expressionEvaluator = expressionEvaluator;
4347
}
4448

4549
/**
4650
* Method that performs the actual property replacement.
51+
*
4752
* @param properties all properties that are being generated by the plugin
4853
* @param replacementProperties list of all replacement actions to perform
4954
*/
50-
public void performReplacement(Properties properties, List<ReplacementProperty> replacementProperties) {
55+
public void performReplacement(
56+
Properties properties, List<ReplacementProperty> replacementProperties) {
5157
if ((replacementProperties != null) && (properties != null)) {
52-
for (ReplacementProperty replacementProperty: replacementProperties) {
58+
for (ReplacementProperty replacementProperty : replacementProperties) {
5359
String propertyKey = replacementProperty.getProperty();
5460
if (propertyKey == null) {
5561
performReplacementOnAllGeneratedProperties(properties, replacementProperty);
@@ -60,63 +66,112 @@ public void performReplacement(Properties properties, List<ReplacementProperty>
6066
}
6167
}
6268

63-
private void performReplacementOnAllGeneratedProperties(Properties properties, ReplacementProperty replacementProperty) {
69+
private void performReplacementOnAllGeneratedProperties(
70+
Properties properties, ReplacementProperty replacementProperty) {
6471
for (String propertyName : properties.stringPropertyNames()) {
6572
String content = properties.getProperty(propertyName);
6673
String result = performReplacement(replacementProperty, content);
67-
if ((replacementProperty.getPropertyOutputSuffix() != null) && (!replacementProperty.getPropertyOutputSuffix().isEmpty())) {
74+
if ((replacementProperty.getPropertyOutputSuffix() != null)
75+
&& (!replacementProperty.getPropertyOutputSuffix().isEmpty())) {
6876
String newPropertyKey = propertyName + "." + replacementProperty.getPropertyOutputSuffix();
6977
properties.setProperty(newPropertyKey, result);
70-
log.info("apply replace on property " + propertyName + " and save to " + newPropertyKey + ": original value '" + content + "' with '" + result + "'");
78+
log.info(
79+
"apply replace on property "
80+
+ propertyName
81+
+ " and save to "
82+
+ newPropertyKey
83+
+ ": original value '"
84+
+ content
85+
+ "' with '"
86+
+ result
87+
+ "'");
7188
} else {
7289
properties.setProperty(propertyName, result);
73-
log.info("apply replace on property " + propertyName + ": original value '" + content + "' with '" + result + "'");
90+
log.info(
91+
"apply replace on property "
92+
+ propertyName
93+
+ ": original value '"
94+
+ content
95+
+ "' with '"
96+
+ result
97+
+ "'");
7498
}
7599
}
76100
}
77101

78-
private void performReplacementOnSingleProperty(Properties properties, ReplacementProperty replacementProperty, String propertyKey) {
102+
private void performReplacementOnSingleProperty(
103+
Properties properties, ReplacementProperty replacementProperty, String propertyKey) {
79104
String content = properties.getProperty(propertyKey);
80105
String result = performReplacement(replacementProperty, content);
81-
if ((replacementProperty.getPropertyOutputSuffix() != null) && (!replacementProperty.getPropertyOutputSuffix().isEmpty())) {
106+
if ((replacementProperty.getPropertyOutputSuffix() != null)
107+
&& (!replacementProperty.getPropertyOutputSuffix().isEmpty())) {
82108
String newPropertyKey = propertyKey + "." + replacementProperty.getPropertyOutputSuffix();
83109
properties.setProperty(newPropertyKey, result);
84-
log.info("apply replace on property " + propertyKey + " and save to " + newPropertyKey + ": original value '" + content + "' with '" + result + "'");
110+
log.info(
111+
"apply replace on property "
112+
+ propertyKey
113+
+ " and save to "
114+
+ newPropertyKey
115+
+ ": original value '"
116+
+ content
117+
+ "' with '"
118+
+ result
119+
+ "'");
85120
} else {
86121
properties.setProperty(propertyKey, result);
87-
log.info("apply replace on property " + propertyKey + ": original value '" + content + "' with '" + result + "'");
122+
log.info(
123+
"apply replace on property "
124+
+ propertyKey
125+
+ ": original value '"
126+
+ content
127+
+ "' with '"
128+
+ result
129+
+ "'");
88130
}
89131
}
90132

91133
private String performReplacement(ReplacementProperty replacementProperty, String content) {
92134
String evaluationContent = content;
93-
if (evaluationContent == null || evaluationContent.isEmpty() || replacementProperty.isForceValueEvaluation()) {
135+
if (evaluationContent == null
136+
|| evaluationContent.isEmpty()
137+
|| replacementProperty.isForceValueEvaluation()) {
94138
evaluationContent = replacementProperty.getValue();
95139
}
96140
String result = "";
97141
try {
98-
result = Optional
99-
.ofNullable(expressionEvaluator.evaluate(evaluationContent))
100-
.map(x -> x.toString()).orElse(evaluationContent);
142+
result =
143+
Optional.ofNullable(expressionEvaluator.evaluate(evaluationContent))
144+
.map(x -> x.toString())
145+
.orElse(evaluationContent);
101146
} catch (Exception e) {
102147
log.error("Something went wrong performing the replacement.", e);
103148
}
104149
if (replacementProperty != null) {
105-
result = performTransformationRules(replacementProperty, result, TransformationRule.ApplyEnum.BEFORE);
150+
result =
151+
performTransformationRules(
152+
replacementProperty, result, TransformationRule.ApplyEnum.BEFORE);
106153
if (replacementProperty.isRegex()) {
107-
result = replaceRegex(result, replacementProperty.getToken(), replacementProperty.getValue());
154+
result =
155+
replaceRegex(result, replacementProperty.getToken(), replacementProperty.getValue());
108156
} else {
109-
result = replaceNonRegex(result, replacementProperty.getToken(), replacementProperty.getValue());
157+
result =
158+
replaceNonRegex(result, replacementProperty.getToken(), replacementProperty.getValue());
110159
}
111-
result = performTransformationRules(replacementProperty, result, TransformationRule.ApplyEnum.AFTER);
160+
result =
161+
performTransformationRules(
162+
replacementProperty, result, TransformationRule.ApplyEnum.AFTER);
112163
}
113164
return result;
114165
}
115166

116-
private String performTransformationRules(ReplacementProperty replacementProperty, String content, TransformationRule.ApplyEnum forRule) {
167+
private String performTransformationRules(
168+
ReplacementProperty replacementProperty,
169+
String content,
170+
TransformationRule.ApplyEnum forRule) {
117171
String result = content;
118-
if ((replacementProperty.getTransformationRules() != null) && (!replacementProperty.getTransformationRules().isEmpty())) {
119-
for (TransformationRule transformationRule: replacementProperty.getTransformationRules()) {
172+
if ((replacementProperty.getTransformationRules() != null)
173+
&& (!replacementProperty.getTransformationRules().isEmpty())) {
174+
for (TransformationRule transformationRule : replacementProperty.getTransformationRules()) {
120175
if (transformationRule.getApplyRule().equals(forRule)) {
121176
result = transformationRule.getActionRule().perform(result);
122177
}

0 commit comments

Comments
 (0)