From 6f7721a04a1a4ce82dfb6f1fe356097efe3595a1 Mon Sep 17 00:00:00 2001 From: Denis Limarev Date: Wed, 31 Aug 2022 11:58:22 +0300 Subject: [PATCH] update flags documentation (#64) --- .gitignore | 1 + cmd/dcRules/main.go | 16 +++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index df8f926..2be4ee3 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ test-projects dist/ bin +.DS_Store diff --git a/cmd/dcRules/main.go b/cmd/dcRules/main.go index d24b4ce..96a9d47 100644 --- a/cmd/dcRules/main.go +++ b/cmd/dcRules/main.go @@ -16,8 +16,7 @@ import ( ) var ( - flagTag string - flagDebug string + flagDebug bool flagDisable string flagEnable string flagRules string @@ -50,9 +49,9 @@ var ( ) func init() { - Analyzer.Flags.StringVar(&flagDebug, "d", "", "enable verbose mode for specific rule") - Analyzer.Flags.StringVar(&flagDisable, "disabled", "", "comma-separated list of enabled groups or skip empty to enable everything") - Analyzer.Flags.StringVar(&flagEnable, "enabled", "", "comma-separated list of disabled groups or skip empty to enable everything") + Analyzer.Flags.BoolVar(&flagDebug, "debug", false, "enable verbose mode") + Analyzer.Flags.StringVar(&flagDisable, "disable", "", "comma-separated list of disabled groups or skip empty to enable everything: #perfomance,#experimental") + Analyzer.Flags.StringVar(&flagEnable, "enable", "", "comma-separated list of enabled groups or skip empty to enable everything: #diagnostic,#style") Analyzer.Flags.StringVar(&flagRules, "rules", "", "comma-separated list of rules files") } @@ -123,13 +122,13 @@ func newEngine() error { disabledTags["experimental"] = true } - if flagDebug != "" { + if flagDebug { debugPrint(fmt.Sprintf("enabled tags: %+v", enabledTags)) debugPrint(fmt.Sprintf("disabled tags: %+v", disabledTags)) } ctx := &ruleguard.LoadContext{ - DebugImports: flagDebug != "", + DebugImports: flagDebug, Fset: token.NewFileSet(), DebugPrint: debugPrint, GroupFilter: func(g *ruleguard.GoRuleGroup) bool { @@ -147,7 +146,7 @@ func newEngine() error { } } - if flagDebug != "" { + if flagDebug { if whyDisabled != "" { debugPrint(fmt.Sprintf("(-) %s is %s", g.Name, whyDisabled)) } else { @@ -197,7 +196,6 @@ func runAnalyzer(pass *analysis.Pass) (interface{}, error) { } ctx := &ruleguard.RunContext{ - Debug: flagDebug, DebugPrint: debugPrint, Pkg: pass.Pkg, Types: pass.TypesInfo,