Scribe-Android
Scribe-Android copied to clipboard
Replace Magic Numbers with Named Constants as identified by detekt
Terms
- [X] I have searched open and closed feature requests
- [X] I agree to follow Scribe-Android's Code of Conduct
Description
Linting issues have been identified by Detekt due to Magic Numbers across the codebase. Magic numbers are when numbers are used in certain code lines within the definition of what that number means.
Example:
Before fixing:
fun isOverSpeeding(speed: Int): Boolean {
return speed > 60 // Magic number 60 lacks clarity
}
After fixing:
const val SPEED_LIMIT = 60 // Named constant provides context
fun isOverSpeeding(speed: Int): Boolean {
return speed > SPEED_LIMIT
}
These can be identified across the code by the following steps:
- Enable the MagicNumber detection from the detekt.yml file.
- Run the command ./gradlew detekt
- You would be able to see all the files where Linting issues are caused due to Magic Numbers
Contribution
I would love to work on this and am more than willing to help anyone solve this issue. 😄
Could you assign this issue to me? The command returned around 500 errors, so resolving this issue might take some time.
Yes, Feel free to work on this issue. If you have any questions, please don't hesitate to ask us. Do you think there is any need to break down this issue?
That's OK. I can work on this and I will ask questions when necessary. 😊
Thanks @Linfye and @angrezichatterbox! :)
Closed by #234 🚀 Thanks for getting to all of these issues recently, @Linfye! Amazing work :)