Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .vale.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,5 @@ Microsoft.Headings = No
Microsoft.Contractions = No
Google.Contractions = No

[src/main/resources/org/eolang/motives/critical/same-line-names.md]
Google.Units = No

[src/main/resources/org/eolang/motives/atoms/not-empty-atom.md]
Google.Units = No
2 changes: 1 addition & 1 deletion src/main/java/org/eolang/lints/LtIncorrectUnlint.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ public Collection<Defect> defects(final XML xmir) throws IOException {

@Override
public String motive() throws IOException {
return new MotiveFrom("errors", "lt-incorrect-unlint").asString();
return new MotiveFrom("errors", "incorrect-unlint").asString();
}
}

This file was deleted.

29 changes: 0 additions & 29 deletions src/main/resources/org/eolang/motives/errors/noname-attribute.md

This file was deleted.

This file was deleted.

22 changes: 0 additions & 22 deletions src/main/resources/org/eolang/motives/metas/architect-duplicate.md

This file was deleted.

This file was deleted.

20 changes: 0 additions & 20 deletions src/main/resources/org/eolang/motives/metas/zero-version.md

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

53 changes: 53 additions & 0 deletions src/test/java/org/eolang/lints/PkMonoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@
*/
package org.eolang.lints;

import com.jcabi.log.Logger;
import com.tngtech.archunit.core.importer.ClassFileImporter;
import com.tngtech.archunit.core.importer.ImportOption;
import com.tngtech.archunit.lang.syntax.ArchRuleDefinition;
import com.yegor256.Together;
import io.github.secretx33.resourceresolver.PathMatchingResourcePatternResolver;
import io.github.secretx33.resourceresolver.Resource;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.cactoos.list.ListOf;
import org.cactoos.scalar.LengthOf;
import org.cactoos.set.SetOf;
Expand Down Expand Up @@ -78,6 +86,27 @@ void checksThatLintsCanBeUnlinted() {
);
}

@Test
void linksEveryMotiveFileToALint() throws Exception {
final List<String> orphans = Arrays.stream(
new PathMatchingResourcePatternResolver().getResources(
"classpath*:org/eolang/motives/**/*.md"
)
).map(PkMonoTest::shortName)
.filter(((Predicate<String>) PkMonoTest.lintNames()::contains).negate())
.distinct()
.sorted()
.collect(Collectors.toList());
MatcherAssert.assertThat(
Logger.format(
"Motive files without a corresponding lint: %[list]s. Each .md under src/main/resources/org/eolang/motives/ must match the name() of a lint produced by PkMono.",
orphans
),
orphans,
Matchers.empty()
);
}

@Test
@SuppressWarnings("JTCOP.RuleAssertionMessage")
void staysInsideThePackage() {
Expand All @@ -90,6 +119,30 @@ void staysInsideThePackage() {
);
}

/**
* Snapshot of every lint name produced by {@link PkMono}.
* @return Set of lint names
*/
private static Set<String> lintNames() {
return StreamSupport.stream(new PkMono().spliterator(), false)
.map(Lint::name).collect(Collectors.toSet());
}

/**
* Pull the lint name out of a motive resource filename.
* @param res Classpath resource for a motive markdown file
* @return Lint name (filename without {@code .md})
*/
private static String shortName(final Resource res) {
final String filename = res.getFilename();
if (filename == null) {
throw new IllegalStateException(
String.format("Resource %s has no filename", res)
);
}
return filename.replaceAll("\\.md$", "");
}

/**
* Found decorated lint of specific lint.
* @param decorate Lint
Expand Down
Loading