Documentation ¶
Overview ¶
Package config is used for defining the configuration necessary to run the linters in an automated fashion.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // TierBronze is the tier name that corresponds to the TierBronzeConfiguration // configuration minimums. TierBronze = "bronze" // TierSilver is the tier name that corresponds to the TierSilverConfiguration // configuration minimums. TierSilver = "silver" // TierGold is the tier name that corresponds to the TierGoldConfiguration // configuration minimums. TierGold = "gold" // TierPlatinum is the tier name that corresponds to the TierPlatinumConfiguration // configuration minimums. TierPlatinum = "platinum" )
Configuration tier variables that correspond to ops-level tiers. The reason these are variables as opposed to constants is because the address of them are needed when defining their corresponding Tier*Configuration types.
var TierBronzeConfiguration = Lintroller{ Tier: &TierBronze, Header: Header{ Enabled: false, Fields: nil, }, Copyright: Copyright{ Enabled: false, }, Doculint: Doculint{ Enabled: false, MinFunLen: 0, ValidatePackages: false, ValidateFunctions: false, ValidateVariables: false, ValidateConstants: false, ValidateTypes: false, }, Todo: Todo{ Enabled: false, }, Why: Why{ Enabled: false, }, }
TierBronzeConfiguration is the Lintroller configuration minumums that correspond to the Bronze OpsLevel tier.
var TierGoldConfiguration = Lintroller{ Tier: &TierSilver, Header: Header{ Enabled: true, Fields: []string{"Description"}, }, Copyright: Copyright{ Enabled: true, Pattern: `^Copyright 20.*$`, }, Doculint: Doculint{ Enabled: true, MinFunLen: 0, ValidatePackages: true, ValidateFunctions: false, ValidateVariables: true, ValidateConstants: true, ValidateTypes: true, }, Todo: Todo{ Enabled: true, }, Why: Why{ Enabled: true, }, }
TierGoldConfiguration is the Lintroller configuration minumums that correspond to the Gold OpsLevel tier.
var TierPlatinumConfiguration = Lintroller{ Tier: &TierSilver, Header: Header{ Enabled: true, Fields: []string{"Description"}, }, Copyright: Copyright{ Enabled: true, Pattern: `^Copyright 20.*$`, }, Doculint: Doculint{ Enabled: true, MinFunLen: 10, ValidatePackages: true, ValidateFunctions: true, ValidateVariables: true, ValidateConstants: true, ValidateTypes: true, }, Todo: Todo{ Enabled: true, }, Why: Why{ Enabled: true, }, }
TierPlatinumConfiguration is the Lintroller configuration minumums that correspond to the Platinum OpsLevel tier.
var TierSilverConfiguration = Lintroller{ Tier: &TierSilver, Header: Header{ Enabled: true, Fields: []string{"Description"}, }, Copyright: Copyright{ Enabled: true, Pattern: `^Copyright 20.*$`, }, Doculint: Doculint{ Enabled: true, MinFunLen: 0, ValidatePackages: true, ValidateFunctions: false, ValidateVariables: false, ValidateConstants: false, ValidateTypes: false, }, Todo: Todo{ Enabled: true, }, Why: Why{ Enabled: true, }, }
TierSilverConfiguration is the Lintroller configuration minumums that correspond to the Silver OpsLevel tier.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Lintroller `yaml:"lintroller"`
}
Config is parent type we use to unmarshal YAML files into to gather config for the lintroller.
func (*Config) MarshalLog ¶
MarshalLog implements the log.Marshaler interface.
type Copyright ¶
type Copyright struct { // Enabled denotes whether or not this linter is enabled. Defaults to true. Enabled bool `yaml:"enabled"` // Text is the copyright literal string required at the top of each .go file. If this // and pattern are empty this linter is a no-op. Pattern will always take precedence // over text if both are provided. Defaults to an empty string. Text string `yaml:"text"` // Pattern is the copyright pattern as a regular expression required at the top of each // .go file. If this and pattern are empty this linter is a no-op. Pattern will always // take precedence over text if both are provided. Defaults to an empty string. Pattern string `yaml:"pattern"` }
Copyright is the configuration type that matches the flags exposed by the copyright linter.
func (*Copyright) MarshalLog ¶
MarshalLog implements the log.Marshaler interface.
type Doculint ¶
type Doculint struct { // Enabled denotes whether or not this linter is enabled. Defaults to true. Enabled bool `yaml:"enabled"` // MinFunLen is the minimum function length that doculint will report on if said // function has no related documentation. Defaults to 10. MinFunLen int `yaml:"minFunLen"` // ValidatePackages denotes whether or not package comments should be validated. // Defaults to true. ValidatePackages bool `yaml:"validatePackages"` // ValidateFunctions denotes whether or not function comments should be validated. // Defaults to true. ValidateFunctions bool `yaml:"validateFunctions"` // ValidateVariables denotes whether or not variable comments should be validated. // Defaults to true. ValidateVariables bool `yaml:"validateVariables"` // ValidateConstants denotes whether or not constant comments should be validated. // Defaults to true. ValidateConstants bool `yaml:"validateConstants"` // ValidateTypes denotes whether or not type comments should be validated. Defaults // to true. ValidateTypes bool `yaml:"validateTypes"` }
Doculint is the configuration type that matches the flags exposed by the doculint linter.
func (*Doculint) MarshalLog ¶
MarshalLog implements the log.Marshaler interface.
type Header ¶
type Header struct { // Enabled denotes whether or not this linter is enabled. Defaults to true. Enabled bool `yaml:"enabled"` // Fields is a list of fields required to be filled out in the header. Defaults // to []string{"Description"}. Fields []string `yaml:"fields"` }
Header is the configuration type that matches the flags exposed by the header linter.
func (*Header) MarshalLog ¶
MarshalLog implements the log.Marshaler interface.
type Lintroller ¶
type Lintroller struct { // Tier is the desired tier you desire your service to pass for in ops-level. Tier *string `yaml:"tier"` // Configuration for individual linters proceeding: Header Header `yaml:"header"` Copyright Copyright `yaml:"copyright"` Doculint Doculint `yaml:"doculint"` Todo Todo `yaml:"todo"` Why Why `yaml:"why"` }
Lintroller contains the actually configuration required by lintroller, used by Config. The reason these fields aren't directly in Config is because we want to the ability utilize the golangci.yml file for lintroller configuration as well, so lintroller configuration needs to be "namespaced" accordingly.
func (*Lintroller) EnsureMinimums ¶
func (l *Lintroller) EnsureMinimums(desired *Lintroller) error
EnsureMinimums takes a desired Lintroller variable and diffs it against the receiver. It will automatically override booleans set to false, needing to be set to true, as well as any zero-valued struct field.
This function will allow the receiver to be more restrictive (enable linters when the desired has them disabled, set the minimum function length to a lower value, add more required header fields, etc.), but not allow it to be less restrictive.
func (*Lintroller) MarshalLog ¶
func (lr *Lintroller) MarshalLog(addField func(key string, value interface{}))
MarshalLog implements the log.Marshaler interface.
func (*Lintroller) ValidateTier ¶
func (l *Lintroller) ValidateTier() error
ValidateTier ensures that if a tier was provided, the rest of the configuration meets minimum requirements. If a field was left unset, it will be automatically set to the minimum requirement.
type Todo ¶
type Todo struct { // Enabled denotes whether or not this linter is enabled. Defaults to true. Enabled bool `yaml:"enabled"` }
Todo is the configuration type that matches the flags exposed by the todo linter.
func (*Todo) MarshalLog ¶
MarshalLog implements the log.Marshaler interface.
type Why ¶
type Why struct { // Enabled denotes whether or not this linter is enabled. Defaults to true. Enabled bool `yaml:"enabled"` }
Why is the configuration type that matches the flags exposed by the why linter.
func (*Why) MarshalLog ¶
MarshalLog implements the log.Marshaler interface.