Skip to content

docs: improve linters page #1842

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

Merged
merged 1 commit into from
Mar 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/golinters/errorlint.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func NewErrorLint(cfg *config.ErrorLintSettings) *goanalysis.Linter {
return goanalysis.NewLinter(
"errorlint",
"go-errorlint is a source code linter for Go software "+
"that can be used to find code that will cause problems"+
"that can be used to find code that will cause problems "+
"with the error wrapping scheme introduced in Go 1.13.",
[]*analysis.Analyzer{a},
cfgMap,
Expand Down
4 changes: 2 additions & 2 deletions pkg/lint/lintersdb/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithLoadForGoAnalysis().
WithURL("https://github.com/denis-tingajkin/go-header"),
linter.NewConfig(golinters.NewGci()).
WithPresets(linter.PresetFormatting).
WithLoadForGoAnalysis().
WithAutoFix().
WithURL("https://github.com/daixiang0/gci"),
Expand All @@ -254,8 +255,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithAutoFix().
WithURL("https://github.com/client9/misspell"),
linter.NewConfig(golinters.NewLLL()).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/walle/lll"),
WithPresets(linter.PresetStyle),
linter.NewConfig(golinters.NewUnparam()).
WithPresets(linter.PresetUnused).
WithLoadForGoAnalysis().
Expand Down
51 changes: 43 additions & 8 deletions scripts/expand_website_templates/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,21 +225,56 @@ func getLintersListMarkdown(enabled bool) string {
sort.Slice(neededLcs, func(i, j int) bool {
return neededLcs[i].Name() < neededLcs[j].Name()
})
var lines []string

lines := []string{
"|Name|Description|Presets|AutoFix|Deprecated|",
"|---|---|---|---|---|",
}

for _, lc := range neededLcs {
var link string
if lc.OriginalURL != "" {
link = fmt.Sprintf("[%s](%s)", lc.Name(), lc.OriginalURL)
} else {
link = lc.Name()
}
line := fmt.Sprintf("- %s - %s", link, lc.Linter.Desc())
line := fmt.Sprintf("|%s|%s|%s|%v|%s|",
getName(lc),
getDesc(lc),
strings.Join(lc.InPresets, ", "),
check(lc.CanAutoFix, "Auto fix supported"),
check(lc.DeprecatedMessage != "", "Deprecated"),
)
lines = append(lines, line)
}

return strings.Join(lines, "\n")
}

func getName(lc *linter.Config) string {
name := lc.Name()

if lc.OriginalURL != "" {
name = fmt.Sprintf("[%s](%s)", lc.Name(), lc.OriginalURL)
}

if lc.DeprecatedMessage != "" {
name += ` <span title="deprecated">⚠</span>`
}

return name
}

func getDesc(lc *linter.Config) string {
desc := lc.Linter.Desc()
if lc.DeprecatedMessage != "" {
desc = lc.DeprecatedMessage
}

return strings.ReplaceAll(desc, "\n", "<br/>")
}

func check(b bool, title string) string {
if b {
return `<span title="` + title + `">✔</span>`
}
return ""
}

func getThanksList() string {
var lines []string
addedAuthors := map[string]bool{}
Expand Down