Skip to content

Commit a5b5598

Browse files
authored
Merge pull request #929 from ewohltman/master
Re-enable `gomnd` linter with release > v1.23.0
2 parents 567904e + b248dc5 commit a5b5598

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ linters:
7474
- gofmt
7575
- goimports
7676
- golint
77-
# - gomnd TODO: enable it with release > v1.23.0
77+
- gomnd
7878
- goprintffuncname
7979
- gosec
8080
- gosimple

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ linters:
10151015
- gofmt
10161016
- goimports
10171017
- golint
1018-
# - gomnd TODO: enable it with release > v1.23.0
1018+
- gomnd
10191019
- goprintffuncname
10201020
- gosec
10211021
- gosimple

test/testdata/govet_custom_formatter/main.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ const (
1010
escape = "\x1b"
1111
reset = escape + "[0m"
1212
green = escape + "[32m"
13+
14+
minValue = 0.0
15+
maxValue = 1.0
1316
)
1417

1518
// Bar is a progress bar.
1619
type Bar float64
1720

18-
var _ fmt.Formatter = Bar(1.0)
21+
var _ fmt.Formatter = Bar(maxValue)
1922

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

28-
if h > 1.0 {
29-
h = 1.0
31+
if h > maxValue {
32+
h = maxValue
3033
}
3134

32-
if h < 0.0 {
33-
h = 0.0
35+
if h < minValue {
36+
h = minValue
3437
}
3538

3639
if state.Flag('-') {
37-
h = 1.0 - h
40+
h = maxValue - h
3841
}
3942

4043
width, ok := state.Width()

0 commit comments

Comments
 (0)