Skip to content

Commit 727c4f7

Browse files
committed
Reformat project code
1 parent 90417d2 commit 727c4f7

55 files changed

Lines changed: 784 additions & 237 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# TestGapScanner
2+
3+
## Project Setup
4+
5+
The plugin requires `JDK 11` but the project has to be compiled with `JDK 17+`, because certain dependencies require a
6+
higher JDK:
7+
8+
```
9+
[ERROR] Errors:
10+
[ERROR] TestGapScannerMojoTest.test:22 » UnsupportedClassVersion org/eclipse/core/runtime/IAdaptable has been compiled
11+
by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes
12+
class file versions up to 55.0
13+
```
14+
15+
## Running Tests
16+
17+
Before being able to run `TestGapScannerMojoTest` one has to execute `mvn clean test` so the necessary test resources
18+
are generated by Takari.

src/main/java/at/aau/Main.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package at.aau;
22

33
public class Main {
4+
45
public static void main(String[] args) {
56
System.out.println("Hello world!");
67
}
8+
79
}

src/main/java/at/aau/jacoco/JacocoCoverageCollector.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
package at.aau.jacoco;
22

3-
import at.aau.jacoco.model.Package;
4-
import at.aau.jacoco.model.Report;
5-
import jakarta.xml.bind.JAXBContext;
6-
import jakarta.xml.bind.Unmarshaller;
73
import java.io.IOException;
84
import java.nio.file.Files;
95
import java.nio.file.Path;
106
import java.util.List;
7+
118
import javax.xml.parsers.ParserConfigurationException;
129
import javax.xml.parsers.SAXParserFactory;
1310
import javax.xml.transform.sax.SAXSource;
11+
12+
import jakarta.xml.bind.JAXBContext;
13+
import jakarta.xml.bind.Unmarshaller;
14+
1415
import org.xml.sax.InputSource;
1516
import org.xml.sax.SAXException;
1617
import org.xml.sax.XMLReader;
1718

19+
import at.aau.jacoco.model.Package;
20+
import at.aau.jacoco.model.Report;
21+
1822
public final class JacocoCoverageCollector {
23+
1924
private JacocoCoverageCollector() {
2025
throw new UnsupportedOperationException("Utility class");
2126
}
@@ -40,9 +45,10 @@ private static SAXSource getXmlSourceWithoutDtd(Path jacocoReportPath)
4045
private static XMLReader getXmlReaderWithoutDtd()
4146
throws ParserConfigurationException, SAXException {
4247
SAXParserFactory spf = SAXParserFactory.newInstance();
43-
48+
4449
spf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
4550

4651
return spf.newSAXParser().getXMLReader();
4752
}
53+
4854
}

src/main/java/at/aau/jacoco/JacocoCoverageFilter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package at.aau.jacoco;
22

3+
import java.util.List;
4+
import java.util.stream.Collectors;
5+
36
import at.aau.jacoco.model.Class;
47
import at.aau.jacoco.model.Method;
58
import at.aau.jacoco.model.Package;
69
import at.aau.util.ListUtils;
7-
import java.util.List;
8-
import java.util.stream.Collectors;
910

1011
public final class JacocoCoverageFilter {
12+
1113
private static final List<String> IGNORED_METHOD_NAMES =
1214
List.of("<init>", "equals", "hashCode", "toString");
1315

@@ -37,4 +39,5 @@ private static boolean isNotIgnoredMethod(Method method) {
3739
private static boolean isUncoveredMethod(Method method) {
3840
return method.getCounters().stream().allMatch(counter -> counter.getCovered() == 0);
3941
}
42+
4043
}

src/main/java/at/aau/jacoco/model/Class.java

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package at.aau.jacoco.model;
22

3-
import at.aau.util.ListUtils;
3+
import java.util.List;
4+
import java.util.Objects;
5+
46
import jakarta.xml.bind.Unmarshaller;
57
import jakarta.xml.bind.annotation.XmlAccessType;
68
import jakarta.xml.bind.annotation.XmlAccessorType;
@@ -9,8 +11,8 @@
911
import jakarta.xml.bind.annotation.XmlRootElement;
1012
import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter;
1113
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
12-
import java.util.List;
13-
import java.util.Objects;
14+
15+
import at.aau.util.ListUtils;
1416

1517
@XmlAccessorType(XmlAccessType.FIELD)
1618
@XmlRootElement(name = "class")
@@ -57,8 +59,12 @@ public int hashCode() {
5759

5860
@Override
5961
public final boolean equals(Object o) {
60-
if (this == o) return true;
61-
if (!(o instanceof Class)) return false;
62+
if (this == o) {
63+
return true;
64+
}
65+
if (!(o instanceof Class)) {
66+
return false;
67+
}
6268

6369
Class aClass = (Class) o;
6470
return Objects.equals(name, aClass.name)
@@ -73,21 +79,18 @@ public String toString() {
7379
}
7480

7581
/**
76-
* Callback method invoked by JAXB (Java Architecture for XML Binding) after unmarshalling an XML
77-
* content tree into a Java object. This method is called after all the properties are
78-
* unmarshalled, and it allows custom initialization or processing after the unmarshalling
79-
* completes.
82+
* Callback method invoked by JAXB (Java Architecture for XML Binding) after unmarshalling an XML content tree into a
83+
* Java object. This method is called after all the properties are unmarshalled, and it allows custom initialization
84+
* or processing after the unmarshalling completes.
8085
*
8186
* <p>The method iterates over the list of {@link Method}s and sets their parent class reference
8287
* to this class instance.
8388
*
84-
* @param unmarshaller the {@link Unmarshaller} that generated this callback; provides context for
85-
* the unmarshalling process
86-
* @param parent the parent object in the object graph; can be {@code null} if this object is the
87-
* root
89+
* @param unmarshaller the {@link Unmarshaller} that generated this callback; provides context for the unmarshalling
90+
* process
91+
* @param parent the parent object in the object graph; can be {@code null} if this object is the root
8892
* @see Unmarshaller
89-
* @see <a
90-
* href="https://docs.oracle.com/javase/8/docs/api/javax/xml/bind/Unmarshaller.html#unmarshalEventCallback">
93+
* @see <a href="https://docs.oracle.com/javase/8/docs/api/javax/xml/bind/Unmarshaller.html#unmarshalEventCallback">
9194
* Unmarshaller unmarshalEventCallback Documentation</a>
9295
*/
9396
void afterUnmarshal(Unmarshaller unmarshaller, Object parent) {
@@ -97,4 +100,5 @@ void afterUnmarshal(Unmarshaller unmarshaller, Object parent) {
97100
}
98101
}
99102
}
103+
100104
}

src/main/java/at/aau/jacoco/model/Counter.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package at.aau.jacoco.model;
22

3+
import java.util.Objects;
4+
35
import jakarta.xml.bind.annotation.XmlAccessType;
46
import jakarta.xml.bind.annotation.XmlAccessorType;
57
import jakarta.xml.bind.annotation.XmlAttribute;
68
import jakarta.xml.bind.annotation.XmlRootElement;
79
import jakarta.xml.bind.annotation.adapters.CollapsedStringAdapter;
810
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
9-
import java.util.Objects;
1011

1112
@XmlAccessorType(XmlAccessType.FIELD)
1213
@XmlRootElement(name = "counter")
@@ -44,8 +45,12 @@ public int hashCode() {
4445

4546
@Override
4647
public final boolean equals(Object o) {
47-
if (this == o) return true;
48-
if (!(o instanceof Counter)) return false;
48+
if (this == o) {
49+
return true;
50+
}
51+
if (!(o instanceof Counter)) {
52+
return false;
53+
}
4954

5055
Counter counter = (Counter) o;
5156
return missed == counter.missed
@@ -65,4 +70,5 @@ public String toString() {
6570
+ covered
6671
+ '}';
6772
}
73+
6874
}

src/main/java/at/aau/jacoco/model/Group.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package at.aau.jacoco.model;
22

3-
import at.aau.util.ListUtils;
3+
import java.util.List;
4+
import java.util.Objects;
5+
46
import jakarta.xml.bind.annotation.XmlAccessType;
57
import jakarta.xml.bind.annotation.XmlAccessorType;
68
import jakarta.xml.bind.annotation.XmlAttribute;
79
import jakarta.xml.bind.annotation.XmlElement;
810
import jakarta.xml.bind.annotation.XmlRootElement;
911
import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter;
1012
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
11-
import java.util.List;
12-
import java.util.Objects;
13+
14+
import at.aau.util.ListUtils;
1315

1416
@XmlAccessorType(XmlAccessType.FIELD)
1517
@XmlRootElement(name = "group")
@@ -55,8 +57,12 @@ public int hashCode() {
5557

5658
@Override
5759
public final boolean equals(Object o) {
58-
if (this == o) return true;
59-
if (!(o instanceof Group)) return false;
60+
if (this == o) {
61+
return true;
62+
}
63+
if (!(o instanceof Group)) {
64+
return false;
65+
}
6066

6167
Group group = (Group) o;
6268
return Objects.equals(name, group.name)
@@ -69,4 +75,5 @@ public final boolean equals(Object o) {
6975
public String toString() {
7076
return "Group{" + "name='" + name + '\'' + '}';
7177
}
78+
7279
}

src/main/java/at/aau/jacoco/model/Line.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ public int hashCode() {
5757
@Override
5858
public final boolean equals(Object o) {
5959

60-
if (this == o) return true;
61-
if (!(o instanceof Line)) return false;
60+
if (this == o) {
61+
return true;
62+
}
63+
if (!(o instanceof Line)) {
64+
return false;
65+
}
6266

6367
Line line = (Line) o;
6468
return lineNumber == line.lineNumber
@@ -83,4 +87,5 @@ public String toString() {
8387
+ coveredBranchCount
8488
+ '}';
8589
}
90+
8691
}

src/main/java/at/aau/jacoco/model/Method.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package at.aau.jacoco.model;
22

3-
import at.aau.util.ListUtils;
3+
import java.util.List;
4+
import java.util.Objects;
5+
46
import com.google.common.base.MoreObjects;
57
import jakarta.xml.bind.annotation.XmlAccessType;
68
import jakarta.xml.bind.annotation.XmlAccessorType;
@@ -10,8 +12,8 @@
1012
import jakarta.xml.bind.annotation.XmlTransient;
1113
import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter;
1214
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
13-
import java.util.List;
14-
import java.util.Objects;
15+
16+
import at.aau.util.ListUtils;
1517

1618
@XmlAccessorType(XmlAccessType.FIELD)
1719
@XmlRootElement(name = "method")
@@ -32,7 +34,8 @@ public class Method {
3234
@XmlElement(name = "counter")
3335
private List<Counter> counters;
3436

35-
@XmlTransient private Class parentClass;
37+
@XmlTransient
38+
private Class parentClass;
3639

3740
public String getName() {
3841
return name;
@@ -74,8 +77,12 @@ public int hashCode() {
7477

7578
@Override
7679
public final boolean equals(Object o) {
77-
if (this == o) return true;
78-
if (!(o instanceof Method)) return false;
80+
if (this == o) {
81+
return true;
82+
}
83+
if (!(o instanceof Method)) {
84+
return false;
85+
}
7986

8087
Method method = (Method) o;
8188
return Objects.equals(name, method.name)
@@ -95,4 +102,5 @@ public String toString() {
95102
.add("parentClass", parentClass)
96103
.toString();
97104
}
105+
98106
}

0 commit comments

Comments
 (0)