-
Notifications
You must be signed in to change notification settings - Fork 4
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
analyzer: fix int-conversion scope #32
base: main
Are you sure you want to change the base?
Conversation
intConv parameter was introduced to disable some rules. The code was introduced with e958370, but only a part of the rules related to integer conversions were altered. This commit completes what was done in the previous commit
Here is a suggestion I'm doing after trying to play with the config to disable some of the rules. Please review, do not hesitate to tell me if I'm wrong with this idea. Thanks cc @alexandear as I'm curious what he would think about it |
Well, Why do you want to disable |
The idea is to be able to be able to disable everything via the configuration. If someone only wants errrof and sprintf1, it should be possible. I chose existing intConv variable because it feels like it was also about int conversion. But maybe you are right. Also having a new variable will avoid breaking changes for people. What would be the name of the variable according to you? It's about integer formating, so maybe |
Just noticing with work @mmorel-35 here That at least format bool would need a configuration variable too |
It can be So, let's change this PR to add a new option field to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose adding new option instead of reusing existing intConv
.
@catenacyber to be more clear, we want something that is already present in |
I agree. I'll use intFormat, add boolFormat and any other needed. I'll also update the tests because noconv should contain them all (at least FormatBool is missing) |
Sounds good, waiting for this |
Based on the changes made on I'll wait it to be merged before working again on this PR. The number of changes in the testdata will be crazy, I'll face too many conflicts. So, let's wait |
I'm now waiting for #38 to be merged Then I can open a new PR. @mmorel-35 do you plan to update all the tests the checker names (the one in TODO for now), or do you want me to do it in my PR ? |
I don't plan it yet we need a clear list of what are the checkers name and what are the options first |
OK, so I can do it with my PR, as I will need to add configuration option for them. |
For example it could be : error-format❌
fmt.Errorf("Simple message")
fmt.Sprintf("%s", err)
fmt.Sprintf("%v", err)
✅
errors.New("Simple message")
err.Error() with:
string-format❌
fmt.Sprintf("%s", strVal)
fmt.Sprintf("format string %s", strVal)
fmt.Sprintf("%s format string", strVal)
✅
strVal
"format string " + strVal
strVal + "format string" with
type-format❌
fmt.Sprintf("%t", boolVal)
fmt.Sprintf("%x", hash)
fmt.Sprintf("%d", id)
fmt.Sprintf("%v", version)
✅
strconv.FormatBool(boolBal)
hex.EncodeToString(hash)
strconv.Itoa(id)
strconv.FormatUint(uint64(version), 10) with
|
Yes, exactly. We also talked about bool-format For the int-conv of int format I don't know. But these are the things that will be reviewed when code is ready |
But maybe the simplest would be for you to open a PR once #38 will be merged to add these checker name. The things I'm doing in this PR can be addressed later |
It's probably simpler for everyone to have a dedicated issue to work what has to be done first |
I just created #39, please have a look at it so we can define clearly how to adapt the structuration of the code |
intConv parameter was introduced to disable some rules.
The code was introduced with e958370, but only a part of the rules
related to integer conversions were altered.
This commit completes what was done in the previous commit