docs: add link to configuration in the linters list ()

This commit is contained in:
Ludovic Fernandez 2022-02-17 15:20:55 +01:00 committed by GitHub
parent 949b059028
commit d7e110ebbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,12 +13,14 @@ import (
"os"
"os/exec"
"path/filepath"
"reflect"
"sort"
"strings"
"gopkg.in/yaml.v3"
"github.com/golangci/golangci-lint/internal/renameio"
"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/lint/linter"
"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
)
@ -251,7 +253,11 @@ func getName(lc *linter.Config) string {
name := lc.Name()
if lc.OriginalURL != "" {
name = fmt.Sprintf("[%s](%s)", lc.Name(), lc.OriginalURL)
name = fmt.Sprintf("[%s](%s)", name, lc.OriginalURL)
}
if hasSettings(lc.Name()) {
name = fmt.Sprintf("%s [%s](#%s)", name, span("Configuration", "⚙️"), lc.Name())
}
if !lc.IsDeprecated() {
@ -285,6 +291,18 @@ func check(b bool, title string) string {
return ""
}
func hasSettings(name string) bool {
tp := reflect.TypeOf(config.LintersSettings{})
for i := 0; i < tp.NumField(); i++ {
if strings.EqualFold(name, tp.Field(i).Name) {
return true
}
}
return false
}
func span(title, icon string) string {
return fmt.Sprintf(`<span title=%q>%s</span>`, title, icon)
}