New returns an analysis.Analyzer to use with golangci-lint.
(cfg any)
| 45 | |
| 46 | // New returns an analysis.Analyzer to use with golangci-lint. |
| 47 | func New(cfg any) (register.LinterPlugin, error) { |
| 48 | allowedTagNames := map[string]bool{} |
| 49 | allowedTagTypes := map[string]bool{} |
| 50 | |
| 51 | if cfg != nil { |
| 52 | if settingsMap, ok := cfg.(map[string]any); ok { |
| 53 | if exceptionsRaw, ok := settingsMap["allowed-tag-names"]; ok { |
| 54 | if exceptionsList, ok := exceptionsRaw.([]any); ok { |
| 55 | for _, item := range exceptionsList { |
| 56 | if exception, ok := item.(string); ok { |
| 57 | allowedTagNames[exception] = true |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | if exceptionsRaw, ok := settingsMap["allowed-tag-types"]; ok { |
| 64 | if exceptionsList, ok := exceptionsRaw.([]any); ok { |
| 65 | for _, item := range exceptionsList { |
| 66 | if exception, ok := item.(string); ok { |
| 67 | allowedTagTypes[exception] = true |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | return &StructFieldPlugin{ |
| 76 | allowedTagNames: allowedTagNames, |
| 77 | allowedTagTypes: allowedTagTypes, |
| 78 | }, nil |
| 79 | } |
| 80 | |
| 81 | // BuildAnalyzers builds the analyzers for the StructFieldPlugin. |
| 82 | func (f *StructFieldPlugin) BuildAnalyzers() ([]*analysis.Analyzer, error) { |
no outgoing calls