Skip to content

started README #4

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
May 15, 2018
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 .golangci.example.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
run:
verbose: true
concurrency: 4
deadline: 1m
issues-exit-code: 1
Expand Down Expand Up @@ -44,6 +43,7 @@ linters:
presets:
- bugs
- unused
fast: false

issues:
exclude:
Expand Down
4 changes: 0 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
run:
verbose: true
deadline: 30s
tests: true

linters-settings:
errcheck:
check-type-assertions: true
check-blank: true
govet:
check-shadowing: true
golint:
Expand Down
28 changes: 26 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

264 changes: 263 additions & 1 deletion README.md

Large diffs are not rendered by default.

Binary file added docs/go.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/run_screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion pkg/commands/linters.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ func (e *Executor) initLinters() {

func printLinterConfigs(lcs []pkg.LinterConfig) {
for _, lc := range lcs {
fmt.Printf("%s: %s\n", color.YellowString(lc.Linter.Name()), lc.Linter.Desc())
fmt.Printf("%s: %s [fast: %t]\n", color.YellowString(lc.Linter.Name()),
lc.Linter.Desc(), !lc.DoesFullImport)
}
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func (e *Executor) initRun() {
runCmd.Flags().BoolVar(&lc.DisableAll, "disable-all", false, "Disable all linters")
runCmd.Flags().StringSliceVarP(&lc.Presets, "presets", "p", []string{},
fmt.Sprintf("Enable presets (%s) of linters. Run 'golangci-lint linters' to see them. This option implies option --disable-all", strings.Join(pkg.AllPresets(), "|")))
runCmd.Flags().BoolVar(&lc.Fast, "fast", false, "Run only fast linters from enabled linters set")

// Issues config
ic := &e.cfg.Issues
Expand All @@ -99,7 +100,7 @@ func (e *Executor) initRun() {
runCmd.Flags().IntVar(&ic.MaxIssuesPerLinter, "max-issues-per-linter", 50, "Maximum issues count per one linter. Set to 0 to disable")
runCmd.Flags().IntVar(&ic.MaxSameIssues, "max-same-issues", 3, "Maximum count of issues with the same text. Set to 0 to disable")

runCmd.Flags().BoolVarP(&ic.Diff, "new", "n", false, "Show only new issues: if there are unstaged changes or untracked files, only those changes are shown, else only changes in HEAD~ are shown")
runCmd.Flags().BoolVarP(&ic.Diff, "new", "n", false, "Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed")
runCmd.Flags().StringVar(&ic.DiffFromRevision, "new-from-rev", "", "Show only new issues created after git revision `REV`")
runCmd.Flags().StringVar(&ic.DiffPatchFilePath, "new-from-patch", "", "Show only new issues created in git patch with file path `PATH`")

Expand Down Expand Up @@ -348,6 +349,10 @@ func (e *Executor) validateConfig() error {
return errors.New("option run.cpuprofilepath in config isn't allowed")
}

if c.Run.IsVerbose {
return errors.New("can't set run.verbose option with config: only on command-line")
}

return nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type Linters struct {
Disable []string
EnableAll bool `mapstructure:"enable-all"`
DisableAll bool `mapstructure:"disable-all"`
Fast bool

Presets []string
}
Expand Down
12 changes: 10 additions & 2 deletions pkg/enabled_linters.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func validateAllDisableEnableOptions(cfg *config.Linters) error {
}

if cfg.DisableAll {
if len(cfg.Enable) == 0 {
if len(cfg.Enable) == 0 && len(cfg.Presets) == 0 {
return fmt.Errorf("all linters were disabled, but no one linter was enabled: must enable at least one")
}

Expand Down Expand Up @@ -284,7 +284,7 @@ func GetAllLintersForPreset(p string) []Linter {
return ret
}

func getEnabledLintersSet(cfg *config.Config) map[string]Linter {
func getEnabledLintersSet(cfg *config.Config) map[string]Linter { // nolint:gocyclo
lcfg := &cfg.Linters

resultLintersSet := map[string]Linter{}
Expand Down Expand Up @@ -313,6 +313,14 @@ func getEnabledLintersSet(cfg *config.Config) map[string]Linter {
delete(resultLintersSet, name)
}

if lcfg.Fast {
for name := range resultLintersSet {
if GetLinterConfig(name).DoesFullImport {
delete(resultLintersSet, name)
}
}
}

return resultLintersSet
}

Expand Down
Loading