-
-
Notifications
You must be signed in to change notification settings - Fork 821
Introduce NamedArguments rule #3167
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
Conversation
871850e to
4b2d0c6
Compare
Codecov Report
@@ Coverage Diff @@
## master #3167 +/- ##
============================================
+ Coverage 79.51% 79.53% +0.02%
- Complexity 2599 2606 +7
============================================
Files 437 439 +2
Lines 7865 7927 +62
Branches 1497 1510 +13
============================================
+ Hits 6254 6305 +51
- Misses 817 821 +4
- Partials 794 801 +7
Continue to review full report at Codecov.
|
… default number of non-named parameters
4b2d0c6 to
77c1cc5
Compare
cortinico
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contrib @sowmyav24
Please clarify the documentation as the semantic is a bit unclear right now. The threshold applies to the whole number of parameters, and not just to the named parameters.
...es-complexity/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NamedArguments.kt
Outdated
Show resolved
Hide resolved
...es-complexity/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NamedArguments.kt
Outdated
Show resolved
Hide resolved
...es-complexity/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NamedArguments.kt
Outdated
Show resolved
Hide resolved
51041b8 to
cc50ded
Compare
cortinico
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
schalkms
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! Please see my attached comments. I'm not sure whether there should be a bigger test coverage.
...es-complexity/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NamedArguments.kt
Show resolved
Hide resolved
| ) | ||
|
|
||
| override fun visitCallExpression(expression: KtCallExpression) { | ||
| val valueArguments = expression.valueArguments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when calling constructors? Shall a test be added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rule gets triggered. Have added tests for them
5136577 to
81d02e1
Compare
|
@cortinico & @BraisGabin should this rule also report constructors or just functions? What's your take on this? |
|
I think that it should report constructors. But maybe we could have two different threshold. |
Seems like it works also for ctors.
Don't have a strong opinion on this actually. Considered that the rule is not enabled by default, I'd be fine having a single threshold for now and adding another one in the future if needed. |
* Introduce NamedArguments rule when function is invoked with more than default number of non-named parameters * Change the documentation to make the intent of default threshold clear * Add compliant and non-compliant code documentation. Add tests for constructor
* Introduce NamedArguments rule when function is invoked with more than default number of non-named parameters * Change the documentation to make the intent of default threshold clear * Add compliant and non-compliant code documentation. Add tests for constructor
* Introduce NamedArguments rule when function is invoked with more than default number of non-named parameters * Change the documentation to make the intent of default threshold clear * Add compliant and non-compliant code documentation. Add tests for constructor
Fixes #1007
Changes done:
NamedArgumentsrule which enforces function invocation to have named parameters when they cross the threshold of number of non-named parameters.3.