Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Dec 1, 2024
2 parents 50e9c32 + 7ab2740 commit ae229a4
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ SOFTWARE.
<version>12.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-manifests</artifactId>
<!-- version from the parent pom -->
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
Expand Down Expand Up @@ -191,6 +196,19 @@ SOFTWARE.
<artifactId>maven-invoker-plugin</artifactId>
<!-- version from the parent pom -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<!-- version from the parent pom -->
<configuration>
<archive>
<index>true</index>
<manifestEntries>
<Lints-Version>${project.version}</Lints-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
13 changes: 13 additions & 0 deletions src/main/java/org/eolang/lints/Defect.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/
package org.eolang.lints;

import com.jcabi.manifests.Manifests;

/**
* A single defect found.
*
Expand Down Expand Up @@ -54,6 +56,12 @@ public interface Defect {
*/
String text();

/**
* The linter's current version.
* @return Linter's current version
*/
String version();

/**
* Default.
*
Expand Down Expand Up @@ -122,6 +130,11 @@ public int line() {
public String text() {
return this.txt;
}

@Override
public String version() {
return Manifests.read("Lints-Version");
}
}

}
51 changes: 51 additions & 0 deletions src/test/java/org/eolang/lints/DefectTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016-2024 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.
*/
package org.eolang.lints;

import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;

/**
* Tests for {@link Defect}.
*
* @since 0.0.12
*/
final class DefectTest {

@Test
void returnsVersion() {
final String version = new Defect.Default(
"metas/incorrect-architect",
Severity.WARNING,
3,
"Something went wrong with an architect"
).version();
MatcherAssert.assertThat(
"Version doesn't match with expected",
version,
Matchers.equalTo("1.2.3")
);
}
}
1 change: 1 addition & 0 deletions src/test/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Lints-Version: 1.2.3

0 comments on commit ae229a4

Please sign in to comment.