Skip to content

Commit

Permalink
bug(#3845): unlints in runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Jan 29, 2025
1 parent 922e0c6 commit b8a5a1e
Show file tree
Hide file tree
Showing 128 changed files with 275 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ public void exec() {
final Moja<?>[] mojas = {
new Moja<>(ParseMojo.class),
new Moja<>(ShakeMojo.class),
// new Moja<>(DiscoverMojo.class),
new Moja<>(ProbeMojo.class),
new Moja<>(PullMojo.class),
new Moja<>(ResolveMojo.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ private void probe() throws IOException {
for (final ForeignTojo tojo : tojos) {
final Path src = tojo.shaken();
final Collection<String> objects = this.probes(src);
System.out.println(objects);
if (!objects.isEmpty()) {
Logger.debug(this, "Probing object(s): %s", objects);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,23 @@ SOFTWARE.
<xsl:apply-templates select="o" mode="create"/>
</xsl:template>
<!-- Method base -->
<xsl:template match="o[starts-with(@base, '.') and o[1][not(eo:abstract(.))]]" mode="create" as="element()*">
<xsl:template match="o[starts-with(@base, '.')]" mode="create" as="element()*">
<xsl:variable name="first" select="o[1]"/>
<xsl:choose>
<xsl:when test="$first[eo:abstract(.)]">
<xsl:apply-templates select="o[position()&gt;1]" mode="create"/>
</xsl:when>
<xsl:when test="starts-with($first/@base, '.')">
<xsl:variable name="nested" as="element()*">
<xsl:apply-templates select="$first" mode="create"/>
</xsl:variable>
<xsl:copy-of select="$nested"/>
<xsl:apply-templates select="o[position()&gt;1]" mode="create"/>
<a>
<xsl:value-of select="concat($nested[last()]/text(), @base)"/>
</a>
<xsl:if test="ends-with($nested[last()]/text(), $first/@base)">
<a>
<xsl:value-of select="concat($nested[last()]/text(), @base)"/>
</a>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="$first" mode="create"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ SOFTWARE.
<xsl:value-of select="@line"/>
</xsl:attribute>
<xsl:attribute name="severity">
<xsl:value-of select="eo:hex-to-utf8(element()[last() - 1])"/>
<xsl:value-of select="eo:hex-to-utf8(o[last() - 1]/o[1]/text())"/>
</xsl:attribute>
<xsl:value-of select="eo:hex-to-utf8(element()[last()])"/>
<xsl:value-of select="eo:hex-to-utf8(o[last()]/o[1]/text())"/>
</xsl:element>
</xsl:template>
<xsl:template match="node()|@*">
Expand All @@ -65,19 +65,22 @@ SOFTWARE.
<!--Converts hex sting into readable UTF-8 string-->
<xsl:function name="eo:hex-to-utf8">
<xsl:param name="str"/>
<xsl:variable name="hex">0123456789ABCDEF</xsl:variable>
<xsl:variable name="hex" select="'0123456789ABCDEF'"/>
<xsl:variable name="tail" select="translate($str, '-', '')"/>
<xsl:if test="$tail">
<!-- extract first 2 digits -->
<!-- Base case: Return empty string if input is empty or invalid -->
<xsl:if test="string-length($tail) &gt;= 2">
<!-- Extract first 2 digits -->
<xsl:variable name="first" select="substring($tail, 1, 1)"/>
<xsl:variable name="second" select="substring($tail, 2, 1)"/>
<!-- get their hex values -->
<!-- Get their hex values -->
<xsl:variable name="val1" select="string-length(substring-before($hex, $first))"/>
<xsl:variable name="val2" select="string-length(substring-before($hex, $second))"/>
<!-- get the corresponding utf-8 character -->
<xsl:variable name="head" select="codepoints-to-string($val1 * 16 + $val2)"/>
<!-- recursive call with the rest of the hex string -->
<xsl:value-of select="concat($head, eo:hex-to-utf8(substring($tail, 3)))"/>
<!-- Ensure valid character range -->
<xsl:variable name="codepoint" select="$val1 * 16 + $val2"/>
<xsl:if test="$codepoint &gt; 0">
<xsl:variable name="head" select="codepoints-to-string($codepoint)"/>
<xsl:value-of select="concat($head, eo:hex-to-utf8(substring($tail, 3)))"/>
</xsl:if>
</xsl:if>
</xsl:function>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ SOFTWARE.
<xsl:choose>
<xsl:when test="@base='$' or @base='Q'">
<xsl:value-of select="eo:fqn-start(@base, $rho)"/>
<xsl:text>;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="parts" select="tokenize(@base, '\.')"/>
Expand Down
2 changes: 0 additions & 2 deletions eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,6 @@ public Iterator<Class<? extends AbstractMojo>> iterator() {
return Arrays.<Class<? extends AbstractMojo>>asList(
ParseMojo.class,
ShakeMojo.class,
// DiscoverMojo.class,
ProbeMojo.class
).iterator();
}
Expand All @@ -730,7 +729,6 @@ public Iterator<Class<? extends AbstractMojo>> iterator() {
return Arrays.<Class<? extends AbstractMojo>>asList(
ParseMojo.class,
ShakeMojo.class,
// DiscoverMojo.class,
ProbeMojo.class,
PullMojo.class
).iterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import org.cactoos.io.ResourceOf;
import org.eolang.maven.footprint.Saved;
import org.eolang.maven.hash.ChCached;
import org.eolang.maven.hash.ChRemote;
import org.eolang.maven.hash.ChText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@
*/
package org.eolang.maven.hash;

import com.yegor256.Together;
import com.yegor256.WeAreOnline;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.cactoos.Scalar;
import org.cactoos.experimental.Threads;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
Expand All @@ -37,15 +34,11 @@
* Test case for {@link CommitHashesText}.
*
* @since 0.37.0
* @todo #3122:60min Add "Reload" to the test CommitHashesTextTest#isThreadSafe
* when issue about "Reload" annotation will be solved.
* We need to reinitialize some static fields of the class
* before the test will be executed.
*/
@ExtendWith(WeAreOnline.class)
final class CommitHashesTextTest {

@Test
@ExtendWith(WeAreOnline.class)
void downloadsDefaultList() throws Exception {
MatcherAssert.assertThat(
"CommitHashesText downloads the default list of hashes from Objectionary",
Expand All @@ -56,20 +49,12 @@ void downloadsDefaultList() throws Exception {

@Test
void isThreadSafe() {
final int threads = 200;
boolean nonulls = true;
for (final boolean bool: new Threads<>(
threads,
Stream.generate(
() -> (Scalar<Boolean>) () -> new CommitHashesText().asString() != null
).limit(threads).collect(Collectors.toList())
)) {
nonulls &= bool;
}
MatcherAssert.assertThat(
"Can be used in different threads without NPE",
nonulls,
Matchers.equalTo(true)
new Together<>(
thread -> new CommitHashesText().asString() != null
),
Matchers.not(Matchers.hasItems(false))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,28 @@
---
sheets:
- /org/eolang/maven/shake/cti-adds-errors.xsl
- /org/eolang/maven/shake/add-probes.xsl
- /org/eolang/maven/shake/set-locators.xsl
asserts:
- /program/errors[count(*)=1]
- /program/errors[count(*)=2]
- /program/errors/error[@check='cti']
- /program/errors/error[@severity='warning']
- /program/errors/error[text()='This method is deprecated!']

input: |
+package org.eolang
+version 0.0.0
+unlint object-has-data
# This unit test is supposed to check the functionality of the corresponding object.
[] > just-prints-warning
eq. > @
cti
2.times 2
"warning"
"This method is deprecated!"
4
# No comments.
[] > foo
cti > @
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# The MIT License (MIT)
#
# Copyright (c) 2016-2025 Objectionary.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
---
sheets:
- /org/eolang/maven/shake/cti-adds-errors.xsl
- /org/eolang/maven/shake/add-probes.xsl
- /org/eolang/maven/shake/blank-xsd-schema.xsl
asserts:
- /program[not(errors)]
- /program/sheets[sheet='add-probes']
- /program/metas[count(meta[head='probe'])=3]
- /program/metas/meta[head='probe' and tail='Q.org']
- /program/metas/meta[head='probe' and tail='Q.org.eolang']
- /program/metas/meta[head='probe' and tail='Q.org.eolang.int']
input: |
# No comments.
[] > test
([] (^ > x)).plus.minus > s
int
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
---
skip: true
locators:
- .data .f .α0 .Δ δ=40-09-21-FB-4D-12-D8-4A
- .data .f .π >number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
---
skip: true
locators:
- .org .eolang .number
- .org .eolang .true
Expand Down
2 changes: 2 additions & 0 deletions eo-runtime/src/main/eo/org/eolang/bytes.eo
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
+rt jvm org.eolang:eo-runtime:0.0.0
+rt node eo2js-runtime:0.0.0
+version 0.0.0
+unlint object-has-data
+unlint broken-alias-second

# The object encapsulates a chain of bytes, adding a few
# convenient operations to it. Objects like `int`, `string`,
Expand Down
1 change: 1 addition & 0 deletions eo-runtime/src/main/eo/org/eolang/cti.eo
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
+home https://github.com/objectionary/eo
+package org.eolang
+version 0.0.0
+unlint object-has-data

# Compile Time Instruction (CTI).
#
Expand Down
1 change: 1 addition & 0 deletions eo-runtime/src/main/eo/org/eolang/dataized.eo
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
+home https://github.com/objectionary/eo
+package org.eolang
+version 0.0.0
+unlint object-has-data

# The object dataizes `target`, makes new instance of `bytes` from given data and behaves as result
# `bytes`.
Expand Down
1 change: 1 addition & 0 deletions eo-runtime/src/main/eo/org/eolang/error.eo
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
+rt jvm org.eolang:eo-runtime:0.0.0
+rt node eo2js-runtime:0.0.0
+version 0.0.0
+unlint object-has-data

# This object must be used in order to terminate the program
# due to an error. Just make a copy of it with any encapsulated object.
Expand Down
1 change: 1 addition & 0 deletions eo-runtime/src/main/eo/org/eolang/false.eo
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
+home https://github.com/objectionary/eo
+package org.eolang
+version 0.0.0
+unlint object-has-data

# The object is a FALSE boolean state.
[] > false
Expand Down
2 changes: 2 additions & 0 deletions eo-runtime/src/main/eo/org/eolang/fs/dir.eo
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
+rt jvm org.eolang:eo-runtime:0.0.0
+rt node eo2js-runtime:0.0.0
+version 0.0.0
+unlint object-has-data
+unlint broken-alias-second

# Directory in the file system.
# Apparently every directory is a file.
Expand Down
2 changes: 2 additions & 0 deletions eo-runtime/src/main/eo/org/eolang/fs/file.eo
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
+rt jvm org.eolang:eo-runtime:0.0.0
+rt node eo2js-runtime:0.0.0
+version 0.0.0
+unlint object-has-data
+unlint broken-ref
+unlint broken-alias-second

# The file object in the filesystem.
[path] > file
Expand Down
3 changes: 3 additions & 0 deletions eo-runtime/src/main/eo/org/eolang/fs/path.eo
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
+home https://github.com/objectionary/eo
+package org.eolang.fs
+version 0.0.0
+unlint object-has-data
+unlint broken-ref
+unlint broken-alias-second
+unlint unused-alias

# A `path` represents a path that is hierarchical and composed of a sequence of
# directory and file name elements separated by a special separator or delimiter.
Expand Down
3 changes: 3 additions & 0 deletions eo-runtime/src/main/eo/org/eolang/fs/tmpdir.eo
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
+home https://github.com/objectionary/eo
+package org.eolang.fs
+version 0.0.0
+unlint object-has-data
+unlint broken-ref
+unlint broken-alias-second
+unlint unused-alias

# Temporary directory.
# For Unix/MacOS uses the path supplied by the first environment variable
Expand Down
1 change: 1 addition & 0 deletions eo-runtime/src/main/eo/org/eolang/go.eo
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
+home https://github.com/objectionary/eo
+package org.eolang
+version 0.0.0
+unlint object-has-data
+unlint broken-ref

# Non-conditional forward and backward jumps.
Expand Down
2 changes: 2 additions & 0 deletions eo-runtime/src/main/eo/org/eolang/i16.eo
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
+rt jvm org.eolang:eo-runtime:0.0.0
+rt node eo2js-runtime:0.0.0
+version 0.0.0
+unlint object-has-data
+unlint broken-alias-second

# The 16 bits signed integer.
# Here `as-bytes` must be a `bytes` object.
Expand Down
2 changes: 2 additions & 0 deletions eo-runtime/src/main/eo/org/eolang/i32.eo
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
+rt jvm org.eolang:eo-runtime:0.0.0
+rt node eo2js-runtime:0.0.0
+version 0.0.0
+unlint object-has-data
+unlint broken-alias-second

# The 32 bits signed integer.
# Here `as-bytes` must be a `bytes` object.
Expand Down
2 changes: 2 additions & 0 deletions eo-runtime/src/main/eo/org/eolang/i64.eo
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
+rt jvm org.eolang:eo-runtime:0.0.0
+rt node eo2js-runtime:0.0.0
+version 0.0.0
+unlint object-has-data
+unlint broken-alias-second

# The 64 bits signed integer.
# Here `as-bytes` must be a `bytes` object.
Expand Down
1 change: 1 addition & 0 deletions eo-runtime/src/main/eo/org/eolang/io/bytes-as-input.eo
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
+home https://github.com/objectionary/eo
+package org.eolang.io
+version 0.0.0
+unlint object-has-data

# Makes an `input` from bytes.
# Here `bts` is sequence of bytes or an object that can be dataized
Expand Down
3 changes: 3 additions & 0 deletions eo-runtime/src/main/eo/org/eolang/io/console.eo
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
+home https://github.com/objectionary/eo
+package org.eolang.io
+version 0.0.0
+unlint object-has-data
+unlint broken-alias-second
+unlint unused-alias

# The `console` object is basic I/O object that allows to
# interact with operation system console.
Expand Down
Loading

0 comments on commit b8a5a1e

Please sign in to comment.