generated from TrueCloudLab/basic
[#10] linters: add useStrconv linter #10
No reviewers
Labels
No labels
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/linters#10
Loading…
Reference in a new issue
No description provided.
Delete branch "achuprov/linters:nofmt"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Added a linter that suggests using strconv instead of fmt.
Signed-off-by: Alexander Chuprov a.chuprov@yadro.com
[#10] linters: add nofmt linterto WIP: [#10] linters: add nofmt linter200519f3cd
to61fab5ddd8
61fab5ddd8
to4ebbf63eb9
WIP: [#10] linters: add nofmt linterto [#10] linters: add nofmt linter@ -49,3 +51,3 @@
linters-settings:
custom:
noliteral:
custom-linter:
Is such name mandatory? Maybe
truecloudlab
orfrostfs
is better?@ -0,0 +34,4 @@
Methods: []Method{
{
TargetMethods: "Sprintf",
Modyficators: []string{"%d", "%f", "%t", "%x"},
targetMethods, modificators, positionModificator and package are implementation details, not config parameters. I think there should be no parameters at all for this check.
@ -0,0 +42,4 @@
Enable: true,
}
func ConfigurationLinter(conf any) (*analysis.Analyzer, error) {
Since this is a constructor, it is better to use
New
as the name of the method.@ -7,3 +6,2 @@
noliteral "git.frostfs.info/TrueCloudLab/linters/internal/analyzers/noliteral"
"github.com/mitchellh/mapstructure"
"golang.org/x/tools/go/analysis"
Our projects usually use two import groups.
@ -0,0 +1,96 @@
package util
There is such an expression:
util classes (packages, packets etc) are evil
.util
is the right place for everything.For example,
ast
package is more specific.4ebbf63eb9
to003ae9ae11
003ae9ae11
to69dab19c19
@dstepanov-yadro fixed
@ -57,2 +57,2 @@
constants-package: "git.frostfs.info/rep/logs" # if not set, then the check is disabled
noliteral:
enable: true # required
Is it really required? As is see, if you do not pass this value, the linter just will be turned off.
I suggest to correct the comment, for example
if not defined, then noliteral check will be disabled
@ -0,0 +28,4 @@
var modyficators = []string{"%d", "%f", "%t", "%x"}
func New(conf any) (*analysis.Analyzer, error) {
configMap, ok := conf.(map[string]any)
What happens if there is no section for this linter in the configuration file?
I expect the check should work in this case.
@ -75,3 +89,3 @@
})
return false
return true
Please explain this change.
69dab19c19
toc049dbe1c8
c049dbe1c8
to63e20aedd0
@ -39,0 +36,4 @@
| Name | Description |
|-------------------------|-------------------------------------------------------------------------------------------------------------------------------|
| [noliteral](#noliteral) | The tool prohibits the use of literal string arguments in logging functions. |
| [nofmt](#nofmt) | The `nofmt` linter recommends the utilization of `strconv` over `fmt` when performing string conversions of primitive data types. Detailed guidelines can be found in the [official Uber Go Style Guide](https://github.com/uber-go/guide/blob/master/style.md#prefer-strconv-over-fmt). |
nofmt
is too generic (we havego fmt
), maybestrconv
?@ -59,3 +62,3 @@
```
##### ENV Configuration
### nofmt
I think noliteral may also have a separate section.
noliteral
already has its own section in the README.mdd0450b6301/README.md (noliteral)
@ -0,0 +76,4 @@
return true
}
modValue := strings.Replace(stringLiteral.Value, "\"", "", -1)
63e20aedd0
tofbe445d090
fbe445d090
toc0c21f0eb7
c0c21f0eb7
tod0450b6301
[#10] linters: add nofmt linterto [#10] linters: add useStrconv linter@fyrchik fixed