Skip to content

Commit 82b5710

Browse files
committed
Merge branch '__rultor'
2 parents d7b0961 + e83b03e commit 82b5710

File tree

86 files changed

+585
-183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+585
-183
lines changed

eo-maven-plugin/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ SOFTWARE.
212212
<!-- This dependency must precede jcabi-maven-slf4j in order
213213
to enable configurable Log4j logging during testing -->
214214
</dependency>
215+
<dependency>
216+
<groupId>org.codehaus.plexus</groupId>
217+
<artifactId>plexus-utils</artifactId>
218+
<version>3.5.1</version>
219+
</dependency>
215220
<dependency>
216221
<groupId>ch.qos.reload4j</groupId>
217222
<artifactId>reload4j</artifactId>

eo-maven-plugin/src/main/java/org/eolang/maven/Moja.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public Moja<T> with(final String attr, final Object value) {
8585
* @param mojo Another mojo
8686
* @return Itself
8787
*/
88+
@SuppressWarnings("PMD.AvoidAccessibilityAlteration")
8889
public Moja<T> copy(final Object mojo) {
8990
final Collection<String> mine = new ListOf<>(
9091
new Mapped<>(
@@ -157,6 +158,7 @@ private static Collection<Field> fields(final Class<?> cls) {
157158
* can't be set to the Mojo, we can't just remove Logger.warn. On the other hand, we will
158159
* see warnings all the time during unit testing, which can be an insignificant problem.
159160
*/
161+
@SuppressWarnings("PMD.AvoidAccessibilityAlteration")
160162
private void initField(
161163
final Class<?> clazz,
162164
final AbstractMojo mojo,

eo-maven-plugin/src/main/java/org/eolang/maven/OptimizationFolder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public enum OptimizationFolder {
5959
*
6060
* @return The attribute name.
6161
*/
62-
String key() {
62+
String getKey() {
6363
return this.key;
6464
}
6565
}

eo-maven-plugin/src/main/java/org/eolang/maven/OptimizationTask.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ public Scalar<Integer> value(
123123
private Path make(final XML xml, final Path file) throws IOException {
124124
final String name = new XMLDocument(file).xpath("/program/@name").get(0);
125125
final Place place = new Place(name);
126-
final Path dir = this.paths.get(OptimizationFolder.TARGET.key());
126+
final Path dir = this.paths.get(OptimizationFolder.TARGET.getKey());
127127
final Path target = place.make(
128-
dir.resolve(this.dirs.get(OptimizationFolder.TARGET.key())), TranspileMojo.EXT
128+
dir.resolve(this.dirs.get(OptimizationFolder.TARGET.getKey())), TranspileMojo.EXT
129129
);
130130
new HmBase(dir).save(
131131
xml.toString(),
@@ -153,8 +153,8 @@ private Optimization optimization(final ForeignTojo tojo, final Optimization com
153153
res = new OptCached(
154154
common,
155155
this.paths.get(
156-
OptimizationFolder.CACHE.key()
157-
).resolve(this.dirs.get(OptimizationFolder.CACHE.key())).resolve(tojo.hash()),
156+
OptimizationFolder.CACHE.getKey()
157+
).resolve(this.dirs.get(OptimizationFolder.CACHE.getKey())).resolve(tojo.hash()),
158158
this.source.apply(tojo)
159159
);
160160
} else {

eo-maven-plugin/src/main/java/org/eolang/maven/OptimizeMojo.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ public final class OptimizeMojo extends SafeMojo {
7070
* The map with directories of OptimizeMojo.
7171
* @checkstyle DiamondOperatorCheck (10 lines)
7272
*/
73+
@SuppressWarnings("PMD.UseDiamondOperator")
7374
private static final Map<String, String> DIRECTORIES = new MapOf<String, String>(
74-
new MapEntry<>(OptimizationFolder.TARGET.key(), OptimizeMojo.DIR),
75-
new MapEntry<>(OptimizationFolder.CACHE.key(), OptimizeMojo.OPTIMIZED)
75+
new MapEntry<>(OptimizationFolder.TARGET.getKey(), OptimizeMojo.DIR),
76+
new MapEntry<>(OptimizationFolder.CACHE.getKey(), OptimizeMojo.OPTIMIZED)
7677
);
7778

7879
/**
@@ -96,8 +97,8 @@ public void exec() {
9697
this.optimization(),
9798
new OptimizationTask(
9899
new MapOf<String, Path>(
99-
new MapEntry<>(OptimizationFolder.TARGET.key(), this.targetDir.toPath()),
100-
new MapEntry<>(OptimizationFolder.CACHE.key(), this.cache)
100+
new MapEntry<>(OptimizationFolder.TARGET.getKey(), this.targetDir.toPath()),
101+
new MapEntry<>(OptimizationFolder.CACHE.getKey(), this.cache)
101102
),
102103
OptimizeMojo.DIRECTORIES,
103104
ForeignTojo::withOptimized,

eo-maven-plugin/src/main/java/org/eolang/maven/ProbeMojo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public final class ProbeMojo extends SafeMojo {
9898
);
9999

100100
@Override
101+
@SuppressWarnings("PMD.CognitiveComplexity")
101102
public void exec() throws IOException {
102103
if (this.hash == null) {
103104
this.hash = new ChCached(

eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ abstract class SafeMojo extends AbstractMojo {
259259
* @checkstyle CyclomaticComplexityCheck (70 lines)
260260
*/
261261
@Override
262+
@SuppressWarnings("PMD.CognitiveComplexity")
262263
public final void execute() throws MojoFailureException {
263264
StaticLoggerBinder.getSingleton().setMavenLog(this.getLog());
264265
if (this.skip) {
@@ -327,6 +328,7 @@ protected final ForeignTojos scopedTojos() {
327328
* @throws ExecutionException If unexpected exception happened during execution
328329
* @throws TimeoutException If timeout limit reached
329330
*/
331+
@SuppressWarnings("PMD.CloseResource")
330332
private void execWithTimeout() throws ExecutionException, TimeoutException {
331333
final ExecutorService service = Executors.newSingleThreadExecutor();
332334
try {
@@ -383,35 +385,36 @@ private static void closeTojos(final Closeable res) throws MojoFailureException
383385
*/
384386
private void exitError(final String msg, final Throwable exp)
385387
throws MojoFailureException {
388+
if (!this.unrollExitError) {
389+
return;
390+
}
386391
final MojoFailureException out = new MojoFailureException(msg, exp);
387-
if (this.unrollExitError) {
388-
final List<String> causes = SafeMojo.causes(exp);
389-
for (int pos = 0; pos < causes.size(); ++pos) {
390-
final String cause = causes.get(pos);
391-
if (cause == null) {
392-
causes.remove(pos);
393-
break;
394-
}
392+
final List<String> causes = SafeMojo.causes(exp);
393+
for (int pos = 0; pos < causes.size(); ++pos) {
394+
final String cause = causes.get(pos);
395+
if (cause == null) {
396+
causes.remove(pos);
397+
break;
398+
}
399+
}
400+
int idx = 0;
401+
while (true) {
402+
if (idx >= causes.size()) {
403+
break;
395404
}
396-
int idx = 0;
397-
while (true) {
398-
if (idx >= causes.size()) {
405+
final String cause = causes.get(idx);
406+
for (int later = idx + 1; later < causes.size(); ++later) {
407+
final String another = causes.get(later);
408+
if (another != null && cause.contains(another)) {
409+
causes.remove(idx);
410+
idx -= 1;
399411
break;
400412
}
401-
final String cause = causes.get(idx);
402-
for (int later = idx + 1; later < causes.size(); ++later) {
403-
final String another = causes.get(later);
404-
if (another != null && cause.contains(another)) {
405-
causes.remove(idx);
406-
idx -= 1;
407-
break;
408-
}
409-
}
410-
idx += 1;
411-
}
412-
for (final String cause : new LinkedHashSet<>(causes)) {
413-
Logger.error(this, cause);
414413
}
414+
idx += 1;
415+
}
416+
for (final String cause : new LinkedHashSet<>(causes)) {
417+
Logger.error(this, cause);
415418
}
416419
throw out;
417420
}

eo-maven-plugin/src/main/java/org/eolang/maven/ShakeMojo.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ public final class ShakeMojo extends SafeMojo {
6767
* The map with directories of ShakeMojo.
6868
* @checkstyle DiamondOperatorCheck (10 lines)
6969
*/
70+
@SuppressWarnings("PMD.UseDiamondOperator")
7071
private static final Map<String, String> DIRECTORIES = new MapOf<String, String>(
71-
new MapEntry<>(OptimizationFolder.TARGET.key(), ShakeMojo.DIR),
72-
new MapEntry<>(OptimizationFolder.CACHE.key(), ShakeMojo.SHAKEN)
72+
new MapEntry<>(OptimizationFolder.TARGET.getKey(), ShakeMojo.DIR),
73+
new MapEntry<>(OptimizationFolder.CACHE.getKey(), ShakeMojo.SHAKEN)
7374
);
7475

7576
/**
@@ -93,8 +94,8 @@ void exec() {
9394
this.optimization(),
9495
new OptimizationTask(
9596
new MapOf<String, Path>(
96-
new MapEntry<>(OptimizationFolder.TARGET.key(), this.targetDir.toPath()),
97-
new MapEntry<>(OptimizationFolder.CACHE.key(), this.cache)
97+
new MapEntry<>(OptimizationFolder.TARGET.getKey(), this.targetDir.toPath()),
98+
new MapEntry<>(OptimizationFolder.CACHE.getKey(), this.cache)
9899
),
99100
ShakeMojo.DIRECTORIES,
100101
ForeignTojo::withShaken,

eo-maven-plugin/src/main/java/org/eolang/maven/UnphiMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private static class Metas extends IterableEnvelope<Directive> {
161161
meta -> {
162162
final String[] pair = meta.split(" ", 2);
163163
final String head = pair[0].substring(1);
164-
if (head.equals(UnphiMojo.Metas.PACKAGE)) {
164+
if (UnphiMojo.Metas.PACKAGE.equals(head)) {
165165
throw new IllegalStateException(
166166
"+package meta is prohibited for attaching to unphied XMIR"
167167
);

eo-maven-plugin/src/main/java/org/eolang/maven/UnplaceMojo.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public final class UnplaceMojo extends SafeMojo {
7575
private Set<String> keepBinaries = new SetOf<>();
7676

7777
@Override
78+
@SuppressWarnings("PMD.AvoidAccessToStaticMembersViaThis")
7879
public void exec() throws IOException {
7980
if (this.placedTojos.isEmpty()) {
8081
Logger.info(
@@ -105,6 +106,7 @@ private void unplaceJars() {
105106
* Place what's necessary.
106107
* @throws IOException If fails
107108
*/
109+
@SuppressWarnings("PMD.AvoidAccessToStaticMembersViaThis")
108110
private void unplaceClasses() throws IOException {
109111
final Collection<PlacedTojo> classes = this.placedTojos.classes();
110112
int deleted = 0;
@@ -141,6 +143,7 @@ private void unplaceClasses() throws IOException {
141143
* @return Number of files deleted
142144
* @throws IOException If fails
143145
*/
146+
@SuppressWarnings("PMD.CognitiveComplexity")
144147
private int killThem(final Iterable<PlacedTojo> all) throws IOException {
145148
int unplaced = 0;
146149
for (final PlacedTojo tojo : all) {
@@ -195,6 +198,7 @@ private int killThem(final Iterable<PlacedTojo> all) throws IOException {
195198
* @return Number of files deleted
196199
* @throws IOException If fails
197200
*/
201+
@SuppressWarnings("PMD.AvoidAccessToStaticMembersViaThis")
198202
private int keepThem(final Iterable<? extends PlacedTojo> tojos) throws IOException {
199203
int deleted = 0;
200204
int remained = 0;

0 commit comments

Comments
 (0)