From bdfb0c504045df1127f016668ab0f60e2f7cd2a6 Mon Sep 17 00:00:00 2001 From: Andre White Date: Sat, 27 Jul 2024 23:40:35 -0600 Subject: [PATCH 1/6] :pushpin: bump gradle 8.3 -> 8.9 --- gradle/wrapper/gradle-wrapper.properties | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index db9a6b82..09523c0e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From ceb4b8e77ae861353572dd1d991bb26c7b14bf31 Mon Sep 17 00:00:00 2001 From: Andre White Date: Sat, 27 Jul 2024 23:46:52 -0600 Subject: [PATCH 2/6] :pushpin: JDK 17 -> 21 :pushpin: logback 1.4.11 -> 1.5.6 :pushpin: jacoco 0.8.10 -> 0.8.12 --- .github/workflows/sonar_analysis.yml | 6 +++--- build-logic/src/main/kotlin/code-quality.gradle.kts | 2 +- .../src/main/kotlin/djaxonomy.test-conventions.gradle.kts | 3 ++- gradle/libs.versions.toml | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/sonar_analysis.yml b/.github/workflows/sonar_analysis.yml index e01e93f2..ced510d6 100644 --- a/.github/workflows/sonar_analysis.yml +++ b/.github/workflows/sonar_analysis.yml @@ -14,10 +14,10 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: 17 + java-version: 21 distribution: zulu # Alternative distribution options are available - name: Cache SonarCloud packages uses: actions/cache@v3 @@ -35,4 +35,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: ./gradlew build sonar --info + run: ./gradlew build aggregateScoverage sonar --info diff --git a/build-logic/src/main/kotlin/code-quality.gradle.kts b/build-logic/src/main/kotlin/code-quality.gradle.kts index e7be2d74..4297571e 100644 --- a/build-logic/src/main/kotlin/code-quality.gradle.kts +++ b/build-logic/src/main/kotlin/code-quality.gradle.kts @@ -23,7 +23,7 @@ plugins { // id("com.github.hierynomus.license") id("com.diffplug.spotless") - id("org.sonarqube") + id("djaxonomy.quality-sonar") // id("com.javiersc.gradle.plugins.dependency.updates") } diff --git a/build-logic/src/main/kotlin/djaxonomy.test-conventions.gradle.kts b/build-logic/src/main/kotlin/djaxonomy.test-conventions.gradle.kts index 319d1dd7..9ecc7a71 100644 --- a/build-logic/src/main/kotlin/djaxonomy.test-conventions.gradle.kts +++ b/build-logic/src/main/kotlin/djaxonomy.test-conventions.gradle.kts @@ -54,7 +54,8 @@ sonar { ).joinToString() property("sonar.scala.coverage.reportPaths", rPath) } else { - // use Jacoco + logger.warn("SONAR: ${project.name} is not a scala project or does not have the scala plugin applied, no coverage data will be available") + // use Jacoco ? // sonar.coverage.jacoco.xmlReportPaths } val junitPaths = diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fe5e87f3..01b3b639 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,7 +11,7 @@ junit-platform = "1.10.0" kotest = "5.7.2" # @pin We all move together kotlin = "1.9.0" -logback = "1.4.11" +logback = "1.5.6" mockito = "5.5.0" monix = "3.4.1" moshi = "1.15.0" From 00768b075d3fc4786acb7747fb1e6d21f6ad8bc6 Mon Sep 17 00:00:00 2001 From: Andre White Date: Sat, 27 Jul 2024 23:50:31 -0600 Subject: [PATCH 3/6] :rotating_light: :art: set DefaultTestListener to static, string formatting --- .../ddo/grammar/antlr/DdoItemParserTest.java | 47 +++++++++---------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/subprojects/common/ddo-antlr/src/test/java/io/truthencode/ddo/grammar/antlr/DdoItemParserTest.java b/subprojects/common/ddo-antlr/src/test/java/io/truthencode/ddo/grammar/antlr/DdoItemParserTest.java index 962b970c..4c3eb830 100644 --- a/subprojects/common/ddo-antlr/src/test/java/io/truthencode/ddo/grammar/antlr/DdoItemParserTest.java +++ b/subprojects/common/ddo-antlr/src/test/java/io/truthencode/ddo/grammar/antlr/DdoItemParserTest.java @@ -6,13 +6,9 @@ import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.tree.*; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import io.truthencode.ddo.grammar.antlr.EnchantmentsParserBaseListener; -import io.truthencode.ddo.grammar.antlr.EnchantmentsParser; - import java.util.Arrays; import java.util.stream.Collectors; @@ -27,10 +23,10 @@ class DdoItemParserTest { /** * Default Listener just logs major entries / exits */ - class DefaultTestListener extends EnchantmentsParserBaseListener { - private final EnchantmentsParser parser; + static class DefaultTestListener extends io.truthencode.ddo.grammar.antlr.EnchantmentsParserBaseListener { + private final io.truthencode.ddo.grammar.antlr.EnchantmentsParser parser; - public DefaultTestListener(EnchantmentsParser parser) { + public DefaultTestListener(io.truthencode.ddo.grammar.antlr.EnchantmentsParser parser) { this.parser = parser; } @@ -57,15 +53,15 @@ void showTokenInfo(Token tok) { LOG.info(msg); } - void showLog(String tag, EnchantmentsParser.IdDeclContext ctx) { + void showLog(String tag, io.truthencode.ddo.grammar.antlr.EnchantmentsParser.IdDeclContext ctx) { int idx = ctx.getRuleIndex(); - String ph = String.format(tag + "\tid:%d \tdata:%s", idx, ctx.getText()); + String ph = String.format("%s\tid:%d \tdata:%s", tag, idx, ctx.getText()); LOG.info(ph); } void showLog(String tag, String ctx) { - String ph = String.format(tag + ":\t%s", ctx); + String ph = String.format("%s:\t%s", tag,ctx); LOG.info(ph); } @@ -97,48 +93,49 @@ public void exitEveryRule(ParserRuleContext ctx) { } @Override - public void enterParse(EnchantmentsParser.ParseContext ctx) { + public void enterParse(io.truthencode.ddo.grammar.antlr.EnchantmentsParser.ParseContext ctx) { showLog("enterParse", ctx.getText()); } @Override - public void exitParse(EnchantmentsParser.ParseContext ctx) { + public void exitParse(io.truthencode.ddo.grammar.antlr.EnchantmentsParser.ParseContext ctx) { showLog("exitParse", ctx.getText()); } @Override - public void enterIdDecl(EnchantmentsParser.IdDeclContext ctx) { + public void enterIdDecl(io.truthencode.ddo.grammar.antlr.EnchantmentsParser.IdDeclContext ctx) { showLog("enterIdDecl", ctx); } @Override - public void exitIdDecl(EnchantmentsParser.IdDeclContext ctx) { + public void exitIdDecl(io.truthencode.ddo.grammar.antlr.EnchantmentsParser.IdDeclContext ctx) { showLog("exitIdDecl", ctx.getText()); } } - final static String SomeData = "Physical Sheltering +19\n" + - "Blue Augment Slot: Empty\n" + - "Fortification +94%\n" + - "+5 Enhancement Bonus\n" + - "Competence Healing Amplification +30\n" + - "False Life +29\n" + - "Flamecleansed Fury"; + static final String SAMPLE_DATA = """ + Physical Sheltering +19 + Blue Augment Slot: Empty + Fortification +94%% + +5 Enhancement Bonus + Competence Healing Amplification +30 + False Life +29 + Flamecleansed Fury"""; @Test void canReadPercent() { // TODO: Refactor to inject tree listener assertDoesNotThrow(() -> { - walkText(SomeData); + walkText(SAMPLE_DATA); }); } @Test void canReadNumber() { assertDoesNotThrow(() -> { - walkText(SomeData); + walkText(SAMPLE_DATA); }); } @@ -148,10 +145,10 @@ void walkText(String data) { void walkText(String data, ParseTreeListener listener) { - EnchantmentsLexer lexer = new EnchantmentsLexer(CharStreams.fromString(data)); + io.truthencode.ddo.grammar.antlr.EnchantmentsLexer lexer = new io.truthencode.ddo.grammar.antlr.EnchantmentsLexer(CharStreams.fromString(data)); CommonTokenStream tokens = new CommonTokenStream(lexer); - EnchantmentsParser parser = new EnchantmentsParser(tokens); + io.truthencode.ddo.grammar.antlr.EnchantmentsParser parser = new io.truthencode.ddo.grammar.antlr.EnchantmentsParser(tokens); ParseTreeListener l = (listener != null) ? listener : new DefaultTestListener(parser); ParseTree parseTree = parser.parse(); LOG.info(String.format("parseTree has %d children", parseTree.getChildCount())); From f087661b0cc2106c77a35728589d3e7796e200ec Mon Sep 17 00:00:00 2001 From: Andre White Date: Sat, 27 Jul 2024 23:51:43 -0600 Subject: [PATCH 4/6] :green_heart: generate xml test results for coverage (jacoco deprecation of .testexec binary results) --- .../kotlin/djaxonomy.java-coverage-conventions.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-logic/src/main/kotlin/djaxonomy.java-coverage-conventions.gradle.kts b/build-logic/src/main/kotlin/djaxonomy.java-coverage-conventions.gradle.kts index c8f2a3c8..7de685e8 100644 --- a/build-logic/src/main/kotlin/djaxonomy.java-coverage-conventions.gradle.kts +++ b/build-logic/src/main/kotlin/djaxonomy.java-coverage-conventions.gradle.kts @@ -10,13 +10,13 @@ NOTICE: You must still include a kotlin app / library etc. profile as we do not */ jacoco { - toolVersion = "0.8.10" + toolVersion = "0.8.12" // reportsDirectory.set(layout.buildDirectory.dir("customJacocoReportDir")) } tasks.withType(JacocoReport::class) { reports { - xml.required.set(false) + xml.required.set(true) csv.required.set(false) // html.outputLocation.set(layout.buildDirectory.dir("jacocoHtml")) } From 5f7c8caf1640f0e197f20fb9c347f67797a9b419 Mon Sep 17 00:00:00 2001 From: Andre White Date: Sun, 28 Jul 2024 00:29:09 -0600 Subject: [PATCH 5/6] :construction_worker: Added Feat Respec Token as Special Feat. --- .../io/truthencode/ddo/model/feats/Feat.scala | 2 +- .../ddo/model/feats/FeatRespecToken.scala | 7 +++ .../ddo/model/feats/GeneralFeat.scala | 12 ------ .../ddo/model/feats/SpecialFeat.scala | 43 +++++++++++++++++++ .../ddo/model/feats/SpecialFeatTest.scala | 14 ++++++ 5 files changed, 65 insertions(+), 13 deletions(-) create mode 100644 subprojects/common/ddo-core/src/main/scala/io/truthencode/ddo/model/feats/FeatRespecToken.scala create mode 100644 subprojects/common/ddo-core/src/main/scala/io/truthencode/ddo/model/feats/SpecialFeat.scala create mode 100644 subprojects/common/ddo-core/src/test/scala/io/truthencode/ddo/model/feats/SpecialFeatTest.scala diff --git a/subprojects/common/ddo-core/src/main/scala/io/truthencode/ddo/model/feats/Feat.scala b/subprojects/common/ddo-core/src/main/scala/io/truthencode/ddo/model/feats/Feat.scala index 8f18c6ab..f9942139 100644 --- a/subprojects/common/ddo-core/src/main/scala/io/truthencode/ddo/model/feats/Feat.scala +++ b/subprojects/common/ddo-core/src/main/scala/io/truthencode/ddo/model/feats/Feat.scala @@ -113,5 +113,5 @@ object Feat extends Enum[Feat] with FeatSearchPrefix with LazyLogging { } override def values: IndexedSeq[Feat] = - GeneralFeat.values ++ ClassFeat.values ++ RacialFeat.values ++ MetaMagicFeat.values ++ DeityFeat.values ++ EpicFeat.values + GeneralFeat.values ++ ClassFeat.values ++ RacialFeat.values ++ MetaMagicFeat.values ++ DeityFeat.values ++ EpicFeat.values ++ SpecialFeat.values } diff --git a/subprojects/common/ddo-core/src/main/scala/io/truthencode/ddo/model/feats/FeatRespecToken.scala b/subprojects/common/ddo-core/src/main/scala/io/truthencode/ddo/model/feats/FeatRespecToken.scala new file mode 100644 index 00000000..54401f9c --- /dev/null +++ b/subprojects/common/ddo-core/src/main/scala/io/truthencode/ddo/model/feats/FeatRespecToken.scala @@ -0,0 +1,7 @@ +package io.truthencode.ddo.model.feats + +import io.truthencode.ddo.support.requisite.{FeatRequisiteImpl, FreeFeat} + +protected[feats] trait FeatRespecToken extends FeatRequisiteImpl with Passive with FreeFeat { + self: SpecialFeat => +} diff --git a/subprojects/common/ddo-core/src/main/scala/io/truthencode/ddo/model/feats/GeneralFeat.scala b/subprojects/common/ddo-core/src/main/scala/io/truthencode/ddo/model/feats/GeneralFeat.scala index 83b979a9..2efca7aa 100644 --- a/subprojects/common/ddo-core/src/main/scala/io/truthencode/ddo/model/feats/GeneralFeat.scala +++ b/subprojects/common/ddo-core/src/main/scala/io/truthencode/ddo/model/feats/GeneralFeat.scala @@ -242,13 +242,6 @@ object GeneralFeat * Delimits the prefix and text. */ override protected val prefixSeparator: String = ": " -// val wow1: Seq[Seq[(WeaponCategory, Int)]] = for { -// weapon <- filterByWeaponClass(weaponClass) -// a1 <- icPlus1.filter(_ == weapon) -// a2 <- icPlus2.filter(_ == weapon) -// a3 <- icPlus3.filter(_ == weapon) -// } yield Seq((a1, 1), (a2, 2), (a3, 3)) - // logger.info(s"found ${wow1.size} weapons for improved critical: ${weaponClass.entryName}") override def prefix: Option[String] = Some("Improved Critical") @@ -663,8 +656,6 @@ object GeneralFeat case object Resilience extends GeneralFeat with Resilience - // Seq(Feat.WeaponFocusBludgeon, Feat.WeaponFocusPiercing, Feat.WeaponFocusSlashing, Feat.WeaponFocusRanged, Feat.WeaponFocusThrown) - // Passive Feats // General passive feats case object Diehard extends GeneralFeat with Diehard @@ -941,8 +932,5 @@ object GeneralFeat case object CoinLordFinishingSchoolTraining extends GeneralFeat with CoinLordFinishingSchoolTraining - // Exchange feats - // case object FeatRespecToken extends Feat with FeatRespecToken - case object DraconicVitality extends GeneralFeat with DraconicVitality } diff --git a/subprojects/common/ddo-core/src/main/scala/io/truthencode/ddo/model/feats/SpecialFeat.scala b/subprojects/common/ddo-core/src/main/scala/io/truthencode/ddo/model/feats/SpecialFeat.scala new file mode 100644 index 00000000..20b257dc --- /dev/null +++ b/subprojects/common/ddo-core/src/main/scala/io/truthencode/ddo/model/feats/SpecialFeat.scala @@ -0,0 +1,43 @@ +package io.truthencode.ddo.model.feats + +import com.typesafe.scalalogging.LazyLogging +import enumeratum.Enum +import io.truthencode.ddo.model.effect.features.{Features, FeaturesImpl} +import io.truthencode.ddo.support.naming.FriendlyDisplay +import io.truthencode.ddo.support.requisite.{Inclusion, Requisite} + +/** + * Meta / special feats such as Feat Respec Tokens which generally have meta-mechanic functions. + */ +sealed trait SpecialFeat extends Feat with FriendlyDisplay with SubFeatInformation with FeaturesImpl { + self: FeatType with Requisite with Inclusion with Features => + +} + +object SpecialFeat extends Enum[SpecialFeat] with FeatSearchPrefix with FeatMatcher with LazyLogging { + + val matchFeat: PartialFunction[Feat, SpecialFeat] = { case x: SpecialFeat => + x + } + + val matchFeatById: PartialFunction[String, SpecialFeat] = { + case x: String if SpecialFeat.namesToValuesMap.contains(x) => + SpecialFeat.withNameOption(x) match { + case Some(y) => y + } + } + + /** + * Used when qualifying a search with a prefix. Examples include finding "HalfElf" from qualified + * "Race:HalfElf" + * + * @return + * A default or applied prefix + */ + override def searchPrefixSource: String = "Special" + + override def values: IndexedSeq[SpecialFeat] = findValues + + // Exchange feats + case object FeatRespecToken extends SpecialFeat with FeatRespecToken +} diff --git a/subprojects/common/ddo-core/src/test/scala/io/truthencode/ddo/model/feats/SpecialFeatTest.scala b/subprojects/common/ddo-core/src/test/scala/io/truthencode/ddo/model/feats/SpecialFeatTest.scala new file mode 100644 index 00000000..01014c73 --- /dev/null +++ b/subprojects/common/ddo-core/src/test/scala/io/truthencode/ddo/model/feats/SpecialFeatTest.scala @@ -0,0 +1,14 @@ +package io.truthencode.ddo.model.feats + +import com.typesafe.scalalogging.LazyLogging +import io.truthencode.ddo.model.feats.SpecialFeat.FeatRespecToken +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers + +class SpecialFeatTest extends AnyFunSpec with Matchers with LazyLogging { + describe("A Feat Respec Token") { + it("should be retrieved from the base Feat Search") { + Feat.values should contain(SpecialFeat.FeatRespecToken) + } + } +} From 61222e1cbb0dfb8bb8014f044c525cfe787dec3d Mon Sep 17 00:00:00 2001 From: Andre White Date: Sun, 28 Jul 2024 00:32:50 -0600 Subject: [PATCH 6/6] :construction_worker: Add sonar specific convention --- build-logic/src/main/kotlin/djaxonomy.quality-sonar.gradle.kts | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 build-logic/src/main/kotlin/djaxonomy.quality-sonar.gradle.kts diff --git a/build-logic/src/main/kotlin/djaxonomy.quality-sonar.gradle.kts b/build-logic/src/main/kotlin/djaxonomy.quality-sonar.gradle.kts new file mode 100644 index 00000000..82e29f2f --- /dev/null +++ b/build-logic/src/main/kotlin/djaxonomy.quality-sonar.gradle.kts @@ -0,0 +1,3 @@ +plugins { + id ("org.sonarqube") +} \ No newline at end of file