Openrewrite recipes ran: JavaApiBestPractices, CommonStaticAnalysis,

CodeCleanup
master
Markus Kreth 4 months ago
parent 533640b583
commit 09276b5be5
  1. 3
      pom.xml
  2. 3
      src/main/java/de/kreth/property2java/Configuration.java
  3. 4
      src/main/java/de/kreth/property2java/Generator.java
  4. 4
      src/main/java/de/kreth/property2java/cli/ArgumentConfiguration.java
  5. 3
      src/main/java/de/kreth/property2java/config/Regex.java
  6. 2
      src/main/java/de/kreth/property2java/processor/ProcessorConfiguration.java

@ -159,6 +159,9 @@
<configuration>
<activeRecipes>
<recipe>org.openrewrite.java.migrate.UpgradeToJava17</recipe>
<recipe>org.openrewrite.staticanalysis.JavaApiBestPractices</recipe>
<recipe>org.openrewrite.staticanalysis.CommonStaticAnalysis</recipe>
<recipe>org.openrewrite.staticanalysis.CodeCleanup</recipe>
</activeRecipes>
</configuration>
<dependencies>

@ -59,8 +59,7 @@ public interface Configuration {
String path = Regex.PATTERN.matcher(fileName).replaceAll(".").replaceAll("\\.", "_").replaceAll(" ", "_")
.replaceAll("/", "_");
path = WordUtils.capitalize(path, '_');
return path;
return WordUtils.capitalize(path, '_');
}
}

@ -75,13 +75,13 @@ public class Generator {
root.put("fileName", fileName);
root.put("bundle_base_name", fileName.substring(0, min(fileName.length(), fileName.lastIndexOf('.'))));
root.put("classname", config.mapFilenameToClassName(fileName));
if (config.getOptions().isEmpty() == false) {
if (!config.getOptions().isEmpty()) {
root.put("options", config.getOptions());
List<String> imports = config.getOptions().stream()
.map(GeneratorOptions::getAdditionalImport)
.flatMap(Arrays::stream)
.collect(Collectors.toList());
if (imports.isEmpty() == false) {
if (!imports.isEmpty()) {
root.put("imports", imports);
}
}

@ -14,7 +14,7 @@ import java.util.Map;
import de.kreth.property2java.Configuration;
public class ArgumentConfiguration implements Configuration {
public final class ArgumentConfiguration implements Configuration {
private final String packageName;
@ -51,7 +51,7 @@ public class ArgumentConfiguration implements Configuration {
@Override
public Writer outWriter(String fileName) throws IOException {
File dir;
if (packageName != null && packageName.isBlank() == false) {
if (packageName != null && !packageName.isBlank()) {
dir = new File(rootPath.toFile(), packageName.replace('.', File.separatorChar));
} else {
dir = rootPath.toFile();

@ -5,4 +5,7 @@ import java.util.regex.Pattern;
public class Regex {
public static final Pattern PATTERN = Pattern.compile("_[a-z]{2}(_[A-Z]{2})?\\.");
private Regex() {
}
}

@ -90,7 +90,7 @@ public class ProcessorConfiguration implements Configuration {
return new Builder(filer, element);
}
static class Builder {
static final class Builder {
public GeneratorOptions[] options;
private final Filer filer;
private final Element element;

Loading…
Cancel
Save