rule

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package rule contains lint rules

Index

Constants

This section is empty.

Variables

View Source
var CaseValues = casing.All

CaseValues is the ordered list of supported case formats. Use the casing.* constants (e.g. casing.Lower, casing.Pascal) when referring to individual formats in code.

Functions

This section is empty.

Types

type BodyCaseRule

type BodyCaseRule struct{ Case string }

BodyCaseRule validates that the commit body as a whole matches a given case format. An empty body always passes. Argument: one of the casing.* constants.

func (*BodyCaseRule) Apply

func (r *BodyCaseRule) Apply(s lint.RuleSetting) error

func (*BodyCaseRule) Name

func (r *BodyCaseRule) Name() string

func (*BodyCaseRule) Validate

func (r *BodyCaseRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type BodyEmptyRule

type BodyEmptyRule struct{}

BodyEmptyRule validates that the commit body is not empty.

func (*BodyEmptyRule) Apply

func (r *BodyEmptyRule) Apply(_ lint.RuleSetting) error

func (*BodyEmptyRule) Name

func (r *BodyEmptyRule) Name() string

func (*BodyEmptyRule) Validate

func (r *BodyEmptyRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type BodyFullStopRule

type BodyFullStopRule struct{ Char string }

BodyFullStopRule checks that the body does NOT end with a given character.

func (*BodyFullStopRule) Apply

func (r *BodyFullStopRule) Apply(s lint.RuleSetting) error

func (*BodyFullStopRule) Name

func (r *BodyFullStopRule) Name() string

func (*BodyFullStopRule) Validate

func (r *BodyFullStopRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type BodyLeadingBlankRule

type BodyLeadingBlankRule struct{}

BodyLeadingBlankRule checks that when a body is present, it begins with a blank line (i.e. the raw commit message has an empty line between header and body).

func (*BodyLeadingBlankRule) Apply

func (*BodyLeadingBlankRule) Name

func (r *BodyLeadingBlankRule) Name() string

func (*BodyLeadingBlankRule) Validate

func (r *BodyLeadingBlankRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type BodyMaxLenRule

type BodyMaxLenRule struct{ CheckLen int }

BodyMaxLenRule to validate max length of body

func (*BodyMaxLenRule) Apply

func (r *BodyMaxLenRule) Apply(s lint.RuleSetting) error

func (*BodyMaxLenRule) Name

func (r *BodyMaxLenRule) Name() string

func (*BodyMaxLenRule) Validate

func (r *BodyMaxLenRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type BodyMaxLineLenRule

type BodyMaxLineLenRule struct{ CheckLen int }

BodyMaxLineLenRule to validate max line length of body

func (*BodyMaxLineLenRule) Apply

func (*BodyMaxLineLenRule) Name

func (r *BodyMaxLineLenRule) Name() string

func (*BodyMaxLineLenRule) Validate

func (r *BodyMaxLineLenRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type BodyMinLenRule

type BodyMinLenRule struct{ CheckLen int }

BodyMinLenRule to validate min length of body

func (*BodyMinLenRule) Apply

func (r *BodyMinLenRule) Apply(s lint.RuleSetting) error

func (*BodyMinLenRule) Name

func (r *BodyMinLenRule) Name() string

func (*BodyMinLenRule) Validate

func (r *BodyMinLenRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type BreakingChangeExclamationMarkRule

type BreakingChangeExclamationMarkRule struct{}

BreakingChangeExclamationMarkRule implements the breaking-change-exclamation-mark rule.

It enforces that breaking changes are signalled consistently via an XNOR:

  • PASS when the header contains "!" AND a footer note has token "BREAKING CHANGE" or "BREAKING-CHANGE".
  • PASS when neither signal is present.
  • FAIL when exactly one of the two is present.

func (*BreakingChangeExclamationMarkRule) Apply

func (*BreakingChangeExclamationMarkRule) Name

func (*BreakingChangeExclamationMarkRule) Validate

Validate validates BreakingChangeExclamationMarkRule.

type DescriptionCaseRule

type DescriptionCaseRule struct{ Case string }

DescriptionCaseRule validates that the commit description (subject) matches a given case format. Argument: one of the casing.* constants.

func (*DescriptionCaseRule) Apply

func (*DescriptionCaseRule) Name

func (r *DescriptionCaseRule) Name() string

func (*DescriptionCaseRule) Validate

func (r *DescriptionCaseRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type DescriptionEmptyRule

type DescriptionEmptyRule struct{}

DescriptionEmptyRule validates that the commit description is not empty.

func (*DescriptionEmptyRule) Apply

func (*DescriptionEmptyRule) Name

func (r *DescriptionEmptyRule) Name() string

func (*DescriptionEmptyRule) Validate

func (r *DescriptionEmptyRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type DescriptionFullStopRule

type DescriptionFullStopRule struct{ Char string }

DescriptionFullStopRule checks that the description does NOT end with a given character.

func (*DescriptionFullStopRule) Apply

func (*DescriptionFullStopRule) Name

func (r *DescriptionFullStopRule) Name() string

func (*DescriptionFullStopRule) Validate

func (r *DescriptionFullStopRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type DescriptionMaxLenRule

type DescriptionMaxLenRule struct{ CheckLen int }

DescriptionMaxLenRule to validate max length of description

func (*DescriptionMaxLenRule) Apply

func (*DescriptionMaxLenRule) Name

func (r *DescriptionMaxLenRule) Name() string

func (*DescriptionMaxLenRule) Validate

func (r *DescriptionMaxLenRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type DescriptionMinLenRule

type DescriptionMinLenRule struct{ CheckLen int }

DescriptionMinLenRule to validate min length of description

func (*DescriptionMinLenRule) Apply

func (*DescriptionMinLenRule) Name

func (r *DescriptionMinLenRule) Name() string

func (*DescriptionMinLenRule) Validate

func (r *DescriptionMinLenRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type FooterEmptyRule

type FooterEmptyRule struct{}

FooterEmptyRule validates that the commit footer is not empty.

func (*FooterEmptyRule) Apply

func (r *FooterEmptyRule) Apply(_ lint.RuleSetting) error

func (*FooterEmptyRule) Name

func (r *FooterEmptyRule) Name() string

func (*FooterEmptyRule) Validate

func (r *FooterEmptyRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type FooterEnumRule

type FooterEnumRule struct {
	Tokens []string
}

FooterEnumRule to validate footer tokens

func (*FooterEnumRule) Apply

func (r *FooterEnumRule) Apply(setting lint.RuleSetting) error

Apply sets the needed argument for the rule

func (*FooterEnumRule) Name

func (r *FooterEnumRule) Name() string

Name return name of the rule

func (*FooterEnumRule) Validate

func (r *FooterEnumRule) Validate(msg lint.Commit) (*lint.Issue, bool)

Validate validates FooterEnumRule

type FooterLeadingBlankRule

type FooterLeadingBlankRule struct{}

FooterLeadingBlankRule checks that when a footer is present, it begins with a blank line (i.e. there is an empty line between body/header and footer).

func (*FooterLeadingBlankRule) Apply

func (*FooterLeadingBlankRule) Name

func (r *FooterLeadingBlankRule) Name() string

func (*FooterLeadingBlankRule) Validate

func (r *FooterLeadingBlankRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type FooterMaxLenRule

type FooterMaxLenRule struct{ CheckLen int }

FooterMaxLenRule to validate max length of footer

func (*FooterMaxLenRule) Apply

func (r *FooterMaxLenRule) Apply(s lint.RuleSetting) error

func (*FooterMaxLenRule) Name

func (r *FooterMaxLenRule) Name() string

func (*FooterMaxLenRule) Validate

func (r *FooterMaxLenRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type FooterMaxLineLenRule

type FooterMaxLineLenRule struct{ CheckLen int }

FooterMaxLineLenRule to validate max line length of footer

func (*FooterMaxLineLenRule) Apply

func (*FooterMaxLineLenRule) Name

func (r *FooterMaxLineLenRule) Name() string

func (*FooterMaxLineLenRule) Validate

func (r *FooterMaxLineLenRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type FooterMinLenRule

type FooterMinLenRule struct{ CheckLen int }

FooterMinLenRule to validate min length of footer

func (*FooterMinLenRule) Apply

func (r *FooterMinLenRule) Apply(s lint.RuleSetting) error

func (*FooterMinLenRule) Name

func (r *FooterMinLenRule) Name() string

func (*FooterMinLenRule) Validate

func (r *FooterMinLenRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type FooterTypeEnumParam

type FooterTypeEnumParam struct {
	Token  string
	Types  []string
	Values []string
}

FooterTypeEnumParam represent a single footer type param

type FooterTypeEnumRule

type FooterTypeEnumRule struct {
	Params []*FooterTypeEnumParam
}

FooterTypeEnumRule to validate footer tokens

func (*FooterTypeEnumRule) Apply

func (r *FooterTypeEnumRule) Apply(setting lint.RuleSetting) error

Apply sets the needed argument for the rule

func (*FooterTypeEnumRule) Name

func (r *FooterTypeEnumRule) Name() string

Name return name of the rule

func (*FooterTypeEnumRule) Validate

func (r *FooterTypeEnumRule) Validate(msg lint.Commit) (*lint.Issue, bool)

Validate validates FooterTypeEnumRule

type HeadMaxLenRule

type HeadMaxLenRule struct{ CheckLen int }

HeadMaxLenRule to validate max length of header

func (*HeadMaxLenRule) Apply

func (r *HeadMaxLenRule) Apply(s lint.RuleSetting) error

func (*HeadMaxLenRule) Name

func (r *HeadMaxLenRule) Name() string

func (*HeadMaxLenRule) Validate

func (r *HeadMaxLenRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type HeadMinLenRule

type HeadMinLenRule struct{ CheckLen int }

HeadMinLenRule to validate min length of header

func (*HeadMinLenRule) Apply

func (r *HeadMinLenRule) Apply(s lint.RuleSetting) error

func (*HeadMinLenRule) Name

func (r *HeadMinLenRule) Name() string

func (*HeadMinLenRule) Validate

func (r *HeadMinLenRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type HeaderCaseRule

type HeaderCaseRule struct{ Case string }

HeaderCaseRule validates that the commit header matches a given case format. Argument: one of the casing.* constants.

func (*HeaderCaseRule) Apply

func (r *HeaderCaseRule) Apply(s lint.RuleSetting) error

func (*HeaderCaseRule) Name

func (r *HeaderCaseRule) Name() string

func (*HeaderCaseRule) Validate

func (r *HeaderCaseRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type HeaderFullStopRule

type HeaderFullStopRule struct{ Char string }

HeaderFullStopRule checks that the header does NOT end with a given character. Default character is ".".

func (*HeaderFullStopRule) Apply

func (*HeaderFullStopRule) Name

func (r *HeaderFullStopRule) Name() string

func (*HeaderFullStopRule) Validate

func (r *HeaderFullStopRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type HeaderTrimRule

type HeaderTrimRule struct{}

HeaderTrimRule checks that the header has no leading or trailing whitespace.

func (*HeaderTrimRule) Apply

func (r *HeaderTrimRule) Apply(_ lint.RuleSetting) error

func (*HeaderTrimRule) Name

func (r *HeaderTrimRule) Name() string

func (*HeaderTrimRule) Validate

func (r *HeaderTrimRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type ScopeCaseRule

type ScopeCaseRule struct{ Case string }

ScopeCaseRule validates that commit scope matches a given case format. An empty scope is always accepted (scope is optional by convention). Argument: one of the casing.* constants.

func (*ScopeCaseRule) Apply

func (r *ScopeCaseRule) Apply(s lint.RuleSetting) error

func (*ScopeCaseRule) Name

func (r *ScopeCaseRule) Name() string

func (*ScopeCaseRule) Validate

func (r *ScopeCaseRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type ScopeCharsetRule

type ScopeCharsetRule struct{ Charset string }

ScopeCharsetRule to validate charset of scope

func (*ScopeCharsetRule) Apply

func (r *ScopeCharsetRule) Apply(s lint.RuleSetting) error

func (*ScopeCharsetRule) Name

func (r *ScopeCharsetRule) Name() string

func (*ScopeCharsetRule) Validate

func (r *ScopeCharsetRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type ScopeEmptyRule

type ScopeEmptyRule struct{}

ScopeEmptyRule validates that the commit scope is not empty.

func (*ScopeEmptyRule) Apply

func (r *ScopeEmptyRule) Apply(_ lint.RuleSetting) error

func (*ScopeEmptyRule) Name

func (r *ScopeEmptyRule) Name() string

func (*ScopeEmptyRule) Validate

func (r *ScopeEmptyRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type ScopeEnumRule

type ScopeEnumRule struct {
	Scopes []string

	AllowEmpty bool
}

ScopeEnumRule to validate scope against a list of allowed values

func (*ScopeEnumRule) Apply

func (r *ScopeEnumRule) Apply(setting lint.RuleSetting) error

Apply sets the needed argument for the rule

func (*ScopeEnumRule) Name

func (r *ScopeEnumRule) Name() string

Name return name of the rule

func (*ScopeEnumRule) Validate

func (r *ScopeEnumRule) Validate(msg lint.Commit) (*lint.Issue, bool)

Validate validates ScopeEnumRule

type ScopeMaxLenRule

type ScopeMaxLenRule struct{ CheckLen int }

ScopeMaxLenRule to validate max length of scope

func (*ScopeMaxLenRule) Apply

func (r *ScopeMaxLenRule) Apply(s lint.RuleSetting) error

func (*ScopeMaxLenRule) Name

func (r *ScopeMaxLenRule) Name() string

func (*ScopeMaxLenRule) Validate

func (r *ScopeMaxLenRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type ScopeMinLenRule

type ScopeMinLenRule struct{ CheckLen int }

ScopeMinLenRule to validate min length of scope

func (*ScopeMinLenRule) Apply

func (r *ScopeMinLenRule) Apply(s lint.RuleSetting) error

func (*ScopeMinLenRule) Name

func (r *ScopeMinLenRule) Name() string

func (*ScopeMinLenRule) Validate

func (r *ScopeMinLenRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type SignedOffByRule

type SignedOffByRule struct{ Value string }

SignedOffByRule checks that at least one footer note token matches the configured value (default "Signed-off-by").

func (*SignedOffByRule) Apply

func (r *SignedOffByRule) Apply(s lint.RuleSetting) error

func (*SignedOffByRule) Name

func (r *SignedOffByRule) Name() string

func (*SignedOffByRule) Validate

func (r *SignedOffByRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type TrailerExistsRule

type TrailerExistsRule struct{ Value string }

TrailerExistsRule checks that at least one footer note has a token matching the configured value.

This is a generalized version of signed-off-by: any trailer token can be required.

func (*TrailerExistsRule) Apply

func (*TrailerExistsRule) Name

func (r *TrailerExistsRule) Name() string

func (*TrailerExistsRule) Validate

func (r *TrailerExistsRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type TypeCaseRule

type TypeCaseRule struct{ Case string }

TypeCaseRule validates that commit type matches a given case format. Argument: one of the casing.* constants (e.g. casing.Lower).

func (*TypeCaseRule) Apply

func (r *TypeCaseRule) Apply(s lint.RuleSetting) error

func (*TypeCaseRule) Name

func (r *TypeCaseRule) Name() string

func (*TypeCaseRule) Validate

func (r *TypeCaseRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type TypeCharsetRule

type TypeCharsetRule struct{ Charset string }

TypeCharsetRule to validate charset of type

func (*TypeCharsetRule) Apply

func (r *TypeCharsetRule) Apply(s lint.RuleSetting) error

func (*TypeCharsetRule) Name

func (r *TypeCharsetRule) Name() string

func (*TypeCharsetRule) Validate

func (r *TypeCharsetRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type TypeEmptyRule

type TypeEmptyRule struct{}

TypeEmptyRule validates that the commit type is not empty.

func (*TypeEmptyRule) Apply

func (r *TypeEmptyRule) Apply(_ lint.RuleSetting) error

func (*TypeEmptyRule) Name

func (r *TypeEmptyRule) Name() string

func (*TypeEmptyRule) Validate

func (r *TypeEmptyRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type TypeEnumRule

type TypeEnumRule struct {
	Types []string
}

TypeEnumRule to validate types

func (*TypeEnumRule) Apply

func (r *TypeEnumRule) Apply(setting lint.RuleSetting) error

Apply sets the needed argument for the rule

func (*TypeEnumRule) Name

func (r *TypeEnumRule) Name() string

Name return name of the rule

func (*TypeEnumRule) Validate

func (r *TypeEnumRule) Validate(msg lint.Commit) (*lint.Issue, bool)

Validate validates TypeEnumRule

type TypeMaxLenRule

type TypeMaxLenRule struct{ CheckLen int }

TypeMaxLenRule to validate max length of type

func (*TypeMaxLenRule) Apply

func (r *TypeMaxLenRule) Apply(s lint.RuleSetting) error

func (*TypeMaxLenRule) Name

func (r *TypeMaxLenRule) Name() string

func (*TypeMaxLenRule) Validate

func (r *TypeMaxLenRule) Validate(msg lint.Commit) (*lint.Issue, bool)

type TypeMinLenRule

type TypeMinLenRule struct{ CheckLen int }

TypeMinLenRule to validate min length of type

func (*TypeMinLenRule) Apply

func (r *TypeMinLenRule) Apply(s lint.RuleSetting) error

func (*TypeMinLenRule) Name

func (r *TypeMinLenRule) Name() string

func (*TypeMinLenRule) Validate

func (r *TypeMinLenRule) Validate(msg lint.Commit) (*lint.Issue, bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL