Skip to content

Commit 8cbf7d5

Browse files
committed
Cleanup and fixes
1 parent 498ea50 commit 8cbf7d5

19 files changed

+416
-102
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.settings
33
bin
44
build
5+
config
56
.classpath
67
.project
78

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2019 TheRandomLabs
3+
Copyright (c) 2019-2020 TheRandomLabs
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
# CurseAPI-Minecraft
22

3-
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3+
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
44
[![Build](https://jitci.com/gh/TheRandomLabs/CurseAPI-Minecraft/svg)](https://jitci.com/gh/TheRandomLabs/CurseAPI-Minecraft)
5+
[![Dependabot](https://badgen.net/dependabot/TheRandomLabs/CurseAPI-Minecraft/?icon=dependabot)](https://dependabot.com/)
6+
7+
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/TheRandomLabs/CurseAPI-Minecraft.svg)](http://isitmaintained.com/project/TheRandomLabs/CurseAPI-Minecraft "Average time to resolve an issue")
8+
9+
<!-- [![Maven Central](https://img.shields.io/maven-central/v/com.therandomlabs.curseapi.minecraft/curseapi-minecraft.svg?style=shield)](https://maven-badges.herokuapp.com/maven-central/com.therandomlabs.curseapi.minecraft/curseapi-minecraft/)
10+
11+
[comment]: # [![Javadoc](https://javadoc.io/badge/com.therandomlabs.curseapi.minecraft/curseapi-minecraft.svg?color=blue)](https://javadoc.io/doc/com.therandomlabs.curseapi.minecraft/curseapi-minecraft)-->
512

613
An extension of [CurseAPI](https://github.com/TheRandomLabs/CurseAPI) for parsing CurseForge
714
modpack manifests and for performing more Minecraft-specific operations.

build.gradle

Lines changed: 21 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,52 @@
1-
import com.github.spotbugs.SpotBugsTask
1+
buildscript {
2+
repositories {
3+
mavenCentral()
4+
}
5+
6+
configurations.maybeCreate("pitest")
27

3-
plugins {
4-
id "java-library"
5-
id "maven-publish"
6-
id "checkstyle"
7-
id "pmd"
8-
id "com.github.spotbugs" version "3.0.0"
9-
id "net.ltgt.errorprone" version "1.1.1"
10-
id "jacoco"
8+
dependencies {
9+
classpath "info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.4.6"
10+
pitest "org.pitest:pitest-junit5-plugin:0.11"
11+
}
1112
}
1213

14+
apply from: "https://raw.githubusercontent.com/TheRandomLabs/Common-Gradle/master/build.gradle"
15+
apply plugin: "info.solidsoft.pitest"
16+
1317
group = "com.therandomlabs.curseapi.minecraft"
1418
version = "1.0.0"
1519

1620
repositories {
17-
mavenCentral()
18-
1921
maven {
2022
url "https://jitpack.io"
2123
}
2224
}
2325

2426
dependencies {
25-
implementation "com.google.guava:guava:28.2-jre"
26-
implementation "org.slf4j:slf4j-api:2.0.0-alpha1"
2727
api "com.github.TheRandomLabs:CurseAPI:master-SNAPSHOT"
2828

29-
testRuntimeOnly "org.apache.logging.log4j:log4j-core:2.13.0"
30-
testRuntimeOnly "org.apache.logging.log4j:log4j-slf4j18-impl:2.13.0"
31-
3229
testImplementation "com.github.TheRandomLabs:TRLUtils-IO:master-SNAPSHOT"
33-
34-
testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.0-M1"
35-
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.6.0-M1"
36-
testImplementation "org.assertj:assertj-core:3.14.0"
37-
38-
spotbugsPlugins "com.mebigfatguy.fb-contrib:fb-contrib:7.4.3.sb"
39-
spotbugsPlugins "com.h3xstream.findsecbugs:findsecbugs-plugin:1.10.1"
40-
spotbugsPlugins "jp.skypencil.findbugs.slf4j:bug-pattern:1.5.0@jar"
41-
42-
errorprone "com.google.errorprone:error_prone_core:2.3.4"
43-
errorproneJavac "com.google.errorprone:javac:9+181-r4173-1"
4430
}
4531

46-
test {
47-
useJUnitPlatform()
48-
finalizedBy jacocoTestReport
49-
}
5032

51-
jacocoTestCoverageVerification {
33+
/* jacocoTestCoverageVerification {
5234
violationRules {
5335
rule {
5436
element = "CLASS"
5537
5638
limit {
5739
counter = "INSTRUCTION"
5840
value = "COVEREDRATIO"
59-
minimum = 0.6
60-
}
61-
}
62-
}
63-
}
64-
65-
check.dependsOn jacocoTestCoverageVerification
66-
67-
pmd {
68-
ruleSets = []
69-
ruleSetConfig = resources.text.fromFile("config/pmd.xml")
70-
}
71-
72-
spotbugs {
73-
excludeFilter = file("config/spotbugs-exclude.xml")
74-
}
75-
76-
tasks.withType(SpotBugsTask) {
77-
reports {
78-
xml.enabled false
79-
html.enabled true
80-
}
81-
}
82-
83-
tasks.withType(JavaCompile) {
84-
options.encoding = "UTF-8"
85-
options.compilerArgs << "-Xlint:all"
86-
}
87-
88-
task sourcesJar(type: Jar, dependsOn: classes) {
89-
archiveClassifier.set("sources")
90-
from sourceSets.main.allSource
91-
}
92-
93-
task javadocJar(type: Jar) {
94-
archiveClassifier.set("javadoc")
95-
from javadoc
96-
}
97-
98-
artifacts {
99-
archives sourcesJar
100-
archives javadocJar
101-
}
102-
103-
publishing {
104-
repositories {
105-
maven {
106-
name = "GitHubPackages"
107-
url = uri("https://maven.pkg.github.com/TheRandomLabs/CurseAPI-Minecraft")
108-
109-
credentials {
110-
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
111-
password = project.findProperty("gpr.key") ?: System.getenv("PASSWORD")
41+
minimum = 0.8
11242
}
11343
}
11444
}
45+
} */
11546

116-
publications {
117-
gpr(MavenPublication) {
118-
artifact sourcesJar
119-
artifact javadocJar
120-
from components.java
121-
}
122-
}
47+
pitest {
48+
testPlugin = "junit5"
49+
threads = 4
50+
outputFormats = ["XML", "HTML"]
51+
timestampedReports = false
12352
}

config/pmd.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
55
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
66
<description>
7-
CurseAPI-Minecraft ruleset.
7+
TheRandomLabs's ruleset.
88
</description>
99

1010
<rule ref="category/java/bestpractices.xml/AvoidStringBufferField"/>
@@ -100,6 +100,7 @@
100100
<rule ref="category/java/errorprone.xml/CloneMethodMustImplementCloneable"/>
101101
<rule ref="category/java/errorprone.xml/CloneMethodReturnTypeMustMatchClassName"/>
102102
<rule ref="category/java/errorprone.xml/CloseResource"/>
103+
<rule ref="category/java/errorprone.xml/CompareObjectsWithEquals"/>
103104
<rule ref="category/java/errorprone.xml/DoNotCallGarbageCollectionExplicitly"/>
104105
<rule ref="category/java/errorprone.xml/DoNotExtendJavaLangThrowable"/>
105106
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices"/>

config/spotbugs-exclude.xml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,46 @@
11
<FindBugsFilter>
22
<Match>
3-
<Bug pattern="EXS_EXCEPTION_SOFTENING_NO_CONSTRAINTS"/>
3+
<Bug pattern="NP_UNWRITTEN_FIELD"/>
4+
</Match>
5+
6+
<Match>
7+
<Bug pattern="UWF_UNWRITTEN_FIELD"/>
48
</Match>
59

610
<Match>
711
<Bug pattern="URF_UNREAD_FIELD"/>
812
</Match>
913

1014
<Match>
11-
<Bug pattern="UWF_UNWRITTEN_FIELD"/>
15+
<Bug pattern="EXS_EXCEPTION_SOFTENING_NO_CONSTRAINTS"/>
16+
</Match>
17+
18+
<Match>
19+
<Bug pattern="LEST_LOST_EXCEPTION_STACK_TRACE"/>
20+
</Match>
21+
22+
<Match>
23+
<Bug pattern="FII_USE_METHOD_REFERENCE"/>
24+
</Match>
25+
26+
<Match>
27+
<Bug pattern="IMC_IMMATURE_CLASS_BAD_SERIALVERSIONUID"/>
28+
</Match>
29+
30+
<Match>
31+
<Bug pattern="PATH_TRAVERSAL_IN"/>
32+
</Match>
33+
34+
<Match>
35+
<Bug pattern="MDM_INETADDRESS_GETLOCALHOST"/>
36+
</Match>
37+
38+
<Match>
39+
<Bug pattern="EXS_EXCEPTION_SOFTENING_RETURN_FALSE"/>
40+
</Match>
41+
42+
<Match>
43+
<Bug pattern="DMI_HARDCODED_ABSOLUTE_FILENAME"/>
1244
</Match>
1345

1446
<Match>

src/main/java/com/therandomlabs/curseapi/minecraft/CurseAPIMinecraft.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2019-2020 TheRandomLabs
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
* this software and associated documentation files (the "Software"), to deal in
8+
* the Software without restriction, including without limitation the rights to
9+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
* the Software, and to permit persons to whom the Software is furnished to do so,
11+
* subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
23+
124
package com.therandomlabs.curseapi.minecraft;
225

326
import com.therandomlabs.curseapi.CurseAPI;

src/main/java/com/therandomlabs/curseapi/minecraft/ForgeSvcMinecraft.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2019-2020 TheRandomLabs
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
* this software and associated documentation files (the "Software"), to deal in
8+
* the Software without restriction, including without limitation the rights to
9+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
* the Software, and to permit persons to whom the Software is furnished to do so,
11+
* subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
23+
124
package com.therandomlabs.curseapi.minecraft;
225

326
import java.util.List;

src/main/java/com/therandomlabs/curseapi/minecraft/ForgeSvcMinecraftProvider.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2019-2020 TheRandomLabs
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
* this software and associated documentation files (the "Software"), to deal in
8+
* the Software without restriction, including without limitation the rights to
9+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
* the Software, and to permit persons to whom the Software is furnished to do so,
11+
* subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
23+
124
package com.therandomlabs.curseapi.minecraft;
225

326
import java.util.List;
@@ -8,6 +31,7 @@
831
import com.therandomlabs.curseapi.CurseException;
932
import com.therandomlabs.curseapi.game.CurseGameVersion;
1033
import com.therandomlabs.curseapi.util.RetrofitUtils;
34+
import org.checkerframework.checker.nullness.qual.Nullable;
1135
import org.slf4j.Logger;
1236
import org.slf4j.LoggerFactory;
1337

@@ -32,6 +56,7 @@ private ForgeSvcMinecraftProvider() {}
3256
/**
3357
* {@inheritDoc}
3458
*/
59+
@Nullable
3560
@Override
3661
public SortedSet<? extends CurseGameVersion<?>> gameVersions(int id) {
3762
MCVersions.initialize();
@@ -41,6 +66,7 @@ public SortedSet<? extends CurseGameVersion<?>> gameVersions(int id) {
4166
/**
4267
* {@inheritDoc}
4368
*/
69+
@Nullable
4470
@Override
4571
public CurseGameVersion<?> gameVersion(int gameID, String versionString) {
4672
MCVersions.initialize();
@@ -55,6 +81,10 @@ private static SortedSet<MCVersion> getVersions() {
5581
final List<MCVersion> versions =
5682
RetrofitUtils.execute(FORGESVC_MINECRAFT.getVersions());
5783

84+
if (versions == null) {
85+
throw new CurseException("Could not retrieve Minecraft versions");
86+
}
87+
5888
for (int i = 0; i < versions.size(); i++) {
5989
final MCVersion version = versions.get(i);
6090
//Initialize MCVersion#versionGroup so that the MCVersion adds itself to the

0 commit comments

Comments
 (0)