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

Magic number extension functions #3299

Merged
merged 3 commits into from
Dec 27, 2020

Conversation

BraisGabin
Copy link
Member

We should allow things like:

500.dp()
5.days

Because they are not magic numbers, they have units.

More about this in #3283

This PR adds a new flag to MagicNumber to allow this. Open questions:

  • Should we enable this flag by default?
  • Is ignoreExtensionFunctions a good name?

@BraisGabin BraisGabin force-pushed the maginc-number-extension-functions branch from 37a878d to 0953366 Compare December 19, 2020 11:22
@codecov
Copy link

codecov bot commented Dec 19, 2020

Codecov Report

Merging #3299 (0eaa99e) into master (9270ee6) will decrease coverage by 0.00%.
The diff coverage is 83.33%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3299      +/-   ##
============================================
- Coverage     80.33%   80.32%   -0.01%     
- Complexity     2719     2721       +2     
============================================
  Files           445      445              
  Lines          8165     8168       +3     
  Branches       1552     1553       +1     
============================================
+ Hits           6559     6561       +2     
  Misses          774      774              
- Partials        832      833       +1     
Impacted Files Coverage Δ Complexity Δ
...itlab/arturbosch/detekt/rules/style/MagicNumber.kt 79.26% <83.33%> (-0.48%) 64.00 <1.00> (+2.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 9270ee6...0eaa99e. Read the comment docs.

@BraisGabin BraisGabin added this to the 1.16.0 milestone Dec 27, 2020
@BraisGabin BraisGabin force-pushed the maginc-number-extension-functions branch from 0953366 to 0eaa99e Compare December 27, 2020 12:20
@BraisGabin
Copy link
Member Author

I changed the PR a bit: I enabled ignoreExtensionFunctions by default (last commit)

@schalkms schalkms merged commit a6b9c44 into detekt:master Dec 27, 2020
@BraisGabin BraisGabin deleted the maginc-number-extension-functions branch December 27, 2020 18:34
chao2zhang pushed a commit to chao2zhang/detekt that referenced this pull request Dec 27, 2020
* Use braces in multiline ifs

* Introduce ignoreExtensionFunctions in MagicNumber

* Enable ignoreExtensionFunctions by default
arturbosch pushed a commit that referenced this pull request Jan 16, 2021
* Use braces in multiline ifs

* Introduce ignoreExtensionFunctions in MagicNumber

* Enable ignoreExtensionFunctions by default
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