github.com/blueinnovationsgroup/can-go@v0.0.0-20230518195432-d0567cda0028/pkg/dbc/analysis/passes/messagenames/analyzer.go (about) 1 package messagenames 2 3 import ( 4 "github.com/blueinnovationsgroup/can-go/internal/identifiers" 5 "github.com/blueinnovationsgroup/can-go/pkg/dbc" 6 "github.com/blueinnovationsgroup/can-go/pkg/dbc/analysis" 7 ) 8 9 func Analyzer() *analysis.Analyzer { 10 return &analysis.Analyzer{ 11 Name: "messagenames", 12 Doc: "check that message names are valid CamelCase identifiers", 13 Run: run, 14 } 15 } 16 17 func run(pass *analysis.Pass) error { 18 for _, def := range pass.File.Defs { 19 messageDef, ok := def.(*dbc.MessageDef) 20 if !ok { 21 continue // not a message 22 } 23 if !identifiers.IsCamelCase(string(messageDef.Name)) { 24 pass.Reportf(messageDef.Pos, "message names must be CamelCase") 25 } 26 } 27 return nil 28 }