Repository: mgechev/revive
Pull request #450 (2020-08-03 23:06:28)

Update golang.org/x/tools commit hash to 75c7103
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [golang.org/x/tools](https://togithub.com/golang/tools) | require | digest | `b5fad4e` -> `75c7103` |

---

### Renovate configuration

:date: **Schedule**: At any time (no schedule defined).

:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

:recycle: **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#mgechev/revive).


Patch:
diff --git a/go.mod b/go.mod
index 01d23a1..31af3ab 100644
--- a/go.mod
+++ b/go.mod
@@ -10,5 +10,5 @@ require (
 	github.com/mitchellh/go-homedir v1.1.0
 	github.com/olekukonko/tablewriter v0.0.4
 	github.com/pkg/errors v0.9.1
-	golang.org/x/tools v0.0.0-20200731060945-b5fad4ed8dd6
+	golang.org/x/tools v0.0.0-20200805155214-75c71030ab24
 )
diff --git a/go.sum b/go.sum
index 1eee712..40a0f16 100644
--- a/go.sum
+++ b/go.sum
@@ -96,6 +96,8 @@ golang.org/x/tools v0.0.0-20200725200936-102e7d357031/go.mod h1:njjCfa9FT2d7l9Bc
 golang.org/x/tools v0.0.0-20200727233628-55644ead90ce h1:HEwYEPqqa3/M0N2Q6IgtBaf2CaxvmRiVdAhX6LR7uE4=
 golang.org/x/tools v0.0.0-20200727233628-55644ead90ce/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
 golang.org/x/tools v0.0.0-20200731060945-b5fad4ed8dd6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
+golang.org/x/tools v0.0.0-20200805155214-75c71030ab24 h1:KYaPFhtmIniMIwJjkFkLct9w+TL7RGb7O4BGAHEJVhA=
+golang.org/x/tools v0.0.0-20200805155214-75c71030ab24/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
diff --git a/rule/cognitive-complexity.go b/rule/cognitive-complexity.go
index 711aa22..9b98237 100644
--- a/rule/cognitive-complexity.go
+++ b/rule/cognitive-complexity.go
@@ -52,7 +52,7 @@ type cognitiveComplexityLinter struct {
 func (w cognitiveComplexityLinter) lint() {
 	f := w.file
 	for _, decl := range f.AST.Decls {
-		if fn, ok := decl.(*ast.FuncDecl); ok {
+		if fn, ok := decl.(*ast.FuncDecl); ok && fn.Body != nil {
 			v := cognitiveComplexityVisitor{}
 			c := v.subTreeComplexity(fn.Body)
 			if c > w.maxComplexity {


Test patch:
diff --git a/testdata/cognitive-complexity.go b/testdata/cognitive-complexity.go
index 0a0348a..c20794b 100644
--- a/testdata/cognitive-complexity.go
+++ b/testdata/cognitive-complexity.go
@@ -278,3 +278,6 @@ func (m *Migrator) MigrateIfNeeded(target *EtcdVersionPair) error { // MATCH /fu
 		}
 	}
 }
+
+// no regression test for issue #451
+func myFunc()