Skip to content

Add configuration to add alternate trimming methods - #6063

Merged
BraisGabin merged 1 commit into
detekt:mainfrom
atulgpt:fixes/5415
May 3, 2023
Merged

BraisGabin merged 1 commit into
detekt:mainfrom
atulgpt:fixes/5415

Conversation

@atulgpt

@atulgpt atulgpt commented May 1, 2023

Copy link
Copy Markdown
Contributor

Fixes #5415

@detekt-ci detekt-ci added the rules label May 1, 2023

@cortinico cortinico left a comment

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.

LGTM 👍

@codecov

codecov Bot commented May 1, 2023

Copy link
Copy Markdown

Codecov Report

Merging #6063 (41742fb) into main (158aa2a) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##               main    #6063   +/-   ##
=========================================
  Coverage     84.86%   84.86%           
- Complexity     3975     3977    +2     
=========================================
  Files           564      564           
  Lines         13300    13304    +4     
  Branches       2325     2327    +2     
=========================================
+ Hits          11287    11291    +4     
  Misses          870      870           
  Partials       1143     1143           
Impacted Files Coverage Δ
...etekt/rules/style/MultilineRawStringIndentation.kt 95.45% <100.00%> (+0.05%) ⬆️
...bosch/detekt/rules/style/TrimMultilineRawString.kt 74.35% <100.00%> (+2.13%) ⬆️

private val indentSize by config(4)

@Configuration("allows to provide a list of multiline string trimming methods")
private val trimmingMethods: List<String> by config(listOf("trimIndent", "trimMargin"))

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.

Should we use the method matcher that we have on forbidden method call? I assume it is not needed. If someone really needs it we could add it later without any breaking change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi, @BraisGabin this will change the old behaviour, initially, we used to allow any multiline sting with any method with name trimMargin method at the end. Now since we are asking for the FunctionMatcher that would mean that we are checking for function signature and hence the above-mentioned usage will be reported by the rule.

Also adding FunctionMatcher will need bindingContext to get the FqName of trimming method

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.

I wouldn't necessarily add bindingcontext here. IMHO, it doesn't add much value over using the current approach in this PR.

@BraisGabin

Copy link
Copy Markdown
Member

Waiting to ensure that at least one of the windows job work to merge it.

We should work on the flakiness that we have on our rule set on windows.

@BraisGabin
BraisGabin merged commit f8f6105 into detekt:main May 3, 2023
@atulgpt
atulgpt deleted the fixes/5415 branch May 3, 2023 10:13

This branch was successfully deployed

1 active deployment
Preview — 41742fbc Deployed May 1, 2023 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TrimMultilineRawString support for alternate trimming methods

5 participants