8000 Improve UnnecessaryApply by BraisGabin · Pull Request #2827 · detekt/detekt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve UnnecessaryApply #2827

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

Merged
merged 3 commits into from
Jun 27, 2020
Merged

Improve UnnecessaryApply #2827

merged 3 commits into from
Jun 27, 2020

Conversation

BraisGabin
Copy link
Member

Closes #2821

This PR implements the ideas proposed int #2821 to improve UnnecessaryApply:

  • We can add one more example of noncompliant pointing that this: config?.apply { println(version) } should be config?.let { println(it.version) }
  • And we can check if the user is calling the apply using the safe null operator ?.. In this case we can tell that he should use let instead of apply. I mean, it's not obvious why config?.let { println(it.version) } is better than config?.apply { println(version) }, so if we can point it out we will help a lot.

I'm not really sure if the messages are clear enough, so the suggestions are more than welcome (as always).

@codecov
Copy link
codecov bot commented Jun 27, 2020

Codecov Report

Merging #2827 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2827   +/-   ##
=========================================
  Coverage     80.66%   80.66%           
- Complexity     2350     2351    +1     
=========================================
  Files           388      388           
  Lines          7027     7028    +1     
  Branches       1281     1282    +1     
=========================================
+ Hits           5668     5669    +1     
  Misses          716      716           
  Partials        643      643           
Impacted Files Coverage Δ Complexity Δ
.../arturbosch/detekt/rules/style/UnnecessaryApply.kt 83.33% <100.00%> (+0.57%) 7.00 <0.00> (+1.00)

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 9ebfede...8be38ff. Read the comment docs.

@schalkms schalkms merged commit 26a78f5 into detekt:master Jun 27, 2020
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.

Apply expression can be omitted wrong suggestion
2 participants
0