Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add versions, improve deprecation system, improve linters page #1854

Merged
merged 4 commits into from Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 25 additions & 8 deletions pkg/lint/linter/config.go
Expand Up @@ -20,6 +20,12 @@ const (
PresetUnused = "unused" // Related to the detection of unused code.
)

type Deprecation struct {
Since string
Message string
Replacement string
}

type Config struct {
Linter Linter
EnabledByDefault bool
Expand All @@ -29,11 +35,13 @@ type Config struct {
InPresets []string
AlternativeNames []string

OriginalURL string // URL of original (not forked) repo, needed for autogenerated README
CanAutoFix bool
IsSlow bool
DoesChangeTypes bool
DeprecatedMessage string
OriginalURL string // URL of original (not forked) repo, needed for autogenerated README
CanAutoFix bool
IsSlow bool
DoesChangeTypes bool

Since string
Deprecation *Deprecation
}

func (lc *Config) ConsiderSlow() *Config {
Expand Down Expand Up @@ -82,13 +90,22 @@ func (lc *Config) WithChangeTypes() *Config {
return lc
}

func (lc *Config) Deprecated(message string) *Config {
lc.DeprecatedMessage = message
func (lc *Config) WithSince(version string) *Config {
lc.Since = version
return lc
}

func (lc *Config) Deprecated(message, version, replacement string) *Config {
lc.Deprecation = &Deprecation{
Since: version,
Message: message,
Replacement: replacement,
}
return lc
}

func (lc *Config) IsDeprecated() bool {
return lc.DeprecatedMessage != ""
return lc.Deprecation != nil
}

func (lc *Config) AllNames() []string {
Expand Down