Skip to content

Update whitespace to v0.0.4 #786

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
Oct 4, 2019
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
3 changes: 2 additions & 1 deletion .golangci.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ linters-settings:
max-blank-identifiers: 2

whitespace:
multi-if: false
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
multi-func: false # Enforces newlines (or comments) after every multi-line function signature

linters:
enable:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,8 @@ linters-settings:
max-blank-identifiers: 2

whitespace:
multi-if: false
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
multi-func: false # Enforces newlines (or comments) after every multi-line function signature

linters:
enable:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require (
github.com/stretchr/testify v1.4.0
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e
github.com/ultraware/funlen v0.0.2
github.com/ultraware/whitespace v0.0.3
github.com/ultraware/whitespace v0.0.4
github.com/uudashr/gocognit v0.0.0-20190926065955-1655d0de0517
github.com/valyala/quicktemplate v1.2.0
golang.org/x/tools v0.0.0-20190912215617-3720d1ec3678
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGr
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/ultraware/funlen v0.0.2 h1:Av96YVBwwNSe4MLR7iI/BIa3VyI7/djnto/pK3Uxbdo=
github.com/ultraware/funlen v0.0.2/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA=
github.com/ultraware/whitespace v0.0.3 h1:S5BCRRB5sttNy0bSOhbpw+0mb+cHiCmWfrvxpEzuUk0=
github.com/ultraware/whitespace v0.0.3/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA=
github.com/ultraware/whitespace v0.0.4 h1:If7Va4cM03mpgrNH9k49/VOicWpGoG70XPBFFODYDsg=
github.com/ultraware/whitespace v0.0.4/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA=
github.com/uudashr/gocognit v0.0.0-20190926065955-1655d0de0517 h1:ChMKTho2hWKpks/nD/FL2KqM1wuVt62oJeiE8+eFpGs=
github.com/uudashr/gocognit v0.0.0-20190926065955-1655d0de0517/go.mod h1:j44Ayx2KW4+oB6SWMv8KsmHzZrOInQav7D3cQMJ5JUM=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ type LintersSettings struct {
Statements int
}
Whitespace struct {
MultiIf bool `mapstructure:"multi-if"`
MultiIf bool `mapstructure:"multi-if"`
MultiFunc bool `mapstructure:"multi-func"`
}

Lll LllSettings
Expand Down
3 changes: 2 additions & 1 deletion pkg/golinters/whitespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func NewWhitespace() *goanalysis.Linter {
[]*analysis.Analyzer{analyzer},
nil,
).WithContextSetter(func(lintCtx *linter.Context) {
settings := whitespace.Settings{MultiIf: lintCtx.Cfg.LintersSettings.Whitespace.MultiIf}
cfg := lintCtx.Cfg.LintersSettings.Whitespace
settings := whitespace.Settings{MultiIf: cfg.MultiIf, MultiFunc: cfg.MultiFunc}

analyzer.Run = func(pass *analysis.Pass) (interface{}, error) {
var issues []whitespace.Message
Expand Down
8 changes: 7 additions & 1 deletion test/testdata/fix/in/whitespace.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//args: -Ewhitespace
//config: linters-settings.whitespace.multi-if=true
//config: linters-settings.whitespace.multi-func=true
package p

import "fmt"
Expand Down Expand Up @@ -47,9 +48,14 @@ func twoLeadingNewlines() {
fmt.Println("Hello world")
}

func multiFuncFunc(a int,
b int) {
fmt.Println("Hello world")
}

func multiIfFunc() {
if 1 == 1 &&
2 == 2 {
fmt.Println(`Hello multi-line world`)
fmt.Println("Hello multi-line world")
}
}
9 changes: 8 additions & 1 deletion test/testdata/fix/out/whitespace.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//args: -Ewhitespace
//config: linters-settings.whitespace.multi-if=true
//config: linters-settings.whitespace.multi-func=true
package p

import "fmt"
Expand Down Expand Up @@ -43,10 +44,16 @@ func twoLeadingNewlines() {
fmt.Println("Hello world")
}

func multiFuncFunc(a int,
b int) {

fmt.Println("Hello world")
}

func multiIfFunc() {
if 1 == 1 &&
2 == 2 {

fmt.Println(`Hello multi-line world`)
fmt.Println("Hello multi-line world")
}
}
48 changes: 1 addition & 47 deletions vendor/github.com/ultraware/whitespace/README.md

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

45 changes: 26 additions & 19 deletions vendor/github.com/ultraware/whitespace/main.go

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

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ github.com/stretchr/testify/require
github.com/timakin/bodyclose/passes/bodyclose
# github.com/ultraware/funlen v0.0.2
github.com/ultraware/funlen
# github.com/ultraware/whitespace v0.0.3
# github.com/ultraware/whitespace v0.0.4
github.com/ultraware/whitespace
# github.com/uudashr/gocognit v0.0.0-20190926065955-1655d0de0517
github.com/uudashr/gocognit
Expand Down