diff --git a/bin/release.sh b/bin/release.sh index b9dbdfb1..31237c5e 100755 --- a/bin/release.sh +++ b/bin/release.sh @@ -3,3 +3,4 @@ git pull git push mvn -B clean build-helper:parse-version release:prepare release:perform -DdevelopmentVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0-SNAPSHOT +mvn -Dproject.version=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.patchVersion} com.github.ferstl:depgraph-maven-plugin:graph scm:add -Dincludes=doc/dependency-graph.puml diff --git a/bin/run.sh b/bin/run.sh new file mode 100755 index 00000000..368281b5 --- /dev/null +++ b/bin/run.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +git pull +git push +mvn build-helper:parse-version +mvn -Dproject.version=1.0.0 com.github.ferstl:depgraph-maven-plugin:graph diff --git a/doc/dependency-graph.puml b/doc/dependency-graph.puml index 5a65fa29..6b98889d 100644 --- a/doc/dependency-graph.puml +++ b/doc/dependency-graph.puml @@ -6,4 +6,15 @@ skinparam rectangle { BackgroundColor<> lightBlue BackgroundColor<> lightGray } +rectangle "spotbugs-annotations\n\n4.8.3" as com_github_spotbugs_spotbugs_annotations_jar +rectangle "jsr305\n\n3.0.2" as com_google_code_findbugs_jsr305_jar +rectangle "codingstyle\n\n3.41.0-SNAPSHOT" as edu_hm_hafner_codingstyle_jar +rectangle "error_prone_annotations\n\n2.24.1" as com_google_errorprone_error_prone_annotations_jar +rectangle "commons-lang3\n\n3.14.0" as org_apache_commons_commons_lang3_jar +rectangle "commons-io\n\n2.15.1" as commons_io_commons_io_jar +com_github_spotbugs_spotbugs_annotations_jar -[#000000]-> com_google_code_findbugs_jsr305_jar +edu_hm_hafner_codingstyle_jar -[#000000]-> com_github_spotbugs_spotbugs_annotations_jar +edu_hm_hafner_codingstyle_jar -[#000000]-> com_google_errorprone_error_prone_annotations_jar +edu_hm_hafner_codingstyle_jar -[#000000]-> org_apache_commons_commons_lang3_jar +edu_hm_hafner_codingstyle_jar -[#000000]-> commons_io_commons_io_jar @enduml \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3320a858..517b8979 100644 --- a/pom.xml +++ b/pom.xml @@ -252,7 +252,6 @@ release deploy v@{project.version} - clean install com.github.ferstl:depgraph-maven-plugin:graph scm:add -Dincludes=doc/dependency-graph.puml @@ -724,21 +723,24 @@ - - com.github.ferstl - depgraph-maven-plugin - ${depgraph-maven-plugin.version} - - puml - compile - true - true - true - true - dependency-graph - ${project.basedir}/doc - - + + + + + com.github.ferstl + depgraph-maven-plugin + ${depgraph-maven-plugin.version} + + puml + compile + true + true + true + true + dependency-graph + ${project.basedir}/doc + + org.apache.maven.plugins maven-scm-plugin @@ -748,9 +750,6 @@ true - - - org.pitest pitest-maven diff --git a/src/main/java/edu/hm/hafner/util/LineRange.java b/src/main/java/edu/hm/hafner/util/LineRange.java index 4df6244e..de5d72c0 100644 --- a/src/main/java/edu/hm/hafner/util/LineRange.java +++ b/src/main/java/edu/hm/hafner/util/LineRange.java @@ -1,13 +1,17 @@ package edu.hm.hafner.util; import java.io.Serializable; +import java.util.NavigableSet; +import java.util.TreeSet; + +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * A line range in a source file is defined by its first and last line. * * @author Ullrich Hafner */ -public class LineRange implements Serializable { +public final class LineRange implements Serializable { private static final long serialVersionUID = -4124143085672930110L; private final int start; @@ -64,6 +68,29 @@ public int getEnd() { return end; } + /** + * Returns the lines of this line lange in a sorted set. + * + * @return the containing lines, one by one + */ + public NavigableSet getLines() { + var lines = new TreeSet(); + for (int line = getStart(); line <= getEnd(); line++) { + lines.add(line); + } + return lines; + } + + /** + * Returns whether the specified line is contained in this range. + * + * @param line the line to check + * @return {@code true} if the line is contained in this range, {@code false} otherwise + */ + public boolean contains(final int line) { + return line >= start && line <= end; + } + /** * Returns whether this range is just a single line. * @@ -74,7 +101,7 @@ public boolean isSingleLine() { } @Override - public boolean equals(final Object o) { + public boolean equals(@CheckForNull final Object o) { if (this == o) { return true; } diff --git a/src/test/java/edu/hm/hafner/util/LineRangeTest.java b/src/test/java/edu/hm/hafner/util/LineRangeTest.java index 2c969fb4..f2b79185 100644 --- a/src/test/java/edu/hm/hafner/util/LineRangeTest.java +++ b/src/test/java/edu/hm/hafner/util/LineRangeTest.java @@ -19,15 +19,31 @@ void shouldRefuseIllegalValue() { } @Test - void shouldCreateSingleLine() { - assertThat(new LineRange(5, 5)).hasStart(5).hasEnd(5).isSingleLine(); - assertThat(new LineRange(5)).hasStart(5).hasEnd(5).isSingleLine(); + void shouldFindLinesInsideAndOutsideOfLineRange() { + var lineRange = new LineRange(1, 2); - assertThat(new LineRange(5, 4)).hasStart(4).hasEnd(5).isNotSingleLine(); + assertThat(lineRange.contains(0)).isFalse(); + assertThat(lineRange.contains(1)).isTrue(); + assertThat(lineRange.contains(2)).isTrue(); + assertThat(lineRange.contains(3)).isFalse(); + assertThat(lineRange).hasStart(1).hasEnd(2).hasLines(1, 2).hasToString("[1-2]"); + + var wrongOrder = new LineRange(2, 1); + assertThat(wrongOrder.contains(0)).isFalse(); + assertThat(wrongOrder.contains(1)).isTrue(); + assertThat(wrongOrder.contains(2)).isTrue(); + assertThat(wrongOrder.contains(3)).isFalse(); + assertThat(wrongOrder).hasStart(1).hasEnd(2).hasLines(1, 2).hasToString("[1-2]"); + + var point = new LineRange(2); + assertThat(point.contains(1)).isFalse(); + assertThat(point.contains(2)).isTrue(); + assertThat(point.contains(3)).isFalse(); + assertThat(point).hasStart(2).hasEnd(2).hasLines(2).hasToString("[2-2]"); } @Test - void shouldObeyEqualsContract() { - EqualsVerifier.simple().forClass(LineRange.class).verify(); + void shouldAdhereToEquals() { + EqualsVerifier.forClass(LineRange.class).verify(); } }