Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

[IMPROVEMENT] Remove unneccessary verbose boolean checks. #33

Closed
MaximilianSoerenPollak opened this issue Jul 24, 2024 · 3 comments
Closed

Comments

@MaximilianSoerenPollak
Copy link

When I looked through the code I saw quite a few places where there was some checks made that are not neccessary in that 'verbosity'.

Examples of said verbosity here:

if since.IsZero() == false && since.Before(entry.Begin) == false && since.Equal(entry.Begin) == false {
  continue
}

Could be simplified to:

if !since.IsZero() && !since.Before(entry.Begin) && !since.Equal(entry.Begin) {
  continue
}

Now my question would be, is this verbosity explicitly wanted or would this be something that one could remove and simplify via a PR?

Please let me know.

@mrusme
Copy link
Owner

mrusme commented Jul 24, 2024

These choices were intentional to keep the code explicit, simple to read and understand, and avoid things going unnoticed. I personally don't mind either version, though. Some people prefer reading "if not since.IsZero", others "if since.IsZero is false", but ultimately it doesn't really matter.

I personally wouldn't put in the effort to go through the code and change it just for the sake of changing it, as I don't see a big benefit in that. If, however, you're working on a feature and are touching an area anyway, and you believe that it makes sense to rewrite it in a shorter format, I wouldn't mind the less verbose format either.

@MaximilianSoerenPollak
Copy link
Author

I don´t mind either, only thing is that 'linters' and some static checkers will complain if you would have them on.
But if it was an intentional decision then I don´t think we need to change this.

I don´t know what's more idiomatic in Go, but then again that word has been used to mean anything and everything. 🤣

@mrusme
Copy link
Owner

mrusme commented Jul 24, 2024

If you would dare to turn on a linter it would probably go brrrrrrrrrr anyway, due to me having used two spaces for indentation. (-:

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

No branches or pull requests

2 participants