Skip to content

Add detekt - #46

Merged
mmathieum merged 3 commits into
masterfrom
mm/add_detekt
Jul 31, 2026
Merged

Add detekt#46
mmathieum merged 3 commits into
masterfrom
mm/add_detekt

Conversation

@mmathieum

Copy link
Copy Markdown
Member

@mmathieum mmathieum self-assigned this Jul 31, 2026
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@mmathieum, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 13 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2de4738e-26c2-466b-bf77-6026f42e718c

📥 Commits

Reviewing files that changed from the base of the PR and between d843349 and 3985ccb.

📒 Files selected for processing (5)
  • detekt-baseline.xml
  • src/main/java/org/mtransit/commons/SourceUtils.kt
  • src/main/java/org/mtransit/commons/gtfs/sql/CalendarDateSQL.kt
  • src/main/java/org/mtransit/commons/gtfs/sql/StopSQL.kt
  • src/main/java/org/mtransit/commons/gtfs/sql/TripSQL.kt

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

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Add Detekt baseline and align code with Detekt rules

⚙️ Configuration changes 🕐 10-20 Minutes

Grey Divider

AI Description

• Introduce Detekt with a baseline to adopt static analysis incrementally.
• Suppress allowed stack-trace printing in shared JVM/Android utility methods.
• Reformat SQL builder code to satisfy style/lint constraints (line-length/formatting).
Diagram

graph TD
  CI["CI / local build"] --> Gradle["Gradle build"] --> Detekt["Detekt task"]
  Detekt --> Baseline[("detekt-baseline.xml")]
  Detekt --> Sources["Kotlin sources"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Adopt Detekt with no baseline (fix all findings upfront)
  • ➕ Immediately enforces a clean static-analysis state
  • ➕ Avoids carrying long-term suppressions/baseline debt
  • ➖ Large up-front cleanup cost and noisy PR
  • ➖ Higher risk of mixing functional changes with lint-driven edits
2. Use KtLint (format-focused) + keep Detekt minimal
  • ➕ Simpler rule set; primarily formatting/consistency
  • ➕ Less configuration than full Detekt rule coverage
  • ➖ Does not cover many semantic/code-smell checks Detekt provides
  • ➖ May still require separate tooling for complexity/bug-prone patterns
3. Rely on Android Lint / Kotlin compiler checks only
  • ➕ No new toolchain/config to maintain
  • ➕ Already integrated into typical Android builds
  • ➖ Less coverage for Kotlin-specific style and complexity rules
  • ➖ Harder to standardize code-quality expectations across modules

Recommendation: The baseline-first Detekt rollout used here is the best tradeoff: it enables immediate CI enforcement for new issues while deferring legacy cleanup. The main follow-up should be a policy for steadily reducing baseline entries (e.g., per-module burn-down or 'touch it, fix it' rule).

Files changed (5) +82 / -4

Refactor (4) +8 / -4
SourceUtils.ktSuppress Detekt warning for stack-trace printing +2/-0

Suppress Detekt warning for stack-trace printing

• Adds @Suppress("PrintStackTrace") on the URL parsing/label helpers. The suppression documents that stack-trace printing is intentional for both JVM and Android usage.

src/main/java/org/mtransit/commons/SourceUtils.kt

CalendarDateSQL.ktAdjust SQL column definition argument style +1/-1

Adjust SQL column definition argument style

• Tweaks the SQLColumDef invocation to avoid the named-argument form for the primary key flag. This is a non-functional change intended to comply with style/lint expectations.

src/main/java/org/mtransit/commons/gtfs/sql/CalendarDateSQL.kt

StopSQL.ktReformat query builder joins for readability/line length +3/-2

Reformat query builder joins for readability/line length

• Cleans up minor indentation and breaks a long JOIN clause into chained append calls. This preserves generated SQL while aligning with formatting constraints.

src/main/java/org/mtransit/commons/gtfs/sql/StopSQL.kt

TripSQL.ktReformat service ID join to satisfy style rules +2/-1

Reformat service ID join to satisfy style rules

• Splits a long JOIN ... ON clause into multiple append calls. This keeps the query semantics identical while reducing line length and improving readability.

src/main/java/org/mtransit/commons/gtfs/sql/TripSQL.kt

Other (1) +74 / -0
detekt-baseline.xmlAdd Detekt baseline for existing findings +74/-0

Add Detekt baseline for existing findings

• Introduces a Detekt baseline containing the current set of known issues. This allows enabling Detekt without forcing immediate cleanup of all pre-existing violations.

detekt-baseline.xml

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Ready to approve

Changes are low-risk and primarily Detekt enablement/formatting, with only a minor readability follow-up noted.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Adds Detekt static analysis support to the commons-java Kotlin codebase by introducing a baseline file and making small, targeted code adjustments/suppressions to reduce (or document) existing findings. This aligns with the effort tracked in mtransit-for-android issue #226.

Changes:

  • Added a detekt-baseline.xml to capture current Detekt findings as a starting point.
  • Added @Suppress("PrintStackTrace") on SourceUtils.getSourceLabel(...) overloads for cross-platform (JVM/Android) usage.
  • Reformatted a couple of SQL query builders (JOIN formatting) and adjusted one SQLColumDef invocation.
File summaries
File Description
src/main/java/org/mtransit/commons/SourceUtils.kt Adds Detekt suppression for printStackTrace() usage in URL label parsing.
src/main/java/org/mtransit/commons/gtfs/sql/TripSQL.kt Splits a long JOIN line into a chained append for readability/linting.
src/main/java/org/mtransit/commons/gtfs/sql/StopSQL.kt Minor indentation fix and splits a long JOIN line into chained append.
src/main/java/org/mtransit/commons/gtfs/sql/CalendarDateSQL.kt Tweaks SQLColumDef call style (primaryKey/foreignKey arguments).
detekt-baseline.xml Introduces Detekt baseline to track existing issues.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment thread src/main/java/org/mtransit/commons/gtfs/sql/CalendarDateSQL.kt Outdated
@mmathieum
mmathieum merged commit ccd7885 into master Jul 31, 2026
5 checks passed
@mmathieum
mmathieum deleted the mm/add_detekt branch July 31, 2026 22:56
montransit added a commit to mtransitapps/mtransit-for-android that referenced this pull request Jul 31, 2026
…parser':

- commons: Add `detekt` mtransitapps/commons#836
- commons-android: Add `detekt` mtransitapps/commons-android#193
- commons-java: Add `detekt` mtransitapps/commons-java#46
- parser: Add `detekt` mtransitapps/parser#84
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.

2 participants