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

strconv.FormatInt or strconv.FormatUint and magic numbers ? #27

Closed
butuzov opened this issue Sep 1, 2021 · 9 comments
Closed

strconv.FormatInt or strconv.FormatUint and magic numbers ? #27

butuzov opened this issue Sep 1, 2021 · 9 comments

Comments

@butuzov
Copy link
Contributor

butuzov commented Sep 1, 2021

Become curious: should any number (within consition 2 <= n <= 36) be considered as magic number if used in strconv.FormatInt or strconv.FormatUint ?

@butuzov butuzov changed the title strconv.FormatInt strconv.FormatInt or strconv.FormatUint and magic numbers ? Sep 1, 2021
@breml
Copy link

breml commented Sep 22, 2021

I have the same issue with strconv.ParseFloat, where the argument bitSize is considered as magic number even though the only two valid values are 32 and 64.

@solokirrik
Copy link

@butuzov @breml

got same issue with gomnd / staticcheck

.....go:413:53: mnd: Magic number: 64, in <argument> detected (gomnd)
                lon, err := strconv.ParseFloat(*addr.Data.GeoLon, 64)
                                                                  ^
....go:91:43: SA1030: 'fmt' argument is invalid: unknown format '\n' (staticcheck)
		lat := strconv.FormatFloat(*ts.Lot.Lat, 10, 5, 64)
		                                        ^

Rollback to golangci-lint v1.40.1 helped

  1. remove currently installed golangci-lint
  2. install v1.40.1
    curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.40.1

@butuzov
Copy link
Contributor Author

butuzov commented Nov 9, 2021

@solokirrik bad advice considering improvements in 1.43 and backwards compatibility for go versions.

@solokirrik
Copy link

@butuzov agree, but that's how it works now wo PR in go-mnd

@butuzov
Copy link
Contributor Author

butuzov commented Nov 9, 2021

Before PR we might need a comment from @tommy-muehle.

@butuzov
Copy link
Contributor Author

butuzov commented Nov 9, 2021

and looks like a way to ignore such patterns was just added

@solokirrik
Copy link

@tommy-muehle could you please tag a new version with built-in functions fix? #29

@butuzov
Copy link
Contributor Author

butuzov commented Jan 17, 2022

+1 to @solokirrik, because support to ignored-functions just landed to golangci-lint json schema (but not golangci-lint itself)

@tommy-muehle
Copy link
Owner

Sure. Thanks for the heads up @solokirrik @butuzov !

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

4 participants