Ignore actual functions in FunctionOnlyReturningConstant (#3388)#3390
Merged
schalkms merged 3 commits intodetekt:masterfrom Jan 19, 2021
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3390 +/- ##
============================================
- Coverage 80.46% 80.40% -0.06%
- Complexity 2739 2745 +6
============================================
Files 448 448
Lines 8282 8279 -3
Branches 1573 1582 +9
============================================
- Hits 6664 6657 -7
+ Misses 771 767 -4
- Partials 847 855 +8 Continue to review full report at Codecov.
|
chao2zhang
approved these changes
Jan 19, 2021
| pull_request: | ||
| branches: | ||
| - '*' | ||
| - '**' |
Member
There was a problem hiding this comment.
Thank you for fixing the glob pattern in github workflows.
Contributor
Author
There was a problem hiding this comment.
Happy to help. The difference between * and ** is well hidden in GitHub Actions documentation. Took me some time to figure out the first time.
Member
There was a problem hiding this comment.
I learned Filter Pattern Cheat Sheet by reviewing this PR 🙏
schalkms
approved these changes
Jan 19, 2021
...src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/FunctionOnlyReturningConstantSpec.kt
Outdated
Show resolved
Hide resolved
This was referenced Mar 11, 2021
Closed
Closed
This was referenced Mar 11, 2021
This was referenced Mar 18, 2021
This was referenced Apr 10, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3388
Expected Behavior of the rule
By default,
actualfunctions in multiplatform projects should be ignored when evaluatingFunctionOnlyReturningConstant.There should be a configuration option
ignoreActualFunction, which would allow changing this behaviour.Example
commonMain
jvmMain
jsMain
Context
Similar to
ignoreOverridableFunction.Implementing an
actualfunction, is conceptually similar to overriding a function from an interface/abstract class.It makes sense for such a function to provide complex logic on some platforms, and only return a constant value on others.