diff --git a/README.md b/README.md index fc4d5b3a4..a460c0cd4 100644 --- a/README.md +++ b/README.md @@ -401,7 +401,7 @@ List of all available rules. The rules ported from `golint` are left unchanged a | [`error-strings`](./RULES_DESCRIPTIONS.md#error-strings) | n/a | Conventions around error strings. | yes | no | | [`error-naming`](./RULES_DESCRIPTIONS.md#error-naming) | n/a | Naming of error variables. | yes | no | | [`exported`](./RULES_DESCRIPTIONS.md#exported) | n/a | Naming and commenting conventions on exported symbols. | yes | no | -| [`if-return`](./RULES_DESCRIPTIONS.md#if-return) | n/a | Redundant if when returning an error. | yes | no | +| [`if-return`](./RULES_DESCRIPTIONS.md#if-return) | n/a | Redundant if when returning an error. | no | no | | [`increment-decrement`](./RULES_DESCRIPTIONS.md#increment-decrement) | n/a | Use `i++` and `i--` instead of `i += 1` and `i -= 1`. | yes | no | | [`var-naming`](./RULES_DESCRIPTIONS.md#var-naming) | whitelist & blacklist of initialisms | Naming rules. | yes | no | | [`package-comments`](./RULES_DESCRIPTIONS.md#package-comments) | n/a | Package commenting conventions. | yes | no | diff --git a/config/config.go b/config/config.go index 6b010038e..1ca54d623 100644 --- a/config/config.go +++ b/config/config.go @@ -20,7 +20,6 @@ var defaultRules = []lint.Rule{ &rule.ExportedRule{}, &rule.VarNamingRule{}, &rule.IndentErrorFlowRule{}, - &rule.IfReturnRule{}, &rule.RangeRule{}, &rule.ErrorfRule{}, &rule.ErrorNamingRule{}, @@ -80,6 +79,7 @@ var allRules = append([]lint.Rule{ &rule.UnexportedNamingRule{}, &rule.FunctionLength{}, &rule.NestedStructs{}, + &rule.IfReturnRule{}, }, defaultRules...) var allFormatters = []lint.Formatter{ diff --git a/test/golint_test.go b/test/golint_test.go index e888eeaca..487218420 100644 --- a/test/golint_test.go +++ b/test/golint_test.go @@ -21,7 +21,6 @@ var rules = []lint.Rule{ &rule.ExportedRule{}, &rule.VarNamingRule{}, &rule.IndentErrorFlowRule{}, - &rule.IfReturnRule{}, &rule.RangeRule{}, &rule.ErrorfRule{}, &rule.ErrorNamingRule{}, diff --git a/test/if-return_test.go b/test/if-return_test.go new file mode 100644 index 000000000..161c9f1ac --- /dev/null +++ b/test/if-return_test.go @@ -0,0 +1,12 @@ +package test + +import ( + "testing" + + "github.com/mgechev/revive/rule" +) + +// TestIfReturn rule. +func TestIfReturn(t *testing.T) { + testRule(t, "if-return", &rule.IfReturnRule{}) +} diff --git a/testdata/golint/if-return.go b/testdata/if-return.go similarity index 100% rename from testdata/golint/if-return.go rename to testdata/if-return.go