Denis Isaev 7705f82591 Update megacheck to the latest version
Also do following improvements:
  - show proper sublinter name for megacheck sublinters
  - refactor and make more simple and robust megacheck
  merging/optimizing
  - improve handling of unknown linter names in //nolint directives
  - minimize diff of our megacheck version from the upstream,
  https://github.com/golang/go/issues/29612 blocks usage of the upstream
  version
  - support the new `stylecheck` linter
  - improve tests coverage for megacheck and nolint related cases
  - update and use upstream versions of unparam and interfacer instead of forked
  ones
  - don't use golangci/tools repo anymore
  - fix newly found issues after updating linters

Also should be noted that megacheck works much faster and consumes less
memory in the newest release, therefore golangci-lint works noticeably
faster and consumes less memory for large repos.

Relates: #314
2019-01-08 21:16:15 +03:00

58 lines
1.2 KiB
Go

package commands
import (
"log"
"os"
"github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/golangci/golangci-lint/pkg/lint/linter"
)
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(_ *cobra.Command, args []string) {
if len(args) != 0 {
e.log.Fatalf("Usage: golangci-lint linters")
}
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)
}