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

Replace Magic Numbers with Named Constants as identified by detekt #90

Closed
2 tasks done
angrezichatterbox opened this issue Sep 7, 2024 · 5 comments
Closed
2 tasks done
Assignees
Labels
feature New feature or request good first issue Good for newcomers hacktoberfest Included as a part of Hacktoberfest help wanted Extra attention is needed refactor Refactor code to improve quality

Comments

@angrezichatterbox
Copy link
Member

Terms

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. 😄

@angrezichatterbox angrezichatterbox added feature New feature or request good first issue Good for newcomers help wanted Extra attention is needed refactor Refactor code to improve quality labels Sep 7, 2024
@Linfye
Copy link
Contributor

Linfye commented Sep 12, 2024

Could you assign this issue to me? The command returned around 500 errors, so resolving this issue might take some time.

@angrezichatterbox
Copy link
Member Author

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?

@Linfye
Copy link
Contributor

Linfye commented Sep 12, 2024

That's OK. I can work on this and I will ask questions when necessary. 😊

@andrewtavis
Copy link
Member

Thanks @Linfye and @angrezichatterbox! :)

@andrewtavis andrewtavis added the hacktoberfest Included as a part of Hacktoberfest label Sep 30, 2024
@Linfye Linfye mentioned this issue Oct 30, 2024
2 tasks
@andrewtavis
Copy link
Member

andrewtavis commented Oct 30, 2024

Closed by #234 🚀 Thanks for getting to all of these issues recently, @Linfye! Amazing work :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request good first issue Good for newcomers hacktoberfest Included as a part of Hacktoberfest help wanted Extra attention is needed refactor Refactor code to improve quality
Projects
Status: Done
Development

No branches or pull requests

3 participants