Skip to content

Commit

Permalink
ruleguard: add DocNote field
Browse files Browse the repository at this point in the history
  • Loading branch information
quasilyte committed Apr 29, 2021
1 parent 0a861a9 commit 9dd3307
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions ruleguard/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ func (p *rulesParser) parseDocComments(comment *ast.CommentGroup) error {
"summary",
"before",
"after",
"note",
}

for _, c := range comment.List {
Expand All @@ -380,6 +381,8 @@ func (p *rulesParser) parseDocComments(comment *ast.CommentGroup) error {
p.group.DocBefore = s
case "after":
p.group.DocAfter = s
case "note":
p.group.DocNote = s
case "tags":
p.group.DocTags = strings.Fields(s)
default:
Expand Down
12 changes: 9 additions & 3 deletions ruleguard/ruleguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,20 @@ type GoRuleGroup struct {
DocTags []string

// DocSummary is a short one sentence description.
// Filled from the `gorules:summary` doc content.
// Filled from the `doc:summary` pragma content.
DocSummary string

// DocBefore is a code snippet of code that will violate rule.
// Filled from the `gorules:before` doc content.
// Filled from the `doc:before` pragma content.
DocBefore string

// DocAfter is a code snippet of fixed code that complies to the rule.
// Filled from the `gorules:after` doc content.
// Filled from the `doc:after` pragma content.
DocAfter string

// DocNote is an optional caution message or advice.
// Usually, it's used to reference some external resource, like
// issue on the GitHub.
// Filled from the `doc:note` pragma content.
DocNote string
}

0 comments on commit 9dd3307

Please sign in to comment.