Repository: mgechev/revive
Pull request #524 (2021-05-24 10:46:47)

Update module github.com/fatih/color to v1.12.0
[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/fatih/color](https://togithub.com/fatih/color) | require | minor | `v1.11.0` -> `v1.12.0` |

---

### Release Notes

<details>
<summary>fatih/color</summary>

### [`v1.12.0`](https://togithub.com/fatih/color/releases/v1.12.0)

[Compare Source](https://togithub.com/fatih/color/compare/v1.11.0...v1.12.0)

This release adds support for the `NO_COLOR`. For more information check out: https://no-color.org The pull request adding this change is: https://github.com/fatih/color/pull/137

</details>

---

### Configuration

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

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

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

🔕 **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#github/mgechev/revive).


Patch:
diff --git a/go.mod b/go.mod
index 5dac74b..e85e0b7 100644
--- a/go.mod
+++ b/go.mod
@@ -5,11 +5,11 @@ go 1.12
 require (
 	github.com/BurntSushi/toml v0.3.1
 	github.com/chavacava/garif v0.0.0-20210405164556-e8a0a408d6af
-	github.com/fatih/color v1.11.0
+	github.com/fatih/color v1.12.0
 	github.com/fatih/structtag v1.2.0
 	github.com/mgechev/dots v0.0.0-20190921121421-c36f7dcfbb81
 	github.com/mitchellh/go-homedir v1.1.0
 	github.com/olekukonko/tablewriter v0.0.5
 	github.com/pkg/errors v0.9.1
-	golang.org/x/tools v0.1.1
+	golang.org/x/tools v0.1.2
 )
diff --git a/go.sum b/go.sum
index 43968c5..8c53ba9 100644
--- a/go.sum
+++ b/go.sum
@@ -10,6 +10,8 @@ github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
 github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
 github.com/fatih/color v1.11.0 h1:l4iX0RqNnx/pU7rY2DB/I+znuYY0K3x6Ywac6EIr0PA=
 github.com/fatih/color v1.11.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
+github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc=
+github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
 github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
 github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
 github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
@@ -66,6 +68,8 @@ golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY=
 golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
 golang.org/x/tools v0.1.1 h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs=
 golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
+golang.org/x/tools v0.1.2 h1:kRBLX7v7Af8W7Gdbbc908OJcdgtK8bOz9Uaj8/F1ACA=
+golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
 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-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
diff --git a/rule/context-as-argument.go b/rule/context-as-argument.go
index 0ed28a8..6502a07 100644
--- a/rule/context-as-argument.go
+++ b/rule/context-as-argument.go
@@ -45,16 +45,19 @@ func (w lintContextArguments) Visit(n ast.Node) ast.Visitor {
 	}
 	// A context.Context should be the first parameter of a function.
 	// Flag any that show up after the first.
+	previousArgIsCtx := isPkgDot(fn.Type.Params.List[0].Type, "context", "Context")
 	for _, arg := range fn.Type.Params.List[1:] {
-		if isPkgDot(arg.Type, "context", "Context") {
+		argIsCtx := isPkgDot(arg.Type, "context", "Context")
+		if argIsCtx && !previousArgIsCtx {
 			w.onFailure(lint.Failure{
-				Node:       fn,
+				Node:       arg,
 				Category:   "arg-order",
 				Failure:    "context.Context should be the first parameter of a function",
 				Confidence: 0.9,
 			})
 			break // only flag one
 		}
+		previousArgIsCtx = argIsCtx
 	}
 	return w
 }


Test patch:
diff --git a/testdata/golint/context-as-argument.go b/testdata/golint/context-as-argument.go
index 5580e60..62e152c 100644
--- a/testdata/golint/context-as-argument.go
+++ b/testdata/golint/context-as-argument.go
@@ -22,3 +22,7 @@ func y(s string, ctx context.Context) { // MATCH /context.Context should be the
 // An invalid context.Context location with more than 2 args
 func y(s string, r int, ctx context.Context, x int) { // MATCH /context.Context should be the first parameter of a function/
 }
+
+func y(ctx1 context.Context, ctx2 context.Context, x int) {}
+
+func y(ctx1 context.Context, ctx2 context.Context, x int, ctx3 context.Context) {} // MATCH /context.Context should be the first parameter of a function/