You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# golangci/golangci-lint#4196
1. TestdataDir() -> analysistest.TestData()
2. Described False-Negative cases as testcases and in README.md
3. Fixed link for type_nested.go.skip in README.md
4. Added testcase with generic
5. Added testcase with alias
6. Added testcase with map, chan, array, func
# golangci/golangci-lint#4196
7. Added glob syntax for pkgs
8. Renamed options
9. Extended unexpected code message
10. Added unimplemented testcases
Copy file name to clipboardExpand all lines: README.md
+23-3Lines changed: 23 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -18,8 +18,8 @@ Installation
18
18
19
19
### Options
20
20
21
-
-`-b`, `--blockedPkgs` - list of packages, where the structures should be created by factories. By default, all structures in all packages should be created by factories, [tests](testdata/src/factory/blockedPkgs).
22
-
-`-ob`, `onlyBlockedPkgs` - only blocked packages should use factory to initiate struct, [tests](testdata/src/factory/onlyBlockedPkgs).
21
+
-`--packageGlobs` - list of glob packages, which can create structures without factories inside the glob package. By default, all structures from another package should be created by factories, [tests](testdata/src/factory/packageGlobs).
22
+
-`onlyPackageGlobs` - use a factory to initiate a structure for glob packages only, [tests](testdata/src/factory/onlyPackageGlobs).
23
23
24
24
## Example
25
25
@@ -120,8 +120,28 @@ func nextID() int64 {
120
120
</td></tr>
121
121
</tbody></table>
122
122
123
+
## False Negative
124
+
125
+
Linter doesn't catch some cases.
126
+
127
+
1. Buffered channel. You can initialize struct in line `v, ok := <-bufCh`[example](testdata/src/factory/unimplemented/chan.go).
128
+
2. Local initialization, [example](testdata/src/factory/unimplemented/local/).
129
+
3. Named return. If you want to block that case, you can use [nonamedreturns](https://github.com/firefart/nonamedreturns) linter, [example](testdata/src/factory/unimplemented/named_return.go).
130
+
4. var declaration, `var initilized nested.Struct` gives structure without factory, [example](testdata/src/factory/unimplemented/var.go).
131
+
5. Casting to nested struct, [example](testdata/src/factory/unimplemented/casting/).
132
+
123
133
## TODO
124
134
135
+
### Possible Features
136
+
137
+
1. Catch nested struct in the same package, [example](testdata/src/factory/unimplemented/local/nested_struct.go).
138
+
```go
139
+
returnStruct{
140
+
Other: OtherStruct{}, // want `Use factory for nested.Struct`
141
+
}
142
+
```
143
+
2. Resolve false negative issue with `var declaration`.
144
+
125
145
### Features that are difficult to implement and unplanned
126
146
127
-
1. Type assertion, type declaration and type underlying, [tests](testdata/src/factory/default/type_nested.go.skip).
147
+
1. Type assertion, type declaration and type underlying, [tests](testdata/src/factory/simple/type_nested.go.skip).
0 commit comments