github.com/blueinnovationsgroup/can-go@v0.0.0-20230518195432-d0567cda0028/pkg/dbc/analysis/passes/uniquesignalnames/analyzer.go (about) 1 package uniquesignalnames 2 3 import ( 4 "github.com/blueinnovationsgroup/can-go/pkg/dbc" 5 "github.com/blueinnovationsgroup/can-go/pkg/dbc/analysis" 6 ) 7 8 func Analyzer() *analysis.Analyzer { 9 return &analysis.Analyzer{ 10 Name: "uniquesignalnames", 11 Doc: "check that all signal names are unique", 12 Run: run, 13 } 14 } 15 16 func run(pass *analysis.Pass) error { 17 for _, def := range pass.File.Defs { 18 message, ok := def.(*dbc.MessageDef) 19 if !ok || dbc.IsIndependentSignalsMessage(message) { 20 continue 21 } 22 signalNames := make(map[dbc.Identifier]struct{}) 23 for i := range message.Signals { 24 signal := &message.Signals[i] 25 if _, ok := signalNames[signal.Name]; ok { 26 pass.Reportf(signal.Pos, "non-unique signal name") 27 } else { 28 signalNames[signal.Name] = struct{}{} 29 } 30 } 31 } 32 return nil 33 }