Skip to content

Replace unmaintained deps: Spek2→Kotest, logback-contrib→JsonEncoder#112

Merged
henrist merged 1 commit intomasterfrom
modernize-deps
Feb 13, 2026
Merged

Replace unmaintained deps: Spek2→Kotest, logback-contrib→JsonEncoder#112
henrist merged 1 commit intomasterfrom
modernize-deps

Conversation

@henrist
Copy link
Member

@henrist henrist commented Feb 13, 2026

Summary

  • Spek2 → Kotest: Migrate test framework from Spek2 (last release 2021) to Kotest DescribeSpec, which has near-identical describe/it syntax. Already used kotest-assertions-core for matchers.
  • logback-contrib → built-in JsonEncoder: Replace unmaintained logback-json-classic (last release 2016) and logback-gson-formatter with logback 1.5+ built-in JsonEncoder.
  • Remove duplicate stdlib deps: Drop two redundant kotlin-stdlib-jdk8 declarations (unnecessary in Kotlin 2.x).
  • Minor test cleanups: Remove duplicate test rows, simplify Moshi JSON builder to string literal, use associate instead of map{}.toMap().

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated test framework to use Kotest, improving test infrastructure and maintainability.
    • Removed unused dependencies for reduced build footprint.
    • Simplified logging configuration for better performance.
    • Minor code optimizations for efficiency.

…nEncoder

- Migrate test framework from Spek2 (stagnant since 2021) to Kotest DescribeSpec
- Replace logback-contrib JSON logging with logback 1.5+ built-in JsonEncoder
- Remove duplicate kotlin-stdlib-jdk8 declarations
- Simplify test helpers and remove duplicate test rows
@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

📝 Walkthrough

Walkthrough

This PR migrates the test framework from Spek to Kotest, updates logging configuration and dependencies, and applies minor refactoring. The test suite is restructured from Spek's object-based approach to Kotest's DescribeSpec class-based pattern while preserving test logic.

Changes

Cohort / File(s) Summary
Build Configuration
build.gradle.kts
Removed Kotlin stdlib for JDK 8, removed logback JSON dependencies (logback-json-classic, logback-gson-formatter), replaced Spek test dependencies with Kotest, and updated test configuration from includeEngines("spek2") to useJUnitPlatform().
Logging Configuration
src/main/resources/logback.xml
Simplified JSON encoding approach by replacing LayoutWrappingEncoder with nested JsonLayout configuration to a single JsonEncoder element for STDOUT appender.
Test Framework Migration
src/test/kotlin/no/foreningenbs/usersapi/MainSpec.kt, src/test/kotlin/no/foreningenbs/usersapi/api/InvalidateCacheSpec.kt, src/test/kotlin/no/foreningenbs/usersapi/hmac/HmacSpec.kt
Migrated test specifications from Spek object-based specs to Kotest DescribeSpec class-based specs, updated imports, and restructured test bodies. MainSpec also inlined memoized structures into direct test blocks with inline assertions.
Test Utilities
src/test/kotlin/no/foreningenbs/usersapi/TestHelpers.kt
Refactored map construction in mockGroups creation from .map { ... }.toMap() to .associate { ... } for more idiomatic Kotlin style.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

🐰 Spek hops away, Kotest bounds in,
Tests now describe with DescribeSpec cheer,
Logback encodes a cleaner spin,
The warren's test suite, refined and clear!
Gradle builds bright in the spring sunshine.

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main changes: replacing Spek2 with Kotest and logback-contrib with JsonEncoder, which directly corresponds to the primary objectives and file modifications.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into master

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch modernize-deps

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/main/resources/logback.xml`:
- Line 4: The logback configuration now uses the built-in JsonEncoder (encoder
class="ch.qos.logback.classic.encoder.JsonEncoder") so remove the
now-unnecessary dependencies (logback-json-classic and logback-gson-formatter)
from the build configuration, ensure Logback is upgraded to v1.5.29+ in your
dependency manifest, and validate/adjust any log ingestion pipelines or
dashboards that relied on the prior JsonLayout+GsonFormatter schema (update
mappings or configure JsonEncoder properties to match expected field/timestamp
names if needed).

<appendLineSeparator>true</appendLineSeparator>
</layout>
</encoder>
<encoder class="ch.qos.logback.classic.encoder.JsonEncoder"/>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Check build.gradle.kts for logback version and dependencies
find . -name "build.gradle.kts" -type f | head -5

Repository: blindern/users-api

Length of output: 80


🏁 Script executed:

# Also check for build.gradle files
find . -name "build.gradle" -type f | head -5

Repository: blindern/users-api

Length of output: 44


🏁 Script executed:

# Search for logback dependencies in gradle files
rg "logback" -t gradle

Repository: blindern/users-api

Length of output: 210


🏁 Script executed:

# Read build.gradle.kts to check logback version
cat build.gradle.kts

Repository: blindern/users-api

Length of output: 2753


🏁 Script executed:

# Search for logback references in all files
rg "logback" -A 2 -B 2

Repository: blindern/users-api

Length of output: 870


🏁 Script executed:

# Check the actual logback.xml file
cat src/main/resources/logback.xml

Repository: blindern/users-api

Length of output: 398


🏁 Script executed:

# Check git history to see what changed
git log --oneline -n 20 -- src/main/resources/logback.xml build.gradle.kts 2>/dev/null || echo "Git history not available"

Repository: blindern/users-api

Length of output: 147


🏁 Script executed:

# Check git diff to see what was removed/added
git diff HEAD~5..HEAD -- src/main/resources/logback.xml build.gradle.kts 2>/dev/null | head -100 || echo "Git diff not available"

Repository: blindern/users-api

Length of output: 44


🌐 Web query:

logback JsonEncoder 1.5 introduction release notes

💡 Result:

JsonEncoder was not first introduced in Logback 1.5.x. It first appeared in the release notes for Logback 1.3.8 / 1.4.8 (2023-06-13): “Logback now ships with JsonEncoder … in Newline delimited JSON (ndjson) format.” [1]

In the Logback 1.5.0 release (2024-02-16), the release notes call out JsonEncoder enhancements: you can enable/disable all top-level JSON members, and an optional (disabled-by-default) "formattedMessage" member was added. [1]

Related 1.5.x JsonEncoder notes include:

  • 1.5.10 (2024-10-12): fix for invalid JSON when some fields (notably throwable) are disabled. [1]
  • 1.5.21 (2025-11-10): JsonEncoder made friendlier for subclassing. [1]

Source: Logback News / release notes page. [1]


🌐 Web query:

logback JsonLayout GsonFormatter vs JsonEncoder differences

💡 Result:

1) ch.qos.logback.contrib.json.classic.JsonLayout (logback-contrib)

  • Type: Layout (produces a JSON string); typically used via LayoutWrappingEncoder (i.e., it’s not an Encoder itself).
  • JSON library: Pluggable via jsonFormatter (commonly ch.qos.logback.contrib.jackson.JacksonJsonFormatter). [1]
  • Status / direction: The logback-contrib project was archived, and logback maintainers point people to Logback’s built-in JsonEncoder as an alternative. [2]

2) GsonFormatter (usually: de.gessnerfl.logback:logback-gson-formatter)

  • What it is: A third‑party JSON formatter module that plugs into logback-contrib’s JsonLayout to serialize via Google Gson (instead of Jackson). It depends on logback-json-core and gson. [3]
  • Scope: It does not replace JsonLayout; it’s only the formatter used by JsonLayout.

3) ch.qos.logback.classic.encoder.JsonEncoder (built into Logback)

  • Type: Encoder (writes bytes directly) and outputs JSON Lines (one JSON object per log event/line). [4][1]
  • Configuration model: Lots of boolean switches to include/exclude fields (timestamp, MDC, markers, arguments, throwable/stacktrace, etc.). [4]
  • Key practical difference vs JsonLayout: This is now the “native” Logback JSON option (no logback-contrib layout/formatter layering). [2][1]

Quick “which should I use?” rule of thumb

  • Want built-in Logback JSON with JSON Lines and configurable standard fields → Logback JsonEncoder. [4][1]
  • You already use logback-contrib JsonLayout and just want Gson instead of Jackson → JsonLayout + Gson formatter module. [3][1]
  • Need Logstash-focused JSON with rich structured logging features (providers/composite encoders, custom fields, etc.) → consider logstash-logback-encoder (LogstashEncoder / composite encoders). [5]

Sources
[1] Logback manual – Encoders / JsonEncoder section: https://logback.qos.ch/manual/encoders.html
[2] logback-user mailing list (May 17, 2024): logback-contrib archived; suggestion to use Logback JsonEncoder: https://mailman3.qos.ch/hyperkitty/list/logback-user%40qos.ch/thread/T2FRI3KDO3P4ASML464I77TKSBD6QFSE/
[3] Maven artifact for third-party Gson formatter (deps include logback-json-core + gson): https://mvnrepository.com/artifact/de.gessnerfl.logback/logback-gson-formatter
[4] Logback Javadoc / source overview for ch.qos.logback.classic.encoder.JsonEncoder (configurable included fields): https://logback.qos.ch/apidocs/ch.qos.logback.classic/ch/qos/logback/classic/encoder/JsonEncoder.html
[5] logstash-logback-encoder README (encoders/layouts, customization, composite encoders/providers): https://github.com/logfellow/logstash-logback-encoder


LGTM — clean migration to built-in JsonEncoder.

This removes the need for the unmaintained logback-json-classic and logback-gson-formatter dependencies. The JsonEncoder is built into Logback and fully supported by version 1.5.29.

Note: The JSON output format from JsonEncoder will likely differ from the previous JsonLayout+GsonFormatter combination (different field names, structure, timestamp format). If any log aggregation pipelines or dashboards depend on the specific JSON schema, they may need updating.

🤖 Prompt for AI Agents
In `@src/main/resources/logback.xml` at line 4, The logback configuration now uses
the built-in JsonEncoder (encoder
class="ch.qos.logback.classic.encoder.JsonEncoder") so remove the
now-unnecessary dependencies (logback-json-classic and logback-gson-formatter)
from the build configuration, ensure Logback is upgraded to v1.5.29+ in your
dependency manifest, and validate/adjust any log ingestion pipelines or
dashboards that relied on the prior JsonLayout+GsonFormatter schema (update
mappings or configure JsonEncoder properties to match expected field/timestamp
names if needed).

@henrist henrist merged commit f523db2 into master Feb 13, 2026
5 checks passed
@henrist henrist deleted the modernize-deps branch February 13, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant