Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor inspect: pass set by value #12

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions zerologlint.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ func run(pass *analysis.Pass) (interface{}, error) {
for _, b := range sf.Blocks {
for _, instr := range b.Instrs {
if c, ok := instr.(*ssa.Call); ok {
inspect(c, &set)
inspect(c, set)
} else if c, ok := instr.(*ssa.Defer); ok {
inspect(c, &set)
inspect(c, set)
}
}
}
Expand All @@ -61,7 +61,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
return nil, nil
}

func inspect(cd callDefer, set *map[posser]struct{}) {
func inspect(cd callDefer, set map[posser]struct{}) {
c := cd.Common()

// check if it's in github.com/rs/zerolog/log since there's some
Expand All @@ -70,7 +70,7 @@ func inspect(cd callDefer, set *map[posser]struct{}) {
if isInLogPkg(*c) || isLoggerRecv(*c) {
if isZerologEvent(c.Value) {
// this ssa block should be dispatched afterwards at some point
(*set)[cd] = struct{}{}
set[cd] = struct{}{}
return
}
}
Expand Down Expand Up @@ -118,10 +118,10 @@ func inspect(cd callDefer, set *map[posser]struct{}) {
// if there's branch, remove both ways from the set
if phi, ok := val.(*ssa.Phi); ok {
for _, edge := range phi.Edges {
delete(*set, edge)
delete(set, edge)
}
} else {
delete(*set, val)
delete(set, val)
}
}
}
Expand Down