Skip to content

Commit

Permalink
Update dependencies, improve leading whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
bombsimon committed Mar 16, 2024
1 parent e5501b7 commit e15c58a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ module github.com/bombsimon/wsl/v4

go 1.19

require golang.org/x/tools v0.6.0
require golang.org/x/tools v0.19.0

require (
golang.org/x/mod v0.8.0 // indirect
golang.org/x/sys v0.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/sys v0.18.0 // indirect
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw=
golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=
2 changes: 1 addition & 1 deletion testdata/src/default_config/leading_whitespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func fn2() { // want "unnecessary whitespace decreases readability"
}

func fn3() {
// Space after comment - v5.0.0 BREAKING CHANGE
// Space after comment // want "unnecessary whitespace decreases readability"

fmt.Println("Hello, World")
}
Expand Down
3 changes: 1 addition & 2 deletions testdata/src/default_config/leading_whitespace.go.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ func fn2() { // want "unnecessary whitespace decreases readability"
}

func fn3() {
// Space after comment - v5.0.0 BREAKING CHANGE

// Space after comment // want "unnecessary whitespace decreases readability"
fmt.Println("Hello, World")
}

Expand Down
18 changes: 16 additions & 2 deletions wsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,23 @@ func (w *WSL) CheckUnnecessaryBlockLeadingNewline(body *ast.BlockStmt) {
// If comment starts at the same line as the opening position it
// should just extend the position for the fixer if needed.
// func fn() { // This comment starts at the same line as LBrace
if commentStartLine == openingPosLine {
switch {
// The comment is on the same line as current opening position.
// E.g. func fn() { // A comment
case commentStartLine == openingPosLine:
openingPos = comment.End()
} else {
// Opening position is the same as `{` and the comment is
// directly on the line after (no empty line)
case openingPosLine == w.lineFor(body.Lbrace) &&
commentStartLine == w.lineFor(body.Lbrace)+1:
openingPos = comment.End()
// The opening position has been updated, it's another comment.
case openingPosLine != w.lineFor(body.Lbrace):
openingPos = comment.End()
// The opening position is still { and the comment is not
// directly above - it must be an empty line which shouldn't be
// there.
default:
firstStmt = comment.Pos()
}
}
Expand Down

0 comments on commit e15c58a

Please sign in to comment.