Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / honnef.co / go / tools@v0.0.1-2020.1.5 / doc / 2019.1.html
1 <h2>Big restructuring</h2>
2
3 <p>
4   At the core of the 2019.1 release lies the grand restructuring of all of the staticcheck tools.
5   All of the individual checkers, as well as megacheck, have been merged into a single tool,
6   which is simply called <em>staticcheck</em>.
7   From this point forward, staticcheck will be <em>the</em> static analyzer for Go code.
8   It will cover all of the existing categories of checks – bugs, simplifications, performance –
9   as well as future categories, such as the new style checks.
10 </p>
11
12 <p>
13   This change makes a series of simplifications possible.
14   Per-tool command line flags in megacheck have been replaced with unified flags
15   (<code>-checks</code> and <code>-fail</code>)
16   that operate on arbitrary subsets of checks.
17   Consumers of the JSON output no longer need to know about different checker names
18   and can instead rely solely on user-controllable severities.
19   And not to be neglected: gone is the silly name of <em>megacheck</em>.
20 </p>
21
22 <p>
23   This change will require some changes to your pipelines.
24   Even though the gosimple, unused, and megacheck tools still exist, they have been deprecated
25   and will be removed in the next release of staticcheck.
26   Additionally, megacheck's <code>-&lt;tool&gt;.exit-non-zero</code> flags have been rendered inoperable.
27   Instead, you will have to use the <code>-fail</code> flag.
28   Furthermore,, <code>-fail</code> defaults to <code>all</code>, meaning all checks will cause non-zero exiting.
29   Previous versions of megacheck had different defaults for different checkers, trying to guess the user's intention.
30   Instead of guessing, staticcheck expects you to provide the correct flags.
31 </p>
32
33 <p>
34   Since all of the tools have been merged into staticcheck, it will no longer run just one group of checks.
35   This may lead to additional problems being reported.
36   To restore the old behavior, you can use the new <code>-checks</code> flag.
37   <code>-checks "SA*"</code> will run the same set of checks that the old staticcheck tool did.
38   The same flag should be used in place of megacheck's – now deprecated – <code>-&lt;tool&gt;.enabled</code> flags.
39 </p>
40
41 <p>
42   Details on all of the command-line flags can be found <a href="/docs/#cli">in the documentation.</a>
43 </p>
44
45 <h2>Configuration files</h2>
46
47 <p>
48   Staticcheck 2019.1 adds support for per-project configuration files.
49   With these it will be possible to standardize and codify linter settings, the set of enabled checks, and more.
50   Please see the <a href="/docs/#configuration">documentation page on configuration</a> for all the details!
51 </p>
52
53 <h2>Build system integration</h2>
54
55 <p>
56   Beginning with this release, staticcheck calls out to the tools of the underlying build system
57   (<code>go</code> for most people) to determine the list of Go files to process.
58   This change should not affect most people.
59   It does, however, have some implications:
60   the system that staticcheck runs on needs access to a full Go toolchain –
61   just the source code of the standard library no longer suffices.
62   Furthermore, setting <code>GOROOT</code> to use a different Go installation no longer works as expected.
63   Instead, <code>PATH</code> has to be modified so that <code>go</code> resolves to the desired Go command.
64 </p>
65
66 <p>
67   This change has been necessary to support Go modules.
68   Additionally, it will allow us to support alternative build systems such as Bazel in the future.
69 </p>
70
71 <h2>Handling of broken packages</h2>
72
73 <p>
74   We have redesigned the way staticcheck handles broken packages.
75   Previously, if you ran <code>staticcheck ...</code> and any package wouldn't compile,
76   staticcheck would refuse to check any packages whatsoever.
77   Now, it will skip broken packages, as well as any of their dependents, and check only the remaining packages.
78   Any build errors that are encountered will be reported as problems.
79 </p>
80
81 <h2>Checks</h2>
82
83 <h3>New checks</h3>
84 <p>
85   Staticcheck 2019.1 adds a new category of checks, ST1.
86   ST1 contains checks for common style violations – poor variable naming, incorrectly formatted comments and the like.
87   It brings the good parts of <a href="https://github.com/golang/lint">golint</a> to staticcheck,
88   and adds some checks of its own.
89 </p>
90
91 <p>
92   In addition, some other checks have been added.
93 </p>
94
95 <p>
96   {{ check "S1032" }} recommends replacing <code>sort.Sort(sort.StringSlice(...))</code> with <code>sort.Strings(...)</code>;
97   similarly for other types that have helpers for sorting.
98 </p>
99
100 <p>
101   {{ check "SA9004" }} flags groups of constants where only the first one is given an explicit type.
102 </p>
103
104 <p>
105   {{ check "SA1025" }} checks for incorrect uses of <code>(*time.Timer).Reset</code>.
106 </p>
107
108 <h3>Changed checks</h3>
109
110 <p>
111   Several checks have been tweaked, either making them more accurate or finding more issues.
112 </p>
113
114 <p>
115   {{ check "S1002" }} no longer applies to code in tests.
116   While <code>if aBool == true</code> is usually an anti-pattern,
117   it can feel more natural in unit tests,
118   as it mirrors the <code>if got != want</code> pattern.
119 </p>
120
121 <p>
122   {{ check "S1005" }} now flags <code>for x, _ := range</code> because of the unnecessary blank assignment.
123 </p>
124
125 <p>
126   {{ check "S1007" }} no longer suggests using raw strings for regular expressions containing backquotes.
127 </p>
128
129 <p>
130   {{ check "S1016" }} now considers the targeted Go version.
131   It will no longer suggest type conversions between struct types with different field tags
132   unless Go 1.8 or later is being targeted.
133 </p>
134
135 <p>
136   {{ check "SA1000" }} now checks arguments passed to the <code>regexp.Match</code> class of functions.
137 </p>
138
139 <p>
140   {{ check "SA1014" }} now checks arguments passed to <code>(*encoding/xml.Decoder).DecodeElement</code>.
141 </p>
142
143 <p>
144   {{ check "SA6002" }} now realizes that unsafe.Pointer is a pointer.
145 </p>
146
147 <p>
148   {{ check "U1000" }} has fewer false positives in the presence of embedding.
149 </p>
150
151 <h3>Removed checks</h3>
152 <p>
153   {{ check "S1013" }} has been removed,
154   no longer suggesting replacing <code>if err != nil { return err }; return nil</code> with <code>return err</code>.
155   This check has been the source of contention and more often than not, it reduced the consistency of the surrounding code.
156 </p>
157
158 <h2>Deprecation notices</h2>
159
160 <p>
161   This release deprecates various features of staticcheck.
162   These features will be removed in the next release.
163 </p>
164
165 <p>
166   As already explained earlier, the <em>unused</em>, <em>gosimple</em>, and <em>megacheck</em> tools
167   have been replaced by <em>staticcheck</em>.
168   Similarly, the flags <code>-&lt;tool&gt;.enabled</code> and <code>-&lt;tool&gt;.exit-non-zero</code>
169   have been replaced by <code>-checks</code> and <code>-fail</code>.
170   Finally, the <code>-ignore</code> flag has been replaced
171   by <a href="/docs/#ignoring-problems">linter directives</a>.
172 </p>
173
174 <h2>Binary releases</h2>
175
176 <p>
177   Beginning with this release, we're publishing
178   <a href="https://github.com/dominikh/go-tools/releases">prebuilt binaries to GitHub</a>.
179   These releases still require a functioning Go installation in order to operate, however.
180 </p>
181
182 <h2>Other changes</h2>
183
184 <p>
185   We've removed the <code>-min_confidence</code> flag.
186   This flag hasn't been doing anything for years.
187 </p>
188
189 <p>
190   A new formatter called <a href="/docs/formatters">Stylish</a>
191   (usable with <code>-f stylish</code>)
192   provides output that is designed for easier consumption by humans.
193 </p>
194
195 <p>
196   Due to the restructuring of checkers, the <code>checker</code> field in JSON output has been replaced
197   with the <code>severity</code> field.
198 </p>
199
200 <h2 id="2019.1.1">Staticcheck 2019.1.1 Release Notes</h2>
201
202 <p>
203   The 2019.1.1 release of Staticcheck is the first bug fix release, fixing several bugs and improving performance.
204 </p>
205
206 <h3>Changes</h3>
207 <ul>
208   <li>
209     The ST category of checks no longer flag style issues of
210     aliased types when the aliased type exists in a package
211     we aren't explicitly checking. This avoids crashes and
212     erratic error reports.
213   </li>
214   <li>
215     Compiler errors now have correct position information.
216   </li>
217   <li>
218     A crash in the Stylish reporter has been fixed.
219   </li>
220   <li>
221     We no longer flag unused objects that belong to cgo internals.
222   </li>
223   <li>
224     The {{ check "U1000" }} check has been optimized, reducing its memory
225     usage and runtime.
226   </li>
227 </ul>