Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration to add alternate trimming methods #6063

Merged
merged 1 commit into from May 3, 2023

Conversation

atulgpt
Copy link
Contributor

@atulgpt atulgpt commented May 1, 2023

Fixes #5415

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

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@codecov
Copy link

codecov bot commented May 1, 2023

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%) ⬆️

@@ -62,10 +62,13 @@ class MultilineRawStringIndentation(config: Config) : Rule(config) {
@Configuration("indentation size")
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
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
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
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
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
22 of 23 checks passed
@atulgpt atulgpt deleted the fixes/5415 branch May 3, 2023 10:13
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