Skip to content

Commit

Permalink
Enable spotless - fix checkstyle issues
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed May 11, 2023
1 parent 835a015 commit 4bc0511
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>${checkstyle.spotless.config}</configLocation>
<violationIgnore>MagicNumber</violationIgnore>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,38 @@ protected void execute(UpToDatePropertySetting config) throws MojoExecutionExcep
if (getLog().isDebugEnabled()) {
try {
StringBuilder msg = new StringBuilder(targetFile.getCanonicalPath());
if (!targetFile.exists()) msg.append(" (nonexistent)");
if (!targetFile.exists()) {
msg.append(" (nonexistent)");
}
msg.append("\n\tis ")
.append(upToDate ? "up to date" : "out of date")
.append(" with respect to \n\t")
.append(srcFile.getCanonicalPath());
if (!srcFile.exists()) msg.append(" (nonexistent)");
if (!srcFile.exists()) {
msg.append(" (nonexistent)");
}

getLog().debug(msg);
} catch (IOException e) {
// Just a log entry so not fatal.
}
}

if (!upToDate) break;
if (!upToDate) {
break;
}
}
} catch (MapperException e) {
throw new MojoExecutionException("", e);
}
}

// Set the property to the appropriate value, depending on whether target files are up to date WRT source files.
if (upToDate) defineProperty(config.getName(), config.getValue().trim());
else if (!StringUtils.isBlank(config.getElse()))
if (upToDate) {
defineProperty(config.getName(), config.getValue().trim());
} else if (!StringUtils.isBlank(config.getElse())) {
defineProperty(config.getName(), config.getElse().trim());
}
}

private File getFile(FileSet fileSet, boolean useOutputDirectory, String path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class ReserveListenerPortMojo extends AbstractMojo {

private static final Integer MAX_PORT_NUMBER = 65535;

private static final Object lock = new Object();
private static final Object LOCK = new Object();

/**
* A List to property names to be placed in Maven project. At least one of {@code #urls} or {@code #portNames} has
Expand Down Expand Up @@ -207,7 +207,7 @@ private ServerSocket getServerSocket() throws IOException, MojoExecutionExceptio
return new ServerSocket(0);
}
if (randomPort) {
synchronized (lock) {
synchronized (LOCK) {
List<Integer> availablePorts = randomPortList();
for (Iterator<Integer> iterator = availablePorts.iterator(); iterator.hasNext(); ) {
int port = iterator.next();
Expand All @@ -223,7 +223,7 @@ private ServerSocket getServerSocket() throws IOException, MojoExecutionExceptio
} else {
// Might be synchronizing a bit too largely, but at least that defensive approach should prevent
// threading issues (essentially possible while put/getting the plugin ctx to get the reserved ports).
synchronized (lock) {
synchronized (LOCK) {
int min = getNextPortNumber();

for (int port = min; ; ++port) {
Expand Down Expand Up @@ -371,7 +371,7 @@ private class UrlResource {

private InputStream stream;

public UrlResource(String url) throws MojoExecutionException {
UrlResource(String url) throws MojoExecutionException {
if (url.startsWith(CLASSPATH_PREFIX)) {
String resource = url.substring(CLASSPATH_PREFIX.length(), url.length());
if (resource.startsWith(SLASH_PREFIX)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ public static void createResources(File baseDir, Properties properties, long bas
for (String propertyName : properties.stringPropertyNames()) {
File file = new File(baseDir, propertyName);
File parent = file.getParentFile();
if (parent != null) parent.mkdirs();
if (parent != null) {
parent.mkdirs();
}
file.createNewFile();

// If required, set the last modification timestamp.
Expand Down

0 comments on commit 4bc0511

Please sign in to comment.