.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / honnef.co / go / tools@v0.1.1 / doc / 2020.2.html
1 <ul class="changes-toc">
2   <li><a href="#performance-improvements">Performance improvements</a></li>
3   <li><a href="#unused">Changes to the detection of unused code</a><ul>
4           <li><a href="#unused-whole-program">Removal of whole-program mode and changes to the handling of exported identifiers</a></li>
5           <li><a href="#unused-improvements">Improvements</a></li>
6   </ul></li>
7   <li><a href="#ui-improvements">UI improvements</a></li>
8   <li><a href="#versioning-improvements">Changes to versioning scheme</a></li>
9   <li><a href="#checks">Checks</a><ul>
10           <li><a href="#checks-new">New checks</a></li>
11           <li><a href="#checks-changed">Changed checks</a></li>
12   </ul></li>
13   <li><a href="#2020.2.1">Staticcheck 2020.2.1 release notes</a></li>
14 </ul>
15
16 <h2 id="performance-improvements">Performance improvements</h2>
17
18 <p>
19   The primary focus of this release is a major improvement in performance, significantly reducing memory usage while also reducing runtimes.
20 </p>
21
22 <details style="margin-bottom: 1em;">
23   <summary>Benchmarks comparing the previous and current releases of Staticcheck</summary>
24   
25   <table class="table">
26         <caption>Uncached, GOMAXPROCS=1</caption>
27         <thead>
28           <tr>
29                 <th>Package</th>
30                 <th>2020.1.6</th>
31                 <th>2020.2</th>
32                 <th>Delta</th>
33                 <th>Stats</th>
34           </tr>
35         </thead>
36
37         <tbody>
38           <tr>
39                 <td>image/color </td>
40                 <td>2.41s ±19% </td>
41                 <td>2.00s ±14% </td>
42                 <td>-17.08%</td>
43                 <td>p=0.000, n=10+10</td>
44           </tr>
45
46           <tr>
47                 <td>k8s.io/kubernetes/pkg/... </td>
48                 <td>276s ± 1% </td>
49                 <td>219s ± 1% </td>
50                 <td>-20.62%</td>
51                 <td>p=0.000, n=10+10</td>
52           </tr>
53
54           <tr>
55                 <td>net/http </td>
56                 <td>6.18s ± 1% </td>
57                 <td>5.61s ± 5% </td>
58                 <td>-9.21%</td>
59                 <td>p=0.000, n=8+10</td>
60           </tr>
61
62           <tr>
63                 <td>std </td>
64                 <td>49.5s ± 1% </td>
65                 <td>42.5s ± 1% </td>
66                 <td>-14.04%</td>
67                 <td>p=0.000, n=9+10</td>
68           </tr>
69
70           <tr>
71                 <td>strconv </td>
72                 <td>2.49s ± 9% </td>
73                 <td>2.19s ±12% </td>
74                 <td>-12.08%</td>
75                 <td>p=0.001, n=10+10</td>
76           </tr>
77         </tbody>
78
79         <tbody>
80           <tr>
81                 <td>image/color </td>
82                 <td>167MB ±26% </td>
83                 <td>146MB ±19% </td>
84                 <td>-12.62%</td>
85                 <td>p=0.043, n=10+10</td>
86           </tr>
87
88           <tr>
89                 <td>k8s.io/kubernetes/pkg/... </td>
90                 <td>2.14GB ± 1% </td>
91                 <td>0.45GB ±13% </td>
92                 <td>-79.09%</td>
93                 <td>p=0.000, n=10+10</td>
94           </tr>
95
96           <tr>
97                 <td>net/http </td>
98                 <td>216MB ± 6% </td>
99                 <td>166MB ±18% </td>
100                 <td>-23.11%</td>
101                 <td>p=0.000, n=10+10</td>
102           </tr>
103
104           <tr>
105                 <td>std </td>
106                 <td>972MB ± 3% </td>
107                 <td>284MB ± 9% </td>
108                 <td>-70.82%</td>
109                 <td>p=0.000, n=8+10</td>
110           </tr>
111
112           <tr>
113                 <td>strconv </td>
114                 <td>155MB ±21% </td>
115                 <td>139MB ±29% </td>
116                 <td>~</td>
117                 <td>p=0.063, n=10+10</td>
118           </tr>
119         </tbody>
120   </table>
121
122   <table class="table">
123         <caption>Cached, GOMAXPROCS=1</caption>
124
125         <thead>
126           <tr>
127                 <th>Package</th>
128                 <th>2020.1.6</th>
129                 <th>2020.2</th>
130                 <th>Delta</th>
131                 <th>Stats</th>
132           </tr>
133         </thead>
134
135         <tbody>
136           <tr>
137                 <td>image/color </td>
138                 <td>160ms ± 0% </td>
139                 <td>107ms ± 7% </td>
140                 <td>-33.13%</td>
141                 <td>p=0.000, n=8+10</td>
142           </tr>
143
144           <tr>
145                 <td>k8s.io/kubernetes/pkg/... </td>
146                 <td>12.7s ± 1% </td>
147                 <td>6.9s ± 1% </td>
148                 <td>-45.26%</td>
149                 <td>p=0.000, n=9+10</td>
150           </tr>
151
152           <tr>
153                 <td>net/http </td>
154                 <td>370ms ± 0% </td>
155                 <td>230ms ± 0% </td>
156                 <td>-37.84%</td>
157                 <td>p=0.000, n=8+8</td>
158           </tr>
159
160           <tr>
161                 <td>std </td>
162                 <td>2.52s ± 1% </td>
163                 <td>1.31s ± 1% </td>
164                 <td>-48.13%</td>
165                 <td>p=0.000, n=10+9</td>
166           </tr>
167
168           <tr>
169                 <td>strconv </td>
170                 <td>164ms ± 4% </td>
171                 <td>110ms ± 0% </td>
172                 <td>-32.93%</td>
173                 <td>p=0.000, n=10+10</td>
174           </tr>
175         </tbody>
176
177         <tbody>
178           <tr>
179                 <td>image/color </td>
180                 <td>38.6MB ± 4% </td>
181                 <td>20.8MB ± 1% </td>
182                 <td>-45.96%</td>
183                 <td>p=0.000, n=9+10</td>
184           </tr>
185
186           <tr>
187                 <td>k8s.io/kubernetes/pkg/... </td>
188                 <td>863MB ± 4% </td>
189                 <td>283MB ± 2% </td>
190                 <td>-67.28%</td>
191                 <td>p=0.000, n=10+10</td>
192           </tr>
193
194           <tr>
195                 <td>net/http </td>
196                 <td>70.5MB ± 5% </td>
197                 <td>25.8MB ± 2% </td>
198                 <td>-63.48%</td>
199                 <td>p=0.000, n=10+9</td>
200           </tr>
201
202           <tr>
203                 <td>std </td>
204                 <td>243MB ±16% </td>
205                 <td>73MB ± 8% </td>
206                 <td>-70.00%</td>
207                 <td>p=0.000, n=10+10</td>
208           </tr>
209
210           <tr>
211                 <td>strconv </td>
212                 <td>37.2MB ± 2% </td>
213                 <td>21.3MB ± 1% </td>
214                 <td>-42.76%</td>
215                 <td>p=0.000, n=9+10</td>
216           </tr>
217         </tbody>
218   </table>
219
220   <table class="table">
221         <caption>Uncached, GOMAXPROCS=32</caption>
222
223         <thead>
224           <tr>
225                 <th>Package</th>
226                 <th>2020.1.6</th>
227                 <th>2020.2</th>
228                 <th>Delta</th>
229                 <th>Stats</th>
230           </tr>
231         </thead>
232
233         <tbody>
234           <tr>
235                 <td>image/color </td>
236                 <td>1.19s ±21% </td>
237                 <td>1.06s ±12% </td>
238                 <td>~</td>
239                 <td>p=0.115, n=10+8</td>
240           </tr>
241
242           <tr>
243                 <td>k8s.io/kubernetes/pkg/... </td>
244                 <td>27.0s ± 2% </td>
245                 <td>22.4s ± 2% </td>
246                 <td>-16.96%</td>
247                 <td>p=0.000, n=10+10</td>
248           </tr>
249
250           <tr>
251                 <td>net/http </td>
252                 <td>2.24s ±11% </td>
253                 <td>2.23s ±10% </td>
254                 <td>~</td>
255                 <td>p=0.870, n=10+10</td>
256           </tr>
257
258           <tr>
259                 <td>std </td>
260                 <td>7.14s ± 5% </td>
261                 <td>5.10s ± 9% </td>
262                 <td>-28.56%</td>
263                 <td>p=0.000, n=10+9</td>
264           </tr>
265
266           <tr>
267                 <td>strconv </td>
268                 <td>1.24s ±26% </td>
269                 <td>1.18s ±21% </td>
270                 <td>~</td>
271                 <td>p=0.753, n=10+10</td>
272           </tr>
273         </tbody>
274
275         <tbody>
276           <tr>
277                 <td>image/color </td>
278                 <td>143MB ± 7% </td>
279                 <td>141MB ± 6% </td>
280                 <td>~</td>
281                 <td>p=0.515, n=8+10</td>
282           </tr>
283
284           <tr>
285                 <td>k8s.io/kubernetes/pkg/... </td>
286                 <td>5.77GB ± 6% </td>
287                 <td>2.76GB ± 4% </td>
288                 <td>-52.25%</td>
289                 <td>p=0.000, n=10+10</td>
290           </tr>
291
292           <tr>
293                 <td>net/http </td>
294                 <td>284MB ±10% </td>
295                 <td>226MB ±14% </td>
296                 <td>-20.38%</td>
297                 <td>p=0.000, n=10+10</td>
298           </tr>
299
300           <tr>
301                 <td>std </td>
302                 <td>1.74GB ±10% </td>
303                 <td>1.15GB ±14% </td>
304                 <td>-34.11%</td>
305                 <td>p=0.000, n=10+10</td>
306           </tr>
307
308           <tr>
309                 <td>strconv </td>
310                 <td>148MB ±18% </td>
311                 <td>144MB ±16% </td>
312                 <td>~</td>
313                 <td>p=0.579, n=10+10</td>
314           </tr>
315         </tbody>
316   </table>
317
318
319   <table class="table">
320         <caption>Cached, GOMAXPROCS=32</caption>
321
322         <thead>
323           <tr>
324                 <th>Package</th>
325                 <th>2020.1.6</th>
326                 <th>2020.2</th>
327                 <th>Delta</th>
328                 <th>Stats</th>
329           </tr>
330         </thead>
331
332         <tbody>
333           <tr>
334                 <td>image/color </td>
335                 <td>96.0ms ± 6% </td>
336                 <td>80.0ms ± 0% </td>
337                 <td>-16.67%</td>
338                 <td>p=0.000, n=10+9</td>
339           </tr>
340
341           <tr>
342                 <td>k8s.io/kubernetes/pkg/... </td>
343                 <td>4.64s ± 1% </td>
344                 <td>3.88s ± 0% </td>
345                 <td>-16.22%</td>
346                 <td>p=0.000, n=9+8</td>
347           </tr>
348
349           <tr>
350                 <td>net/http </td>
351                 <td>216ms ± 3% </td>
352                 <td>167ms ± 4% </td>
353                 <td>-22.69%</td>
354                 <td>p=0.000, n=10+10</td>
355           </tr>
356
357           <tr>
358                 <td>std </td>
359                 <td>1.09s ± 2% </td>
360                 <td>0.96s ± 2% </td>
361                 <td>-12.20%</td>
362                 <td>p=0.000, n=10+10</td>
363           </tr>
364
365           <tr>
366                 <td>strconv </td>
367                 <td>100ms ± 0% </td>
368                 <td>87ms ± 8% </td>
369                 <td>-13.00%</td>
370                 <td>p=0.000, n=9+10</td>
371           </tr>
372         </tbody>
373
374         <tbody>
375           <tr>
376                 <td>image/color </td>
377                 <td>46.4MB ± 3% </td>
378                 <td>24.1MB ± 5% </td>
379                 <td>-48.08%</td>
380                 <td>p=0.000, n=8+10</td>
381           </tr>
382
383           <tr>
384                 <td>k8s.io/kubernetes/pkg/... </td>
385                 <td>1.38GB ± 9% </td>
386                 <td>0.27GB ± 1% </td>
387                 <td>-80.29%</td>
388                 <td>p=0.000, n=10+10</td>
389           </tr>
390
391           <tr>
392                 <td>net/http </td>
393                 <td>80.7MB ±12% </td>
394                 <td>31.4MB ± 2% </td>
395                 <td>-61.16%</td>
396                 <td>p=0.000, n=10+8</td>
397           </tr>
398
399           <tr>
400                 <td>std </td>
401                 <td>363MB ±12% </td>
402                 <td>75MB ± 7% </td>
403                 <td>-79.30%</td>
404                 <td>p=0.000, n=10+10</td>
405           </tr>
406
407           <tr>
408                 <td>strconv </td>
409                 <td>48.5MB ± 6% </td>
410                 <td>24.4MB ± 3% </td>
411                 <td>-49.72%</td>
412                 <td>p=0.000, n=10+10</td>
413           </tr>
414         </tbody>
415   </table>
416 </details>
417
418 <p>
419   See <a href="https://github.com/dominikh/go-tools/commit/5cfc85b70e7b778eb76fd7338e538d7c9af21e4e">commit 5cfc85b70e7b778eb76fd7338e538d7c9af21e4e</a>
420   for details on how these improvements have been achieved.
421 </p>
422
423 <p>
424   Furthermore, Staticcheck 2020.2 will skip very large packages (currently packages that are 50 MiB or larger),
425   under the assumption that these packages contain bundled assets and aren't worth analyzing.
426   This might further reduce Staticcheck's memory usage in your projects.
427 </p>
428
429 <h2 id="unused">Changes to the detection of unused code</h2>
430
431 <h3 id="unused-whole-program">Removal of whole-program mode and changes to the handling of exported identifiers</h3>
432 <p>
433   The <a href="#performance-improvements">aforementioned performance improvements</a> necessitate some changes to the <em>U1000</em> check (also known as <em>unused</em>).
434 </p>
435
436 <p>
437   The most visible change is the removal of the <em>whole program</em> mode.
438   This mode, which analyzed an entire program and reported unused code even if it is exported,
439   did not work well with the kind of caching that we use in Staticcheck.
440   Even in previous versions, it didn't always work correctly and may have caused flaky results,
441   depending on the state of the cache and the order of <code>staticcheck</code> invocations.
442 </p>
443
444 <p>
445   The whole-program mode may be revived in the future as a standalone tool,
446   with the understanding that this mode of operation is inherently more expensive than <code>staticcheck</code>.
447   In the meantime, if you depend on this functionality and can tolerate its bugs, you should continue using Staticcheck 2020.1.
448 </p>
449
450 <p>
451   As part of improving the correctness of U1000, changes were made to the normal mode as well.
452   In particular, <strong>all</strong> exported package-level identifiers will be considered used from now on,
453   even if these identifiers are declared in <code>package main</code> or tests, even if they are otherwise unused.
454   Exported identifiers in <code>package main</code> can be used in ways invisible to us, for example via the <code>plugin</code> build mode.
455   For tests, we would run into the same kind of issues as we did with the whole program mode.
456 </p>
457
458 <h3 id="unused-improvements">Improvements</h3>
459
460 <p>
461   The <code>//lint:ignore</code> directive now works more intelligently with the U1000 check.
462   In previous versions, the directive would only suppress the output of a diagnostic. For example, for the following example
463 </p>
464
465 <pre><code>package pkg
466
467 //lint:ignore U1000 This is fine.
468 func fn1() { fn2() }
469
470 func fn2() {}</code></pre>
471
472 <p>
473   Staticcheck would emit the following output:
474 </p>
475
476 <pre><samp>foo.go:6:6: func fn2 is unused (U1000)</samp></pre>
477
478 <p>
479   as it would only suppress the diagnostic for <code>fn1</code>.
480 </p>
481
482 <p>
483   Beginning with this release, the directive instead actively marks the identifier as used,
484   which means that any transitively used code will also be considered used, and no diagnostic will be reported for <code>fn2</code>.
485   Similarly, the <code>//lint:file-ignore</code> directive will consider everything in a file used, which may transitively mark code in other files used, too.
486 </p>
487
488 <h2 id="ui-improvements">UI improvements</h2>
489
490 We've made some minor improvements to the output and behavior of the <code>staticcheck</code> command:
491
492 <ul>
493   <li>the command now prints instructions on how to look up documentation for checks</li>
494   <li>output of the <code>-explain</code> flag includes a link to the online documentation</li>
495   <!-- <li>the <code>-f</code> flag gets validated <em>before</em> analyzing packages</li> -->
496   <li>a warning is emitted when a package pattern matches no packages</li>
497   <li>unmatched ignore directives cause <code>staticcheck</code> to exit with a non-zero status code</li>
498 </ul>
499
500 <h2 id="versioning-improvements">Changes to versioning scheme</h2>
501
502 <p>
503   Staticcheck releases have two version numbers: one meant for human consumption and one meant for consumption by machines, via Go modules.
504   For example, the previous release was both <code>2020.1.6</code> (for humans) and <code>v0.0.1-2020.1.6</code> (for machines).
505 </p>
506
507 <p>
508   In previous releases, we've tried to include the human version in the machine version, by using the <code>v0.0.1-&lt;human version&gt;</code> scheme.
509   However, this scheme had various drawbacks.
510   For this and future releases we've switched to a more standard scheme for machine versions: <code>v0.&lt;minor&gt;.&lt;patch&gt;</code>.
511   Minor will increase by one for every feature release of Staticcheck,
512   and patch will increase by one for every bugfix release of Staticcheck,
513   resetting to zero on feature releases.
514 </p>
515
516 <p>
517   For example, this release is both <code>2020.2</code> and <code>v0.1.0</code>.
518   A hypothetical <code>2020.2.1</code> would be <code>v0.1.1</code>, and <code>2021.1</code> will be <code>v0.2.0</code>.
519   This new versioning scheme fixes various issues when trying to use Staticcheck as a Go module.
520   It will also allow us to make true pre-releases in the future.
521 </p>
522
523 <p>
524   Documentation on the website, as well as the output of <code>staticcheck -version</code>, will include both version numbers, to make it easier to associate the two.
525 </p>
526
527 <p>
528   For detailed information on how we arrived at this decision, see the discussion on <a href="https://github.com/dominikh/go-tools/issues/777">issue 777</a>.
529 </p>
530
531 <h2 id="checks">Checks</h2>
532 <h3 id="checks-new">New checks</h3>
533
534 <p>
535   The following new checks have been added:
536 </p>
537
538 <ul>
539   <li>{{ check "SA4023" }} flags impossible comparisons of interface values with untyped nils</li>
540   <li>{{ check "SA5012" }} flags function calls with slice arguments that aren't the right length</li>
541   <li>{{ check "SA9006" }} flags dubious bit shifts of fixed size integers</li>
542 </ul>
543
544 <h3 id="checks-changed">Changed checks</h3>
545
546 <p>
547   Several checks have been improved:
548 </p>
549
550 <ul>
551   <li>{{ check "S1030" }} no longer recommends replacing <code>m[string(buf.Bytes())]</code> with <code>m[buf.String()]</code>, as the former gets optimized by the compiler</li>
552   <li>{{ check "S1008" }} no longer incorrectly suggests that the negation of <code>&gt;=</code> is <code>&lt;=</code></li>
553   <li>{{ check "S1029" }} and {{ check "SA6003" }} now also check custom types with underlying type <code>string</code></li>
554   <li>{{ check "SA1019" }} now recognizes deprecation notices that aren't in the last paragraph of a comment</li>
555   <li>{{ check "SA1019" }} now emits more precise diagnostics for deprecated code in the standard library</li>
556   <li>{{ check "SA4006" }} no longer flags assignments where the value is a typed nil</li>
557   <li>{{ check "SA5011" }} is now able to detect more functions that never return, thus reducing the number of false positives</li>
558   <li>{{ check "SA9004" }} no longer assumes that constants belong to the same group when they have different types</li>
559   <li>Automatic fixes for {{ check "SA9004" }} inside gopls no longer incorrectly duplicate comments</li>
560   <li>{{ check "ST1003" }} no longer complains about ALL_CAPS in variable names that don't contain any letters</li>
561   <li>Incorrect position information in various checks have been fixed</li>
562   <li>Crashes in various checks have been fixed</li>
563 </ul>
564
565 <h2 id="2020.2.1">Staticcheck 2020.2.1 release notes</h2>
566
567 <p>
568   This release eliminates some false negatives as well as false positives, makes the <code>staticcheck</code> command less noisy and fixes a potential security issue.
569 </p>
570
571 <ul>
572   <li>{{ check "SA4020" }} no longer claims that <code>case nil</code> is an unreachable case in a type switch.</li>
573   <li>{{ check "S1025" }} no longer marks uses of Printf as unnecessary when the printed types implement the <code>fmt.Formatter</code> interface.</li>
574   <li>Various checks may now detect bugs in conditional code that were previously missed. This was a regression introduced in Staticcheck 2020.1.</li>
575   <li>The <code>staticcheck</code> command no longer reminds the user of the <code>-explain</code> flag every time problems are found. This was deemed too noisy.</li>
576   <li>
577         We've updated our dependency on <code>golang.org/x/tools</code> to guard against arbitrary code execution on Windows.
578         Note that to be fully safe, you will also have to update your installation of Go.
579         See the <a href="https://blog.golang.org/path-security">Command PATH security in Go</a> article by the Go authors for more information on this potential vulnerability.
580   </li>
581 </ul>