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 / 2017.2.html
1 <h2>Introduction to staticcheck 2017.2</h2>
2
3 <p>
4   The 2017.2 release of the staticcheck suite of tools focuses on
5   reducing friction – fewer false positives, more tools for suppressing
6   unwanted output, and JSON output for easier integration with other
7   tools.
8 </p>
9
10 <h2>New features</h2>
11
12 <h3>Linter directives for ignoring problems</h3>
13
14 <p>
15   In the past, the only ways to ignore reported problems was by using
16   the <code>-ignore</code> flag. This led to overreaching ignore rules
17   which weren't maintained regularly. Now, <code>//lint:ignore</code> and
18   <code>//lint:file-ignore</code> comments can be used to ignore
19   problems, either on specific lines or file-wide. A full description of
20   these directives, their syntax and their behavior can be found
21   <a href="/docs#ignoring-problems">in the documentation.</a>
22 </p>
23
24 <p>
25   A related change adds the <code>-show-ignored</code> command line
26   flag, which outputs problems that would otherwise be ignored by
27   directives. This is primarily of use with the JSON output format,
28   for custom front ends.
29 </p>
30
31 <h3>Output formats</h3>
32
33 <p>
34   All staticcheck tools now support multiple output formats, selectable
35   with the <code>-f</code> flag.
36 </p>
37
38 <p>
39   Currently, two formats are supported. The first format is
40   <code>text</code>, which is the default and uses the existing terminal
41   output format. The other is <code>json</code>, which emits JSON. The
42   output is a stream of objects, allowing for a future streaming output
43   mode. Each object uses the following example schema:
44 </p>
45
46 <pre><code>{
47   "checker": "staticcheck",
48   "code": "SA4006",
49   "location": {
50     "file": "/usr/lib/go/src/database/sql/sql_test.go",
51     "line": 2701,
52     "column": 5
53   },
54   "message": "this value of err is never used",
55   "ignored": false
56 }</code></pre>
57
58 <h3>Control over the exit code of megacheck</h3>
59
60 <p>
61   Megacheck, the tool for running multiple checkers at once, now has
62   per checker flags for controlling the overall exit code. Previously,
63   megacheck would exit non-zero if any checker found a problem. Now it
64   is possible to configure for each checker whether it should cause a
65   non-zero exit, by using the <code>-&lt;checker&gt;.exit-non-zero</code>
66   flags. This flag defaults to false for <em>gosimple</em> and to true for
67   the other checkers.
68 </p>
69
70 <h2>Changes to checks</h2>
71
72 <h3>Support for <code>NoCopy</code> in <em>unused</em></h3>
73
74 <p>
75   The <em>unused</em> tool now understands <code>NoCopy</code> sentinel types. The
76   <code>NoCopy</code> type, which is canonically a struct with no fields and only a
77   single, empty <code>Lock</code> method, can be used to mark structs as not safe
78   for copying. By declaring a field of this type, <em>go vet</em> will complain
79   when it sees instances of the struct being copied.
80 </p>
81
82 <p>
83   In the past, <em>unused</em> marked these fields as unused, now it ignores
84   them.
85 </p>
86
87 <h3>Detection of deprecated identifiers</h3>
88
89 <p>
90   <span class="check-name" title="Using a deprecated function, variable, constant or field">SA1019</span> now
91   correctly identifies deprecated methods, in addition to fields and
92   package-level objects. Additionally, staticcheck now keeps track of
93   when each identifier in the Go standard library was deprecated, so
94   that using <code>-go &lt;version&gt;</code> can correctly
95   ignore deprecation warnings that don't apply to the targeted Go
96   version.
97 </p>
98
99 <h3>Other</h3>
100
101 <ul>
102   <li>
103     {{ check "SA4017" }} no
104     longer reports pure functions that are stubs – functions that
105     immediately panic or return a constant.
106   </li>
107   <li>
108     {{ check "SA5007" }} no
109     longer flags infinite recursion when the function call is spawned
110     as a new goroutine.
111   </li>
112   <li>
113     {{ check "SA6002" }}
114     now recognizes that <code>unsafe.Pointer</code> is
115     a pointer type.
116   </li>
117   <li>
118     {{ check "S1005" }}
119     no longer suggests <code>for range</code> when targeting a version
120     older than Go 1.4.
121   </li>
122   <li>
123     {{ check "S1026" }} has been
124     removed. In some rare instances, copying a string is necessary, and
125     all common ways of doing this were incorrectly flagged by the check.
126   </li>
127 </ul>
128
129
130 <h2>Other changes</h2>
131
132 <ul>
133   <li>
134     The <code>-ignore</code> flag now supports ignoring checks in all packages,
135     by using <code>*</code> as the path.
136   </li>
137   <li>
138     <code>//line</code> directives are now being ignored when
139     reporting problems. That is, problems will always be reported for
140     the actual position in the Go files they occur.
141   </li>
142   <li>
143     From now on, only the first compilation error encountered will be
144     reported. The tools expect to be run on valid Go code and there
145     was little (if any) value in reporting all compilation errors
146     encountered, especially because simple errors can lead to many
147     follow-up errors.
148   </li>
149 </ul>
150
151 <h2 id="2017.2.1">Staticcheck 2017.2.1 Release Notes</h2>
152
153 <p>
154   The 2017.2.1 release of the staticcheck suite of tools is the first
155   bug fix release, fixing one bug.
156 </p>
157
158 <h3>Fixed bugs</h3>
159
160 <ul>
161   <li>
162     Staticcheck 2017.2 made the detection of deprecated objects
163     Go-version aware. Unfortunately, this only worked correctly for
164     fields and methods, but not package-level objects. This release
165     fixes that.
166   </li>
167 </ul>
168
169 <h2 id="2017.2.2">Staticcheck 2017.2.2 Release Notes</h2>
170
171 <p>
172   The 2017.2.2 release of the staticcheck suite of tools is the second
173   bug fix release, fixing several bugs.
174 </p>
175
176 <h3>Fixed bugs</h3>
177
178 <ul>
179   <li><em>unused</em>: correctly apply the NoCopy exemption when using the <code>-exported</code> flag.</li>
180   <li><em>keyify</em>: support external test packages (<code>package foo_test</code>)</li>
181   <li><em>staticcheck</em>: disable {{ check "SA4005" }} – the check, in its current form, is prone to false positives and will be reimplemented in a future release.</li>
182 </ul>