Skip to content

Re-enable gomnd linter with release > v1.23.0 #929

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

Merged
merged 3 commits into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ linters:
- gofmt
- goimports
- golint
# - gomnd TODO: enable it with release > v1.23.0
- gomnd
- goprintffuncname
- gosec
- gosimple
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ linters:
- gofmt
- goimports
- golint
# - gomnd TODO: enable it with release > v1.23.0
- gomnd
- goprintffuncname
- gosec
- gosimple
Expand Down
15 changes: 9 additions & 6 deletions test/testdata/govet_custom_formatter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ const (
escape = "\x1b"
reset = escape + "[0m"
green = escape + "[32m"

minValue = 0.0
maxValue = 1.0
)

// Bar is a progress bar.
type Bar float64

var _ fmt.Formatter = Bar(1.0)
var _ fmt.Formatter = Bar(maxValue)

// Format the progress bar as output
func (h Bar) Format(state fmt.State, r rune) {
Expand All @@ -25,16 +28,16 @@ func (h Bar) Format(state fmt.State, r rune) {
panic(fmt.Sprintf("%v: unexpected format character", float64(h)))
}

if h > 1.0 {
h = 1.0
if h > maxValue {
h = maxValue
}

if h < 0.0 {
h = 0.0
if h < minValue {
h = minValue
}

if state.Flag('-') {
h = 1.0 - h
h = maxValue - h
}

width, ok := state.Width()
Expand Down