Skip to content

Commit 2ec0ac6

Browse files
docs: update comments in lint
1 parent 32024eb commit 2ec0ac6

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

lint/config.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
package lint
22

3-
// Config represent linter config
4-
type Config struct {
5-
Formatter string `yaml:"formatter"`
6-
Rules map[string]RuleConfig `yaml:"rules"`
7-
}
8-
93
// RuleConfig represent config for a rule
104
type RuleConfig struct {
11-
Enabled bool `yaml:"enabled"`
12-
Severity Severity `yaml:"severity"`
5+
Enabled bool `yaml:"enabled"`
6+
7+
Severity Severity `yaml:"severity"`
8+
139
Argument interface{} `yaml:"argument"`
1410

15-
// Optional flags
11+
// Flags are optional key value pairs
1612
Flags map[string]interface{} `yaml:"flags"`
1713
}
1814

19-
// GetRule returns RuleConfig for given ruleName
15+
// Config represent linter config
16+
type Config struct {
17+
// Formatter of the lint result
18+
Formatter string `yaml:"formatter"`
19+
20+
// Rules is rule name to rule config map
21+
Rules map[string]RuleConfig `yaml:"rules"`
22+
}
23+
24+
// GetRule returns RuleConfig for given rule name
2025
func (c *Config) GetRule(ruleName string) RuleConfig {
2126
return c.Rules[ruleName]
2227
}

lint/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const (
66
SeverityError Severity = "error"
77
)
88

9+
// Severity represent the severity level of a rule
910
type Severity string
1011

1112
func (s Severity) String() string {

lint/formatter.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ package lint
44
type Formatter interface {
55
// Name is a unique identifier for formatter
66
Name() string
7-
Format(res *Result) (string, error)
7+
8+
// Format formats the linter result
9+
Format(result *Result) (string, error)
810
}

lint/linter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import (
55
"github.com/conventionalcommit/commitlint/message"
66
)
77

8-
// Linter is a simple linter for conventional commits
8+
// Linter is linter for commit message
99
type Linter struct {
1010
conf *Config
1111
rules []Rule
1212
}
1313

14-
// NewLinter returns a new Linter object with given conf
14+
// NewLinter returns a new Linter instance with given config and rules
1515
func NewLinter(conf *Config, rules []Rule) (*Linter, error) {
1616
return &Linter{conf: conf, rules: rules}, nil
1717
}
@@ -28,7 +28,7 @@ func (l *Linter) Lint(commitMsg string) (*Result, error) {
2828
return l.LintCommit(msg)
2929
}
3030

31-
// LintCommit checks the given parser.Commit for rules
31+
// LintCommit checks the given message.Commit against rules
3232
func (l *Linter) LintCommit(msg *message.Commit) (*Result, error) {
3333
res := newResult(msg.FullCommit)
3434

lint/rule.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ type Rule interface {
1313
Apply(arg interface{}, flags map[string]interface{}) error
1414

1515
// Validate validates the rule for given message
16+
// if given message is valid, return true and result string is ignored
17+
// if invalid, return a error result with false
1618
Validate(msg *message.Commit) (result string, isValid bool)
1719
}

0 commit comments

Comments
 (0)