/
doc.go
147 lines (131 loc) · 2.94 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// Package quickfix contains analyzes that implement code refactorings.
// None of these analyzers produce diagnostics that have to be followed.
// Most of the time, they only provide alternative ways of doing things,
// requiring users to make informed decisions.
//
// None of these analyzes should fail a build, and they are likely useless in CI as a whole.
package quickfix
import "honnef.co/go/tools/analysis/lint"
var Docs = lint.Markdownify(map[string]*lint.RawDocumentation{
"QF1001": {
Title: "Apply De Morgan's law",
Since: "2021.1",
Severity: lint.SeverityHint,
},
"QF1002": {
Title: "Convert untagged switch to tagged switch",
Text: `
An untagged switch that compares a single variable against a series of
values can be replaced with a tagged switch.`,
Before: `
switch {
case x == 1 || x == 2, x == 3:
...
case x == 4:
...
default:
...
}`,
After: `
switch x {
case 1, 2, 3:
...
case 4:
...
default:
...
}`,
Since: "2021.1",
Severity: lint.SeverityHint,
},
"QF1003": {
Title: "Convert if/else-if chain to tagged switch",
Text: `
A series of if/else-if checks comparing the same variable against
values can be replaced with a tagged switch.`,
Before: `
if x == 1 || x == 2 {
...
} else if x == 3 {
...
} else {
...
}`,
After: `
switch x {
case 1, 2:
...
case 3:
...
default:
...
}`,
Since: "2021.1",
Severity: lint.SeverityInfo,
},
"QF1004": {
Title: `Use \'strings.ReplaceAll\' instead of \'strings.Replace\' with \'n == -1\'`,
Since: "2021.1",
Severity: lint.SeverityHint,
},
"QF1005": {
Title: `Expand call to \'math.Pow\'`,
Text: `Some uses of \'math.Pow\' can be simplified to basic multiplication.`,
Before: `math.Pow(x, 2)`,
After: `x * x`,
Since: "2021.1",
Severity: lint.SeverityHint,
},
"QF1006": {
Title: `Lift \'if\'+\'break\' into loop condition`,
Before: `
for {
if done {
break
}
...
}`,
After: `
for !done {
...
}`,
Since: "2021.1",
Severity: lint.SeverityHint,
},
"QF1007": {
Title: "Merge conditional assignment into variable declaration",
Before: `
x := false
if someCondition {
x = true
}`,
After: `x := someCondition`,
Since: "2021.1",
Severity: lint.SeverityHint,
},
"QF1008": {
Title: "Omit embedded fields from selector expression",
Since: "2021.1",
Severity: lint.SeverityHint,
},
"QF1009": {
Title: `Use \'time.Time.Equal\' instead of \'==\' operator`,
Since: "2021.1",
Severity: lint.SeverityInfo,
},
"QF1010": {
Title: "Convert slice of bytes to string when printing it",
Since: "2021.1",
Severity: lint.SeverityHint,
},
"QF1011": {
Title: "Omit redundant type from variable declaration",
Since: "2021.1",
Severity: lint.SeverityHint,
},
"QF1012": {
Title: `Use \'fmt.Fprintf(x, ...)\' instead of \'x.Write(fmt.Sprintf(...))\'`,
Since: "2022.1",
Severity: lint.SeverityHint,
},
})