55[ ![ CodeQL] ( https://github.com/fillmore-labs/errortype/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main )] ( https://github.com/fillmore-labs/errortype/actions/workflows/github-code-scanning/codeql ) 
66[ ![ Coverage] ( https://codecov.io/gh/fillmore-labs/errortype/branch/main/graph/badge.svg?token=MMLHL14ZP6 )] ( https://codecov.io/gh/fillmore-labs/errortype ) 
77[ ![ Go Report Card] ( https://goreportcard.com/badge/fillmore-labs.com/errortype )] ( https://goreportcard.com/report/fillmore-labs.com/errortype ) 
8+ [ ![ Codeberg CI] ( https://ci.codeberg.org/api/badges/15305/status.svg?branch=main )] ( https://ci.codeberg.org/repos/15305 ) 
89[ ![ License] ( https://img.shields.io/github/license/fillmore-labs/errortype )] ( https://www.apache.org/licenses/LICENSE-2.0 ) 
910
1011` errortype `  is a Go static analysis tool (linter) that helps prevent subtle bugs in error handling and other areas. It
@@ -69,8 +70,9 @@ Usage: `errortype [-flag] [package]`
6970-  ** -c**  ` <N> ` : Display N lines of context around each issue (default: -1 for no context, 0 for only the offending
7071  line).
7172-  ** -test** : Analyze test files in addition to source files (default: true).
72- -  ** -heuristics** : (Experimental) List of heuristics used (default: “usage,receivers”, “off” to disable).
73- -  ** -trace** : (Experimental) Output information for result tracing.
73+ -  ** -heuristics** : ` <list> `  (Experimental) List of heuristics used (default: “var,usage,receivers”, “off” to disable).
74+ -  ** -tracetypes** : ` <regex> `  (Experimental) Trace error type detection in packages with names matching the regular
75+   expression.
7476
7577## Inconsistent Error Type Usage  
7678
@@ -135,7 +137,15 @@ The linter determines an error type's intended use _(pointer vs. value)_ by anal
1351371 .  ** Overrides**  (the highest priority): User-defined overrides (see [ below] ( #override-file ) ) are applied, overriding
136138   any detected usage.
137139
138- 2 .  ** Package-Level Variable Assignments** : If present, ` var _ error = ... `  assignments are used as explicit declarations
140+ 2 .  ** ` Unwrap `  related methods** : If present, ` Is ` , ` As `  and ` Unwrap `  methods with pointer receiver would be not visible
141+    from a value usage. If an error type would be used as a value, methods with pointer receivers are not in its
142+    [ method set] ( https://go.dev/ref/spec#Method_sets ) .
143+ 
144+    ``` go 
145+    func  (e  *PointerError ) Unwrap  error  { /*  ...*/   } //  Unwrap is only visible from error(&PointerError{}).
146+    ``` 
147+ 
148+ 3 .  ** Package-Level Variable Assignments** : If present, ` var _ error = ... `  assignments are used as explicit declarations
139149   of intent.
140150
141151   ``` go 
@@ -144,7 +154,7 @@ The linter determines an error type's intended use _(pointer vs. value)_ by anal
144154   var  _  error  = (*PointerError)(nil ) //  Determines PointerError is a "pointer" type.
145155   ``` 
146156
147- 3 .  ** Usage Within Functions** : If still undecided, the linter analyzes usage within top-level functions (in ` return ` 
157+ 4 .  ** Usage Within Functions** : If still undecided, the linter analyzes usage within top-level functions (in ` return ` 
148158   statements or type assertions). Consistent usage can determine the type.
149159
150160   ``` go 
@@ -155,7 +165,7 @@ The linter determines an error type's intended use _(pointer vs. value)_ by anal
155165
156166   Note: This heuristic is a fallback and should not be relied upon for defining a type's contract.
157167
158- 4 .  ** Consistent Method Receivers**  (lowest priority): As a final heuristic, if all methods on a type have a consistent
168+ 5 .  ** Consistent Method Receivers**  (lowest priority): As a final heuristic, if all methods on a type have a consistent
159169   receiver (all-value or all-pointer), that style is used.
160170
161171### Designing Linter-Friendly Packages  
@@ -181,21 +191,8 @@ var (
181191
182192### Overriding Detected Types  
183193
184- When the linter reports types from an imported package that have ambiguous or inconsistent usage, you can guide the
185- linter in two ways:
186- 
187- 1 .  ** Local Overrides** : For a one-off fix within a single package, add a ` var `  block to a source file in that package.
188-    This overrides the detected usage for that type _ within this package only_ .
189- 
190-    ``` go 
191-    //  In your code, force a specific usage for an imported type.
192-    var  _  error  = imported.ValueError {}
193- 
194-    var  _  error  = (*imported.PointerError )(nil )
195-    ``` 
196- 
197- 2 .  ** Global Override File** : For project-wide overrides, use an ` errortypes.yaml `  file, see
198-    _ [ “Override File”] ( #override-file ) _ .
194+ When the linter reports ambiguous or inconsistent usage from types of an imported package that you can not change, you
195+ can guide the linter with an override file, see _ [ “Override File”] ( #override-file ) _ .
199196
200197## Pointless Comparisons  
201198
@@ -377,6 +374,12 @@ specific problems.
377374- **`et:emb` (Embedded/Ambiguous Usage)**: The linter could not determine if an error is a pointer or value type. This 
378375  can be resolved with an [override](#overriding-detected-types). 
379376
377+ - **`et:var` (Variable Mismatch)**: An error type is assigned incorrectly in a 
378+   [variable declaration](https://go.dev/ref/spec#Variable_declarations) starting with `Err` or `err`. 
379+ 
380+ - **`et:rcv` (Receiver Mismatch)**: An `Unwrap` related method on a value error should be implemented with a value 
381+   receiver, not a pointer, otherwise it wouldn't be visible. 
382+ 
380383# ## Pointer Comparison Issues
381384
382385- **`et:cmp` (Pointless Error Comparison)**: A pointer is compared against the address of a newly created value in 
@@ -458,7 +461,10 @@ specific problems.
458461  type implementing `error`). This is also flagged by the standard Go 
459462  [`errorsas`](https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/errorsas) linter. 
460463
461- - **`et:auc` (Unchecked Type Assert)**: An unchecked type assert might lead to a run-time panic on a wrapped error. 
464+ - **`et:sig` (Wrong Signature)**: An `Unwrap` related method has the wrong signature. This is also flagged by the 
465+   standard Go [`stdmethods`](https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/stdmethods) linter. 
466+ 
467+ - **`et:uca` (Unchecked Type Assert)**: An unchecked type assert might lead to a run-time panic on a wrapped error. 
462468
463469  ` ` ` go
464470    if err.(*net.AddrError).Err == "missing port in address" { /* ... */ } 
@@ -474,15 +480,15 @@ Add a file `.custom-gcl.yaml` to your source with
474480
475481` ` ` yaml
476482--- 
477- version: v2.4 .0 
483+ version: v2.5 .0 
478484
479485name: golangci-lint 
480486destination: . 
481487
482488plugins: 
483489  - module: fillmore-labs.com/errortype 
484490    import: fillmore-labs.com/errortype/gclplugin 
485-     version: v0.0.5  
491+     version: v0.0.6  
486492` ` ` 
487493
488494then run `golangci-lint custom` from your project root. You get a custom `golangci-lint` executable that can be 
0 commit comments