Skip to content

Split detekt custom rules to handle code point limit#2863

Merged
jonathanmos merged 1 commit into
developfrom
jmoskovich/split-detekt
Sep 9, 2025
Merged

Split detekt custom rules to handle code point limit#2863
jonathanmos merged 1 commit into
developfrom
jmoskovich/split-detekt

Conversation

@jonathanmos

@jonathanmos jonathanmos commented Sep 8, 2025

Copy link
Copy Markdown
Member

What does this PR do?

We are currently receiving errors of The incoming YAML document exceeds the limit: 102400 code points when running custom rules, as soon as the detekt_custom.yml exceeds a certain number of code points. This error is actually not originating in detekt, but rather in snakeYAML that is a detekt dependency. While we might be able to override the limit by using a custom YAML parser, this is complicated by our also running detekt through a shell script. Therefore I'm using a simpler alternative here that will work for both methods that we use for running the rules - splitting the yml file.

In this PR I split the detekt_custom.yml into three separate parts:

  • a general section
  • safe calls
  • unsafe calls

and these parts are then concatenated together when detekt is run.

Motivation

Work around the code point limit.

Additional Notes

Anything else we should know when reviewing?

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@jonathanmos
jonathanmos force-pushed the jmoskovich/split-detekt branch from f26f5d8 to 6c5b4bb Compare September 8, 2025 12:48
@jonathanmos
jonathanmos force-pushed the jmoskovich/split-detekt branch from 6c5b4bb to bf9b009 Compare September 8, 2025 12:53
@codecov-commenter

codecov-commenter commented Sep 8, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.74%. Comparing base (6e78b75) to head (bf9b009).
⚠️ Report is 1495 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2863      +/-   ##
===========================================
- Coverage    70.91%   70.74%   -0.17%     
===========================================
  Files          809      809              
  Lines        29460    29460              
  Branches      4937     4937              
===========================================
- Hits         20889    20839      -50     
- Misses        7236     7261      +25     
- Partials      1335     1360      +25     

see 34 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jonathanmos
jonathanmos marked this pull request as ready for review September 8, 2025 14:15
@jonathanmos
jonathanmos requested review from a team as code owners September 8, 2025 14:15

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

are you sure that by splitting the rule into 2 different files it gets executed as a single rule, just once and not twice, like rules with different configs?

@jonathanmos jonathanmos Sep 8, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was able to find this quote about how detekt handles multiple configs: "Currently Detekt supports specifying multiple config files, which will be merged together at runtime with priority in reverse of the order they are specified. If a later file defines a given rule, that definition will supersede any previous definitions of that rule."

@jonathanmos
jonathanmos merged commit 8a51cb5 into develop Sep 9, 2025
25 checks passed
@jonathanmos
jonathanmos deleted the jmoskovich/split-detekt branch September 9, 2025 07:58
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.

4 participants