Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update qulice to 0.22.2 #2997

Merged
merged 9 commits into from Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions eo-maven-plugin/pom.xml
Expand Up @@ -212,6 +212,11 @@ SOFTWARE.
<!-- This dependency must precede jcabi-maven-slf4j in order
to enable configurable Log4j logging during testing -->
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>ch.qos.reload4j</groupId>
<artifactId>reload4j</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions eo-maven-plugin/src/main/java/org/eolang/maven/Moja.java
Expand Up @@ -85,6 +85,7 @@ public Moja<T> with(final String attr, final Object value) {
* @param mojo Another mojo
* @return Itself
*/
@SuppressWarnings("PMD.AvoidAccessibilityAlteration")
public Moja<T> copy(final Object mojo) {
final Collection<String> mine = new ListOf<>(
new Mapped<>(
Expand Down Expand Up @@ -157,6 +158,7 @@ private static Collection<Field> fields(final Class<?> cls) {
* can't be set to the Mojo, we can't just remove Logger.warn. On the other hand, we will
* see warnings all the time during unit testing, which can be an insignificant problem.
*/
@SuppressWarnings("PMD.AvoidAccessibilityAlteration")
private void initField(
final Class<?> clazz,
final AbstractMojo mojo,
Expand Down
Expand Up @@ -59,7 +59,7 @@ public enum OptimizationFolder {
*
* @return The attribute name.
*/
String key() {
String getKey() {
return this.key;
}
}
Expand Up @@ -123,9 +123,9 @@ public Scalar<Integer> value(
private Path make(final XML xml, final Path file) throws IOException {
final String name = new XMLDocument(file).xpath("/program/@name").get(0);
final Place place = new Place(name);
final Path dir = this.paths.get(OptimizationFolder.TARGET.key());
final Path dir = this.paths.get(OptimizationFolder.TARGET.getKey());
final Path target = place.make(
dir.resolve(this.dirs.get(OptimizationFolder.TARGET.key())), TranspileMojo.EXT
dir.resolve(this.dirs.get(OptimizationFolder.TARGET.getKey())), TranspileMojo.EXT
);
new HmBase(dir).save(
xml.toString(),
Expand Down Expand Up @@ -153,8 +153,8 @@ private Optimization optimization(final ForeignTojo tojo, final Optimization com
res = new OptCached(
common,
this.paths.get(
OptimizationFolder.CACHE.key()
).resolve(this.dirs.get(OptimizationFolder.CACHE.key())).resolve(tojo.hash()),
OptimizationFolder.CACHE.getKey()
).resolve(this.dirs.get(OptimizationFolder.CACHE.getKey())).resolve(tojo.hash()),
this.source.apply(tojo)
);
} else {
Expand Down
Expand Up @@ -70,9 +70,10 @@ public final class OptimizeMojo extends SafeMojo {
* The map with directories of OptimizeMojo.
* @checkstyle DiamondOperatorCheck (10 lines)
*/
@SuppressWarnings("PMD.UseDiamondOperator")
private static final Map<String, String> DIRECTORIES = new MapOf<String, String>(
new MapEntry<>(OptimizationFolder.TARGET.key(), OptimizeMojo.DIR),
new MapEntry<>(OptimizationFolder.CACHE.key(), OptimizeMojo.OPTIMIZED)
new MapEntry<>(OptimizationFolder.TARGET.getKey(), OptimizeMojo.DIR),
new MapEntry<>(OptimizationFolder.CACHE.getKey(), OptimizeMojo.OPTIMIZED)
);

/**
Expand All @@ -96,8 +97,8 @@ public void exec() {
this.optimization(),
new OptimizationTask(
new MapOf<String, Path>(
new MapEntry<>(OptimizationFolder.TARGET.key(), this.targetDir.toPath()),
new MapEntry<>(OptimizationFolder.CACHE.key(), this.cache)
new MapEntry<>(OptimizationFolder.TARGET.getKey(), this.targetDir.toPath()),
new MapEntry<>(OptimizationFolder.CACHE.getKey(), this.cache)
),
OptimizeMojo.DIRECTORIES,
ForeignTojo::withOptimized,
Expand Down
Expand Up @@ -98,6 +98,7 @@ public final class ProbeMojo extends SafeMojo {
);

@Override
@SuppressWarnings("PMD.CognitiveComplexity")
public void exec() throws IOException {
if (this.hash == null) {
this.hash = new ChCached(
Expand Down
51 changes: 27 additions & 24 deletions eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java
Expand Up @@ -259,6 +259,7 @@ abstract class SafeMojo extends AbstractMojo {
* @checkstyle CyclomaticComplexityCheck (70 lines)
*/
@Override
@SuppressWarnings("PMD.CognitiveComplexity")
public final void execute() throws MojoFailureException {
StaticLoggerBinder.getSingleton().setMavenLog(this.getLog());
if (this.skip) {
Expand Down Expand Up @@ -327,6 +328,7 @@ protected final ForeignTojos scopedTojos() {
* @throws ExecutionException If unexpected exception happened during execution
* @throws TimeoutException If timeout limit reached
*/
@SuppressWarnings("PMD.CloseResource")
private void execWithTimeout() throws ExecutionException, TimeoutException {
final ExecutorService service = Executors.newSingleThreadExecutor();
try {
Expand Down Expand Up @@ -383,35 +385,36 @@ private static void closeTojos(final Closeable res) throws MojoFailureException
*/
private void exitError(final String msg, final Throwable exp)
throws MojoFailureException {
if (!this.unrollExitError) {
return;
}
final MojoFailureException out = new MojoFailureException(msg, exp);
if (this.unrollExitError) {
final List<String> causes = SafeMojo.causes(exp);
for (int pos = 0; pos < causes.size(); ++pos) {
final String cause = causes.get(pos);
if (cause == null) {
causes.remove(pos);
break;
}
final List<String> causes = SafeMojo.causes(exp);
for (int pos = 0; pos < causes.size(); ++pos) {
final String cause = causes.get(pos);
if (cause == null) {
causes.remove(pos);
break;
}
}
int idx = 0;
while (true) {
if (idx >= causes.size()) {
break;
}
int idx = 0;
while (true) {
if (idx >= causes.size()) {
final String cause = causes.get(idx);
for (int later = idx + 1; later < causes.size(); ++later) {
final String another = causes.get(later);
if (another != null && cause.contains(another)) {
causes.remove(idx);
idx -= 1;
break;
}
final String cause = causes.get(idx);
for (int later = idx + 1; later < causes.size(); ++later) {
final String another = causes.get(later);
if (another != null && cause.contains(another)) {
causes.remove(idx);
idx -= 1;
break;
}
}
idx += 1;
}
for (final String cause : new LinkedHashSet<>(causes)) {
Logger.error(this, cause);
}
idx += 1;
}
for (final String cause : new LinkedHashSet<>(causes)) {
Logger.error(this, cause);
}
throw out;
}
Expand Down
9 changes: 5 additions & 4 deletions eo-maven-plugin/src/main/java/org/eolang/maven/ShakeMojo.java
Expand Up @@ -67,9 +67,10 @@ public final class ShakeMojo extends SafeMojo {
* The map with directories of ShakeMojo.
* @checkstyle DiamondOperatorCheck (10 lines)
*/
@SuppressWarnings("PMD.UseDiamondOperator")
private static final Map<String, String> DIRECTORIES = new MapOf<String, String>(
new MapEntry<>(OptimizationFolder.TARGET.key(), ShakeMojo.DIR),
new MapEntry<>(OptimizationFolder.CACHE.key(), ShakeMojo.SHAKEN)
new MapEntry<>(OptimizationFolder.TARGET.getKey(), ShakeMojo.DIR),
new MapEntry<>(OptimizationFolder.CACHE.getKey(), ShakeMojo.SHAKEN)
);

/**
Expand All @@ -93,8 +94,8 @@ void exec() {
this.optimization(),
new OptimizationTask(
new MapOf<String, Path>(
new MapEntry<>(OptimizationFolder.TARGET.key(), this.targetDir.toPath()),
new MapEntry<>(OptimizationFolder.CACHE.key(), this.cache)
new MapEntry<>(OptimizationFolder.TARGET.getKey(), this.targetDir.toPath()),
new MapEntry<>(OptimizationFolder.CACHE.getKey(), this.cache)
),
ShakeMojo.DIRECTORIES,
ForeignTojo::withShaken,
Expand Down
Expand Up @@ -161,7 +161,7 @@ private static class Metas extends IterableEnvelope<Directive> {
meta -> {
final String[] pair = meta.split(" ", 2);
final String head = pair[0].substring(1);
if (head.equals(UnphiMojo.Metas.PACKAGE)) {
if (UnphiMojo.Metas.PACKAGE.equals(head)) {
throw new IllegalStateException(
"+package meta is prohibited for attaching to unphied XMIR"
);
Expand Down
Expand Up @@ -75,6 +75,7 @@ public final class UnplaceMojo extends SafeMojo {
private Set<String> keepBinaries = new SetOf<>();

@Override
@SuppressWarnings("PMD.AvoidAccessToStaticMembersViaThis")
public void exec() throws IOException {
if (this.placedTojos.isEmpty()) {
Logger.info(
Expand Down Expand Up @@ -105,6 +106,7 @@ private void unplaceJars() {
* Place what's necessary.
* @throws IOException If fails
*/
@SuppressWarnings("PMD.AvoidAccessToStaticMembersViaThis")
private void unplaceClasses() throws IOException {
final Collection<PlacedTojo> classes = this.placedTojos.classes();
int deleted = 0;
Expand Down Expand Up @@ -141,6 +143,7 @@ private void unplaceClasses() throws IOException {
* @return Number of files deleted
* @throws IOException If fails
*/
@SuppressWarnings("PMD.CognitiveComplexity")
private int killThem(final Iterable<PlacedTojo> all) throws IOException {
int unplaced = 0;
for (final PlacedTojo tojo : all) {
Expand Down Expand Up @@ -195,6 +198,7 @@ private int killThem(final Iterable<PlacedTojo> all) throws IOException {
* @return Number of files deleted
* @throws IOException If fails
*/
@SuppressWarnings("PMD.AvoidAccessToStaticMembersViaThis")
private int keepThem(final Iterable<? extends PlacedTojo> tojos) throws IOException {
int deleted = 0;
int remained = 0;
Expand Down
Expand Up @@ -75,12 +75,12 @@ void exec() {
this.optimization(),
new OptimizationTask(
new MapOf<String, Path>(
new MapEntry<>(OptimizationFolder.TARGET.key(), this.targetDir.toPath()),
new MapEntry<>(OptimizationFolder.CACHE.key(), this.cache)
new MapEntry<>(OptimizationFolder.TARGET.getKey(), this.targetDir.toPath()),
new MapEntry<>(OptimizationFolder.CACHE.getKey(), this.cache)
),
new MapOf<String, String>(
new MapEntry<>(OptimizationFolder.TARGET.key(), "6-verify"),
new MapEntry<>(OptimizationFolder.CACHE.key(), "verified")
new MapEntry<>(OptimizationFolder.TARGET.getKey(), "6-verify"),
new MapEntry<>(OptimizationFolder.CACHE.getKey(), "verified")
),
ForeignTojo::withVerified,
ForeignTojo::shaken
Expand Down
Expand Up @@ -162,7 +162,7 @@ private int weight(final String tag) {
*/
private int numberOfConstants() {
return (int) Stream.of(this.template.split("\\."))
.filter(s -> !s.equals("*")).count();
.filter(s -> !"*".equals(s)).count();
}

/**
Expand All @@ -173,7 +173,7 @@ private int numberOfConstants() {
private String regex() {
final List<String> keys = new LinkedList<>();
for (final String key : this.template.split("\\.")) {
if (key.equals("*")) {
if ("*".equals(key)) {
keys.add("\\w+");
} else {
keys.add(key);
Expand Down