Denis Isaev 8a478c47ac Prepare for #164: rename GAS to gosec
1. Rename in a backward compatible way
2. Remove gosec default exclude list because gosec is already disabled
by default.
3. Warn about unmatched linter names in //nolint directives
4. Process linter names in //nolint directives in upper case
5. Disable gosec for golangci-lint in .golangci.yml
2018-09-02 09:34:35 +03:00

53 lines
1.1 KiB
Go

package commands
import (
"log"
"os"
"github.com/fatih/color"
"github.com/golangci/golangci-lint/pkg/lint/linter"
"github.com/spf13/cobra"
)
func (e *Executor) initLinters() {
lintersCmd := &cobra.Command{
Use: "linters",
Short: "List current linters configuration",
Run: e.executeLinters,
}
e.rootCmd.AddCommand(lintersCmd)
e.initRunConfiguration(lintersCmd)
}
func IsLinterInConfigsList(name string, linters []linter.Config) bool {
for _, lc := range linters {
if lc.Name() == name {
return true
}
}
return false
}
func (e *Executor) executeLinters(cmd *cobra.Command, args []string) {
enabledLCs, err := e.EnabledLintersSet.Get()
if err != nil {
log.Fatalf("Can't get enabled linters: %s", err)
}
color.Green("Enabled by your configuration linters:\n")
printLinterConfigs(enabledLCs)
var disabledLCs []linter.Config
for _, lc := range e.DBManager.GetAllSupportedLinterConfigs() {
if !IsLinterInConfigsList(lc.Name(), enabledLCs) {
disabledLCs = append(disabledLCs, lc)
}
}
color.Red("\nDisabled by your configuration linters:\n")
printLinterConfigs(disabledLCs)
os.Exit(0)
}