aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/actions/setup-normal-workspace/action.yml15
-rw-r--r--.github/workflows/build.yml31
-rw-r--r--.github/workflows/detekt.yml4
-rw-r--r--.gitignore2
-rw-r--r--CONTRIBUTING.md4
-rw-r--r--build.gradle.kts41
-rw-r--r--detekt/build.gradle.kts12
-rw-r--r--detekt/detekt.yml25
-rw-r--r--detekt/src/main/kotlin/grammar/AvoidColour.kt (renamed from src/main/java/at/hannibal2/skyhanni/detektrules/grammar/AvoidColour.kt)4
-rw-r--r--detekt/src/main/kotlin/grammar/GrammarRuleSetProvider.kt (renamed from src/main/java/at/hannibal2/skyhanni/detektrules/grammar/GrammarRuleSetProvider.kt)4
-rw-r--r--detekt/src/main/kotlin/root.kt1
-rw-r--r--docs/CHANGELOG.md2
-rw-r--r--gradle/libs.versions.toml3
-rw-r--r--gradlew.bat2
-rw-r--r--root.gradle.kts21
-rw-r--r--settings.gradle.kts1
-rw-r--r--src/main/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider1
-rw-r--r--versions/1.8.9/detekt/baseline.yml0
-rw-r--r--versions/1.8.9/detekt/detekt.yml3
19 files changed, 113 insertions, 63 deletions
diff --git a/.github/actions/setup-normal-workspace/action.yml b/.github/actions/setup-normal-workspace/action.yml
new file mode 100644
index 000000000..100aa9b03
--- /dev/null
+++ b/.github/actions/setup-normal-workspace/action.yml
@@ -0,0 +1,15 @@
+name: 'Setup Java, Gradle and check out the source code'
+
+runs:
+ using: composite
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+ - name: Set up JDK 21
+ uses: actions/setup-java@v4
+ with:
+ distribution: 'temurin'
+ java-version: 21
+ cache: gradle
+ - name: Setup gradle
+ uses: gradle/actions/setup-gradle@v4
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7c75f0eef..7c12349e9 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -18,15 +18,7 @@ jobs:
runs-on: ubuntu-latest
name: "Build and test"
steps:
- - uses: actions/checkout@v3
- - name: Set up JDK 21
- uses: actions/setup-java@v3
- with:
- java-version: 21
- distribution: temurin
- cache: gradle
- - name: Setup gradle
- uses: gradle/gradle-build-action@v2
+ - uses: ./.github/actions/setup-normal-workspace
- name: Build with Gradle
run: ./gradlew assemble -x test --stacktrace
- uses: actions/upload-artifact@v3
@@ -42,19 +34,22 @@ jobs:
with:
name: "Test Results"
path: versions/1.8.9/build/reports/tests/test/
+ detekt:
+ name: Run detekt
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: ./.github/actions/setup-normal-workspace
+ - name: Run detekt
+ run: |
+ ./gradlew detekt --stacktrace
+
+
preprocess:
runs-on: ubuntu-latest
name: "Build multi version"
steps:
- - uses: actions/checkout@v3
- - name: Set up JDK 21
- uses: actions/setup-java@v3
- with:
- java-version: 21
- distribution: temurin
- cache: gradle
- - name: Setup gradle
- uses: gradle/gradle-build-action@v2
+ - uses: ./.github/actions/setup-normal-workspace
- name: Enable preprocessor
run: |
mkdir -p .gradle
diff --git a/.github/workflows/detekt.yml b/.github/workflows/detekt.yml
index da0d50daf..708f9a19e 100644
--- a/.github/workflows/detekt.yml
+++ b/.github/workflows/detekt.yml
@@ -7,8 +7,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- - name: "checkout"
- uses: actions/checkout@v2
+ - name: "Checkout project"
+ uses: actions/checkout@v4
- name: "detekt"
uses: natiginfo/action-detekt-all@1.23.7
diff --git a/.gitignore b/.gitignore
index d77f4bd8b..1a89de80f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-# Use **/*.* since if a directory is ignored, children of that directory *cannot* be unignored using ! again.
+# Use **/*.* since if a grammar is ignored, children of that grammar *cannot* be unignored using ! again.
.idea/**/*.*
!.idea/icon.svg
!.idea/dictionaries/default_user.xml
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index fc0f2d5c4..47e4abff1 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -111,7 +111,7 @@ format like "- #821" to illustrate the dependency.
- Avoid using deprecated functions.
- These functions are marked for removal in future versions.
- If you're unsure why a function is deprecated or how to replace it, please ask for guidance.
-- Future JSON data objects should be made in kotlin and placed in the directory `at.hannibal2.skyhanni.data.jsonobjects`
+- Future JSON data objects should be made in kotlin and placed in the grammar `at.hannibal2.skyhanni.data.jsonobjects`
- Config files should still be made in Java.
- Please use the existing event system, or expand on it. Do not use Forge events.
- (We inject the calls with Mixin)
@@ -345,7 +345,7 @@ active. To distinguish regular comments from preprocessor comments, preprocessor
walk through what is happening here.
In 1.8.9, the code remains unchanged. **Note that this means the programmer is responsible for commenting out the unused parts.
-The preprocessor will never change the `src/` directory**.
+The preprocessor will never change the `src/` grammar**.
Next, the preprocessor converts the code to 1.12. 1.12 still has the `loadedEntityList` as well as the same name for the `WorldClient` and
`Entity` classes, so nothing is changed.
diff --git a/build.gradle.kts b/build.gradle.kts
index 0162dcf44..22f75b59a 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -20,32 +20,11 @@ plugins {
kotlin("plugin.power-assert")
`maven-publish`
id("moe.nea.shot") version "1.0.0"
- id("io.gitlab.arturbosch.detekt") version "1.23.7"
+ id("io.gitlab.arturbosch.detekt")
}
val target = ProjectTarget.values().find { it.projectPath == project.path }!!
-repositories {
- mavenCentral()
- mavenLocal()
- maven("https://maven.minecraftforge.net") {
- metadataSources {
- artifact() // We love missing POMs
- }
- }
- maven("https://repo.spongepowered.org/maven/") // mixin
- maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1") // DevAuth
- maven("https://jitpack.io") { // NotEnoughUpdates (compiled against)
- content {
- includeGroupByRegex("(com|io)\\.github\\..*")
- }
- }
- maven("https://repo.nea.moe/releases") // libautoupdate
- maven("https://maven.notenoughupdates.org/releases") // NotEnoughUpdates (dev env)
- maven("https://repo.hypixel.net/repository/Hypixel/") // mod-api
- maven("https://maven.teamresourceful.com/repository/thatgravyboat/") // DiscordIPC
-}
-
// Toolchains:
java {
toolchain.languageVersion.set(target.minecraftVersion.javaLanguageVersion)
@@ -185,9 +164,8 @@ dependencies {
implementation("net.hypixel:mod-api:0.3.1")
- compileOnly("io.gitlab.arturbosch.detekt:detekt-api:1.23.7")
- testImplementation("io.kotest:kotest-assertions-core:5.9.1")
- testImplementation("io.gitlab.arturbosch.detekt:detekt-test:1.23.7")
+ detektPlugins("org.notenoughupdates:detektrules:1.0.0")
+ detektPlugins(project(":detekt"))
}
afterEvaluate {
@@ -354,12 +332,13 @@ publishing.publications {
// Detekt:
detekt {
buildUponDefaultConfig = true // preconfigure defaults
- config.setFrom("$projectDir/detekt/detekt.yml") // point to your custom config defining rules to run, overwriting default behavior
- baseline = file("$projectDir/detekt/baseline.xml") // a way of suppressing issues before introducing detekt
- source.setFrom(
- "$projectDir/src/main/kotlin",
- "$projectDir/src/main/java"
- )
+ config.setFrom(rootProject.layout.projectDirectory.file("detekt/detekt.yml")) // point to your custom config defining rules to run, overwriting default behavior
+ baseline = file(layout.projectDirectory.file("detekt/baseline.xml")) // a way of suppressing issues before introducing detekt
+ source.setFrom(project.sourceSets.named("main").map { it.allSource })
+// source.setFrom(
+// "$projectDir/src/main/kotlin",
+// "$projectDir/src/main/java"
+// )
}
tasks.withType<Detekt>().configureEach {
diff --git a/detekt/build.gradle.kts b/detekt/build.gradle.kts
new file mode 100644
index 000000000..02c5c463a
--- /dev/null
+++ b/detekt/build.gradle.kts
@@ -0,0 +1,12 @@
+plugins {
+ kotlin("jvm")
+ id("com.google.devtools.ksp")
+}
+
+dependencies {
+ implementation("io.gitlab.arturbosch.detekt:detekt-api:1.23.7")
+ ksp(libs.autoservice.ksp)
+ implementation(libs.autoservice.annotations)
+ testImplementation("io.kotest:kotest-assertions-core:5.9.1")
+ testImplementation("io.gitlab.arturbosch.detekt:detekt-test:1.23.7")
+}
diff --git a/detekt/detekt.yml b/detekt/detekt.yml
new file mode 100644
index 000000000..31bf77bc3
--- /dev/null
+++ b/detekt/detekt.yml
@@ -0,0 +1,25 @@
+
+config:
+ validation: true
+
+GrammarRules:
+ AvoidColour:
+ active: true
+
+
+style:
+ MagicNumber: # I, Linnea Gräf, of sound mind and body, disagree with disabling this rule
+ active: false
+ UnusedParameter:
+ active: true
+ ignoreAnnotated:
+ - 'SubscribeEvent'
+ - 'HandleEvent'
+ ReturnCount:
+ active: true
+# max: 5
+ excludeGuardClauses: true
+ MaxLineLength:
+ active: true
+ maxLineLength: 140
+ excludeCommentStatements: true
diff --git a/src/main/java/at/hannibal2/skyhanni/detektrules/grammar/AvoidColour.kt b/detekt/src/main/kotlin/grammar/AvoidColour.kt
index 4b7fd2276..754148d36 100644
--- a/src/main/java/at/hannibal2/skyhanni/detektrules/grammar/AvoidColour.kt
+++ b/detekt/src/main/kotlin/grammar/AvoidColour.kt
@@ -23,8 +23,8 @@ class AvoidColour(config: Config) : Rule(config) {
)
override fun visitStringTemplateExpression(expression: KtStringTemplateExpression) {
- val text = expression.text
- if (text.contains("colour")) {
+ val text = expression.text // Be aware .getText() returns the entire span of this template, including variable names contained within. This should be rare enough of a problem for us to not care about it.
+ if (text.contains("colour", ignoreCase = true)) {
report(
CodeSmell(
issue,
diff --git a/src/main/java/at/hannibal2/skyhanni/detektrules/grammar/GrammarRuleSetProvider.kt b/detekt/src/main/kotlin/grammar/GrammarRuleSetProvider.kt
index 963ce582b..957b20147 100644
--- a/src/main/java/at/hannibal2/skyhanni/detektrules/grammar/GrammarRuleSetProvider.kt
+++ b/detekt/src/main/kotlin/grammar/GrammarRuleSetProvider.kt
@@ -1,11 +1,13 @@
package at.hannibal2.skyhanni.detektrules.grammar
+import com.google.auto.service.AutoService
import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.api.RuleSet
import io.gitlab.arturbosch.detekt.api.RuleSetProvider
+@AutoService(RuleSetProvider::class)
class GrammarRuleSetProvider : RuleSetProvider {
- override val ruleSetId: String = "grammar-rules"
+ override val ruleSetId: String = "GrammarRules"
override fun instance(config: Config): RuleSet {
return RuleSet(ruleSetId, listOf(
diff --git a/detekt/src/main/kotlin/root.kt b/detekt/src/main/kotlin/root.kt
new file mode 100644
index 000000000..9b95a398f
--- /dev/null
+++ b/detekt/src/main/kotlin/root.kt
@@ -0,0 +1 @@
+package at.hannibal2.skyhanni.detektrules
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index a0795097c..d5c307336 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -349,7 +349,7 @@
+ Fixed Mayor Detection failing when Special Mayors are in office. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2389)
+ Updated Derpy's extra tax perk to use the correct name. - Luna (https://github.com/hannibal002/SkyHanni/pull/2393)
+ Fixed Christmas presents in the Hypixel lobby being visible outside of December. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2396)
-+ Fixed the mod crashing on startup when the game directory path contains a "!". - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2427)
++ Fixed the mod crashing on startup when the game grammar path contains a "!". - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2427)
+ Fixed chat formatting for coin drops in profit trackers (Diana, Slayer, Fishing, Pest). - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2444)
+ Fixed Last Server Time Slider not functioning. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2440)
+ Fixed warning sounds being stuttered and cutting out. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2482)
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 634e49064..926ed0285 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -10,3 +10,6 @@ libautoupdate = { module = "moe.nea:libautoupdate", version.ref = "libautoupdate
headlessLwjgl = { module = "com.github.3arthqu4ke.HeadlessMc:headlessmc-lwjgl", version.ref = "headlessLwjgl" }
jbAnnotations = { module = "org.jetbrains:annotations", version.ref = "jbAnnotations" }
hotswapagentforge = { module = "moe.nea:hotswapagent-forge", version = "1.0.1" }
+autoservice_ksp = {module="dev.zacsweers.autoservice:auto-service-ksp",version="1.1.0"}
+autoservice_annotations = {module="com.google.auto.service:auto-service-annotations",version="1.1.1"}
+
diff --git a/gradlew.bat b/gradlew.bat
index 107acd32c..28f743205 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -57,7 +57,7 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo ERROR: JAVA_HOME is set to an invalid grammar: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
diff --git a/root.gradle.kts b/root.gradle.kts
index f799ed79d..408f24a32 100644
--- a/root.gradle.kts
+++ b/root.gradle.kts
@@ -8,11 +8,32 @@ plugins {
kotlin("plugin.power-assert") version "2.0.0" apply false
id("com.google.devtools.ksp") version "2.0.0-1.0.24" apply false
id("dev.architectury.architectury-pack200") version "0.1.3"
+ id("io.gitlab.arturbosch.detekt") version "1.23.7" apply false
}
allprojects {
group = "at.hannibal2.skyhanni"
version = "0.27.Beta.9"
+ repositories {
+ mavenCentral()
+ mavenLocal()
+ maven("https://maven.minecraftforge.net") {
+ metadataSources {
+ artifact() // We love missing POMs
+ }
+ }
+ maven("https://repo.spongepowered.org/maven/") // mixin
+ maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1") // DevAuth
+ maven("https://jitpack.io") { // NotEnoughUpdates (compiled against)
+ content {
+ includeGroupByRegex("(com|io)\\.github\\..*")
+ }
+ }
+ maven("https://repo.nea.moe/releases") // libautoupdate
+ maven("https://maven.notenoughupdates.org/releases") // NotEnoughUpdates (dev env)
+ maven("https://repo.hypixel.net/repository/Hypixel/") // mod-api
+ maven("https://maven.teamresourceful.com/repository/thatgravyboat/") // DiscordIPC
+ }
}
preprocess {
diff --git a/settings.gradle.kts b/settings.gradle.kts
index aaf0f02cf..6cbd9201c 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -37,6 +37,7 @@ plugins {
MultiVersionStage.initFrom(file(".gradle/private.properties"))
include("annotation-processors")
+include("detekt")
rootProject.name = "SkyHanni"
rootProject.buildFileName = "root.gradle.kts"
diff --git a/src/main/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider b/src/main/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider
deleted file mode 100644
index 74e85a359..000000000
--- a/src/main/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider
+++ /dev/null
@@ -1 +0,0 @@
-at.hannibal2.skyhanni.detektrules.grammar.GrammarRuleSetProvider
diff --git a/versions/1.8.9/detekt/baseline.yml b/versions/1.8.9/detekt/baseline.yml
deleted file mode 100644
index e69de29bb..000000000
--- a/versions/1.8.9/detekt/baseline.yml
+++ /dev/null
diff --git a/versions/1.8.9/detekt/detekt.yml b/versions/1.8.9/detekt/detekt.yml
deleted file mode 100644
index 50f05d12a..000000000
--- a/versions/1.8.9/detekt/detekt.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-grammar-rules:
- AvoidColour:
- active: true