Skip to main content
Glama

protolint-mcp

by yoheimuta
fileHasCommentRule.go1.76 kB
package rules import ( "github.com/yoheimuta/go-protoparser/v4/parser" "github.com/yoheimuta/protolint/linter/report" "github.com/yoheimuta/protolint/linter/rule" "github.com/yoheimuta/protolint/linter/visitor" ) // FileHasCommentRule verifies that a file starts with a doc comment. type FileHasCommentRule struct { RuleWithSeverity } // NewFileHasCommentRule creates a new FileHasCommentRule. func NewFileHasCommentRule(severity rule.Severity) FileHasCommentRule { return FileHasCommentRule{ RuleWithSeverity: RuleWithSeverity{severity: severity}, } } // ID returns the ID of this rule. func (r FileHasCommentRule) ID() string { return "FILE_HAS_COMMENT" } // Purpose returns the purpose of this rule. func (r FileHasCommentRule) Purpose() string { return "Verifies that a file starts with a doc comment." } // IsOfficial decides whether or not this rule belongs to the official guide. func (r FileHasCommentRule) IsOfficial() bool { return false } // Apply applies the rule to the proto. func (r FileHasCommentRule) Apply(proto *parser.Proto) ([]report.Failure, error) { v := &fileHasCommentVisitor{ BaseAddVisitor: visitor.NewBaseAddVisitor(r.ID(), string(r.Severity())), } return visitor.RunVisitor(v, proto, r.ID()) } type fileHasCommentVisitor struct { *visitor.BaseAddVisitor } // VisitSyntax checks the syntax. func (v *fileHasCommentVisitor) VisitSyntax(s *parser.Syntax) bool { if !hasComment(s.Comments) { v.AddFailuref(s.Meta.Pos, `File should start with a doc comment`) } return false } // VisitEdition checks the syntax. func (v *fileHasCommentVisitor) VisitEdition(s *parser.Edition) bool { if !hasComment(s.Comments) { v.AddFailuref(s.Meta.Pos, `File should start with a doc comment`) } return false }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yoheimuta/protolint'

If you have feedback or need assistance with the MCP directory API, please join our Discord server