File tree Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "context"
5+
6+ "github.com/hashicorp/terraform-plugin-log/tflog"
7+ )
8+
9+ func noAssignment () {
10+ ctx := context .Background ()
11+
12+ // ruleid: setfield-without-assign
13+ tflog .SetField (ctx , "field" , "value" )
14+ }
15+
16+ func assigned () {
17+ ctx := context .Background ()
18+
19+ // ok: setfield-without-assign
20+ ctx = tflog .SetField (ctx , "field" , "value" )
21+ }
22+
23+ func returnedContext () context.Context {
24+ ctx := context .Background ()
25+
26+ // ok: setfield-without-assign
27+ return tflog .SetField (ctx , "field" , "value" )
28+ }
29+
30+ func declareAndAssign_SameName () {
31+ ctx := context .Background ()
32+
33+ for i := 0 ; i < 1 ; i ++ {
34+ // ok: setfield-without-assign
35+ ctx := tflog .SetField (ctx , "field" , "value" )
36+ }
37+ }
38+
39+ func declareAndAssign_Rename () {
40+ outerCtx := context .Background ()
41+
42+ for i := 0 ; i < 1 ; i ++ {
43+ // ok: setfield-without-assign
44+ innerCtx := tflog .SetField (outerCtx , "field" , "value" )
45+ }
46+ }
Original file line number Diff line number Diff line change 44 message : The return value of "tflog.SetField" must be used
55 patterns :
66 - pattern : tflog.SetField(...)
7- - pattern-not-inside : $CTX = tflog.SetField($CTX , ...)
7+ - pattern-not-inside : $CTX1 = tflog.SetField($CTX2 , ...)
88 - pattern-not-inside : return tflog.SetField($CTX, ...)
99 severity : ERROR
You can’t perform that action at this time.
0 commit comments