Skip to content

Commit

Permalink
no NULL -rf :eo-maven-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Oct 14, 2024
1 parent 78db2c5 commit 5d2c795
Show file tree
Hide file tree
Showing 21 changed files with 75 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,18 @@ public ChRemote(final String tag) {

@Override
public String value() {
final String result = new ChText(ChRemote.CACHE::asString, this.tag).value();
if (result == null) {
try {
final String sha = new ChText(ChRemote.CACHE::asString, this.tag).value();
Logger.debug(this, "Git sha of %s is %s", this.tag, sha);
return sha;
} catch (final ChText.NotFound ex) {
throw new IllegalArgumentException(
String.format(
"Tag '%s' doesn't exist or the list of all tags was not loaded correctly",
this.tag
)
),
ex
);
}
Logger.debug(this, "Git sha of %s is %s", this.tag, result);
return result;
}
}
21 changes: 16 additions & 5 deletions eo-maven-plugin/src/main/java/org/eolang/maven/hash/ChText.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,24 @@ public String value() {
new Split(new TextOf(this.source), "\n")
),
() -> {
throw new NotFound();
throw new NotFound(
String.format(
"Git SHA not found for the '%s' tag",
this.tag
)
);
}
)
),
"\\s+"
),
() -> {
throw new NotFound();
throw new NotFound(
String.format(
"No SHA found for the '%s' tag",
this.tag
)
);
}
)
)
Expand All @@ -106,12 +116,13 @@ public String value() {
*
* @since 0.28.11
*/
final class NotFound extends RuntimeException {
static final class NotFound extends RuntimeException {
/**
* The main constructor.
* @param cause The cause of it
*/
private NotFound() {
super(String.format("The hash wasn't found for tag %s", ChText.this.tag));
private NotFound(final String cause) {
super(cause);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ void getsCommitHashOldTag() {
@Test
void throwsCommitHashException() {
Assertions.assertThrows(
ChText.NotFound.class,
IllegalArgumentException.class,
() -> new ChRemote("nonsense").value(),
BinarizeParseTest.TO_ADD_MESSAGE
"Throws when tag is not found"
);
}

Expand Down
4 changes: 2 additions & 2 deletions eo-runtime/src/main/java/org/eolang/AtAbsent.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
/**
* Absent attribute.
*
* This class exists only because we want to have nice and informative
* <p>This class exists only because we want to have nice and informative
* error messages for the attributes that are absent, but are being
* written or read.
* written or read.</p>
*
* @since 0.1
*/
Expand Down
3 changes: 2 additions & 1 deletion eo-runtime/src/main/java/org/eolang/AtComposite.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@

/**
* Attribute that constructs object lazily.
* The attribute depends on context (argument of lambda expression).
*
* <p>The attribute depends on context (argument of lambda expression).</p>
*
* @since 0.1
*/
Expand Down
1 change: 1 addition & 0 deletions eo-runtime/src/main/java/org/eolang/AtEnvelope.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

/**
* Wrapper for {@link Attr}.
*
* @since 0.36.0
* @checkstyle DesignForExtensionCheck (100 lines)
*/
Expand Down
6 changes: 4 additions & 2 deletions eo-runtime/src/main/java/org/eolang/AtFormed.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@

/**
* Attribute that constructs object lazily.
* The main difference between this attribute and {@link AtComposite} is
*
* <p>The main difference between this attribute and {@link AtComposite} is
* it does not depend on context. It means that every new copy of the attribute
* is linked to the origin one (which was initialized first).
* is linked to the origin one (which was initialized first).</p>
*
* @since 0.36.0
*/
public final class AtFormed implements Attr {
Expand Down
1 change: 1 addition & 0 deletions eo-runtime/src/main/java/org/eolang/AtGetOnly.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

/**
* Attribute that only gets objects.
*
* @since 0.36.0
*/
final class AtGetOnly implements Attr {
Expand Down
3 changes: 2 additions & 1 deletion eo-runtime/src/main/java/org/eolang/AtOnce.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@

/**
* Attribute that retrieves object only once.
* It's highly recommended to use it with {@link AtComposite}.
*
* <p>It's highly recommended to use it with {@link AtComposite}.</p>
*
* @since 0.1
*/
Expand Down
4 changes: 3 additions & 1 deletion eo-runtime/src/main/java/org/eolang/AtRho.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@

/**
* Special attribute for \rho.
* The attribute can be set only once, and it ignores all other puts.
*
* <p>The attribute can be set only once, and it ignores all other puts.</p>
*
* @since 0.36.0
*/
final class AtRho implements Attr {
Expand Down
5 changes: 3 additions & 2 deletions eo-runtime/src/main/java/org/eolang/AtSafe.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
/**
* The attribute that catches {@link ExFailure} and
* throws {@link EOerror.ExError}.
* Every time attribute is taken from an object (when method {@link PhDefault#attr(String)}
*
* <p>Every time attribute is taken from an object (when method {@link PhDefault#take(String)}
* is called) - this attribute is being wrapped by this {@link AtSafe}.
* It allows to catch {@link ExFailure} inside encapsulated attributes and transform them into
* {@link EOerror.ExError} which is cached by {@link EOorg.EOeolang.EOtry} lately.
* {@link EOerror.ExError} which is cached by {@link EOorg.EOeolang.EOtry} lately.</p>
*
* @since 0.26
*/
Expand Down
3 changes: 2 additions & 1 deletion eo-runtime/src/main/java/org/eolang/AtSetRho.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

/**
* The attribute tries to copy object and set \rho to it.
* If the name of the attribute is {@link Attr#RHO} - just object is returned.
*
* <p>If the name of the attribute is {@link Attr#RHO} - just object is returned.</p>
*
* @since 0.36.0
*/
Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/main/java/org/eolang/AtSimple.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/**
* Default attribute that just keeps single object.
*
* The class is NOT thread-safe.
* <p>The class is NOT thread-safe.</p>
*
* @since 0.1
*/
Expand Down
4 changes: 2 additions & 2 deletions eo-runtime/src/main/java/org/eolang/AtVoid.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
/**
* Void attribute.
*
* The attribute is not yet set, but can be set. It's writable, but
* only once.
* <p>The attribute is not yet set, but can be set. It's writable, but
* only once.</p>
*
* @since 0.1
*/
Expand Down
6 changes: 4 additions & 2 deletions eo-runtime/src/main/java/org/eolang/Atom.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@

/**
* Atom.
* A native object implemented in the language EO is compiled into.
*
* <p>A native object implemented in the language EO is compiled into.
* For EO end user atoms look like magic box. That's why all atoms have
* λ function, that calculates the final object.
* λ function, that calculates the final object.</p>
*
* @since 0.36.0
*/
public interface Atom {
Expand Down
1 change: 1 addition & 0 deletions eo-runtime/src/main/java/org/eolang/AtomSafe.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

/**
* Atom that catches exceptions.
*
* @since 0.36.0
*/
public final class AtomSafe implements Atom {
Expand Down
4 changes: 2 additions & 2 deletions eo-runtime/src/main/java/org/eolang/Bytes.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
/**
* Bytes.
*
* Represents byte array of arbitrary size,
* <p>Represents byte array of arbitrary size,
* convertible to a numeric value.
* Original size is preserved by and, or and xor.
* Original size is preserved by and, or and xor.</p>
*
* @since 1.0
*/
Expand Down
6 changes: 3 additions & 3 deletions eo-runtime/src/main/java/org/eolang/ExAbstract.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
/**
* Abstract exception.
*
* The exception raised when something is not right inside
* attributes.
* <p>The exception raised when something is not right inside
* attributes.</p>
*
* @since 0.21
*/
@Versionized
Expand Down
6 changes: 4 additions & 2 deletions eo-runtime/src/main/java/org/eolang/JavaPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@

/**
* Java path.
* The class converts object path in eolang notation to java notation.
*
* <p>The class converts object path in eolang notation to java notation.
* For example
* - "org.eolang" -> "EOorg.EOeolang"
* - "org.eolang.as-bytes" -> "EOorg.EOeolang.EOas_bytes"
* - "org.eolang.as-bytes$bytes" -> "EOorg.EOeolang.EOas_bytes$EObytes"
* Since eolang allows using dashes in object names, they are converted to underscores for Java.
* Since EOLANG allows using dashes in object names, they are converted to
* underscores for Java.</p>
*
* @since 0.29
*/
Expand Down
4 changes: 2 additions & 2 deletions eo-runtime/src/main/java/org/eolang/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
/**
* Bridge between Java CLI and EO.
*
* This class has a single public static method {@code main()}, which
* <p>This class has a single public static method {@code main()}, which
* is supposed to be called by java runtime from command line. The best
* example of this class usage is in the "sandbox/canonical" directory.
* example of this class usage is in the "sandbox/canonical" directory.</p>
*
* @since 0.1
*/
Expand Down
22 changes: 11 additions & 11 deletions eo-runtime/src/test/java/org/eolang/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static void checkHeapSize() {
@Test
void printsVersion() {
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
"Prints its own version properly",
MainTest.exec("--version"),
Matchers.allOf(
Matchers.containsString("."),
Expand All @@ -67,7 +67,7 @@ void printsVersion() {
@Test
void printsHelp() {
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
"Prints help summary properly",
MainTest.exec("--help"),
Matchers.containsString("Usage: ")
);
Expand Down Expand Up @@ -102,31 +102,31 @@ void executesJvmFullRun() {
@Test
void executesJvmFullRunWithDashedObject() {
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
"Fails with the proper error message",
MainTest.exec("--verbose", "as-bytes"),
Matchers.allOf(
Matchers.containsString("Loading class EOas_bytes"),
Matchers.containsString("Can not find 'as-bytes' object")
Matchers.containsString("Can not find \"as-bytes\" object")
)
);
}

@Test
void executesJvmFullRinWithAttributeCall() {
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
"Fails with the proper error message",
MainTest.exec("--verbose", "string$as-bytes"),
Matchers.allOf(
Matchers.containsString("Loading class EOstring$EOas_bytes"),
Matchers.containsString("Can not find 'string$as-bytes' object")
Matchers.containsString("Can not find \"string$as-bytes\" object")
)
);
}

@Test
void executesJvmFullRunWithError() {
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
"Fails with the proper error message",
MainTest.exec("--verbose", "org.eolang.io.stdout"),
Matchers.containsString("Error at \"EOorg.EOeolang.EOio.EOstdout#text\" attribute")
);
Expand All @@ -135,9 +135,9 @@ void executesJvmFullRunWithError() {
@Test
void executesWithObjectNotFoundException() {
MatcherAssert.assertThat(
AtCompositeTest.TO_ADD_MESSAGE,
"Fails with the proper error message",
MainTest.exec("unavailable-name"),
Matchers.containsString("Can not find 'unavailable-name' object")
Matchers.containsString("Can not find \"unavailable-name\" object")
);
}

Expand All @@ -152,7 +152,7 @@ void readsStreamCorrectly() throws IOException {
)
)
),
StandardCharsets.UTF_8.name()
StandardCharsets.UTF_8
)
);
MatcherAssert.assertThat(
Expand All @@ -173,7 +173,7 @@ void readsSimpleStreamCorrectly() throws IOException {
)
)
),
StandardCharsets.UTF_8.name()
StandardCharsets.UTF_8
)
);
MatcherAssert.assertThat(
Expand Down

0 comments on commit 5d2c795

Please sign in to comment.