Skip to content

Commit b2e5b37

Browse files
Apply filtered changes (#79986)
1 parent ca5f846 commit b2e5b37

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎pkg/linters/os-stat-ignored-error-deref/osstatignoredeerrorderef.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ func (a *flowAnalyzer) expressionList(expressions []ast.Expr, state flowState) {
278278
}
279279

280280
func (a *flowAnalyzer) expression(expr ast.Expr, state flowState) {
281+
if expr == nil {
282+
return
283+
}
281284
if unary, ok := astutil.UnwrapParenExpr(expr).(*ast.UnaryExpr); ok && unary.Op == token.NOT {
282285
a.condition(unary, state)
283286
return

‎pkg/linters/os-stat-ignored-error-deref/testdata/src/osstatignoredeerrorderef/osstatignoredeerrorderef.go‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ func builtinPanicTerminates(path string) int64 {
123123
return info.Size()
124124
}
125125

126+
func ignoredStatInExpressionlessSwitch(path string) int64 {
127+
info, _ := os.Stat(path)
128+
switch {
129+
case true:
130+
return info.Size() // want "result of os.Stat is dereferenced"
131+
default:
132+
return 0
133+
}
134+
}
135+
126136
func checkedInIfInitializer(path string) int64 {
127137
if info, _ := os.Lstat(path); info != nil {
128138
return info.Size()

0 commit comments

Comments
 (0)