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

Match functions signatures with lambdas on it #4458

Merged
merged 2 commits into from Jan 25, 2022
Merged

Conversation

BraisGabin
Copy link
Member

Related with #4448 but it doesn't fix it yet. The next step is to support extension functions.

Note: If you check the tests you will see that the signature foo(() -> kotlin.String) matches a functione like this one: fun foo(a: () -> Unit). That's because we don't need to distinguish between this two functions:

fun foo(a: () -> Unit)
fun foo(a: () -> String)

The compiler doesn't allow to define both at the same time.

If we want to distinguish between those we would introduce a breaking change because until now this signature: foo(List) was matching fun foo(a: List<String>) but if we enforce to specify the generics that type should be changed.

For those two reasons combined I think that it's better to ignore the generics.

@codecov
Copy link

codecov bot commented Jan 6, 2022

Codecov Report

Merging #4458 (367ec74) into main (a9c38b8) will decrease coverage by 0.15%.
The diff coverage is 88.88%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #4458      +/-   ##
============================================
- Coverage     84.32%   84.16%   -0.16%     
- Complexity     3298     3314      +16     
============================================
  Files           473      476       +3     
  Lines         10591    10908     +317     
  Branches       1907     2023     +116     
============================================
+ Hits           8931     9181     +250     
- Misses          675      694      +19     
- Partials        985     1033      +48     
Impacted Files Coverage Δ
...in/io/github/detekt/tooling/api/FunctionMatcher.kt 86.36% <88.88%> (+0.15%) ⬆️
...lab/arturbosch/detekt/rules/style/VarCouldBeVal.kt 84.37% <0.00%> (-3.13%) ⬇️
...ekt/generator/collection/ConfigurationCollector.kt 72.22% <0.00%> (-3.04%) ⬇️
...osch/detekt/rules/bugs/UselessPostfixExpression.kt 71.73% <0.00%> (-0.99%) ⬇️
...urbosch/detekt/rules/performance/ArrayPrimitive.kt 74.19% <0.00%> (-0.81%) ⬇️
...sch/detekt/generator/printer/RuleSetPagePrinter.kt 90.38% <0.00%> (-0.53%) ⬇️
.../arturbosch/detekt/rules/style/CanBeNonNullable.kt 72.61% <0.00%> (-0.52%) ⬇️
...tlab/arturbosch/detekt/rules/bugs/LateinitUsage.kt 91.30% <0.00%> (-0.37%) ⬇️
...sch/detekt/rules/style/UnnecessaryAbstractClass.kt 86.36% <0.00%> (-0.31%) ⬇️
...bosch/detekt/rules/complexity/LongParameterList.kt 85.41% <0.00%> (-0.30%) ⬇️
... and 18 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a9c38b8...367ec74. Read the comment docs.

@BraisGabin BraisGabin added this to the 1.20.0 milestone Jan 6, 2022
Copy link
Member

@chao2zhang chao2zhang left a comment

Choose a reason for hiding this comment

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

Thanks for expanding the supports for Function signatures! My comments were not blocking, they were primarily documenting my time spent on the confusion.

}
}
split.add(result.toString())
return split.map { it.trim() }.filter { it.isNotBlank() }
Copy link
Member

Choose a reason for hiding this comment

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

Is it.isNotBlank() necessary? Without verifying with actual test code, I assume they are only possible at Line 97. I believe the isNotBlank() and trim() should be applied when append() is invoked, which avoids creating more lists.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, what do you think now?

@BraisGabin BraisGabin merged commit 576ae5f into main Jan 25, 2022
@BraisGabin BraisGabin deleted the function-matcher branch January 25, 2022 08:41
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.

None yet

2 participants