mirror of
https://github.com/mgechev/revive.git
synced 2025-01-24 03:47:45 +02:00
Rename and docs
This commit is contained in:
parent
1899499017
commit
8c53dad5ec
33
README.md
33
README.md
@ -96,14 +96,31 @@ This will use `config.toml`, the `friendly` formatter, and will run linting over
|
||||
|
||||
## Available Rules
|
||||
|
||||
| Name | Configuration | Description |
|
||||
| ------------------- | :---------------------: | ---------------------------------------------------------------: |
|
||||
| `cyclomatic` | int (for instance, `9`) | Sets restriction ot maximum Cyclomatic complexity. |
|
||||
| `context-key-type` | Not configurable | Disallows the usage of basic types in `context.WithValue`. |
|
||||
| `dot-imports` | Not configurable | Forbids `.` imports. |
|
||||
| `blank-imports` | Not configurable | Disallows blank imports |
|
||||
| `context-arguments` | Not configurable | `context.Context` should be the first argument of a function. |
|
||||
| `argument-limit` | int (for instance, `4`) | Specifies the maximum number of arguments a function can receive |
|
||||
| Name | Configuration | Description | In `golint` |
|
||||
| --------------------- | :--------------: | :--------------------------------------------------------------: | :---------: |
|
||||
| `blank-imports` | Not configurable | Disallows blank imports | yes |
|
||||
| `context-arguments` | Not configurable | `context.Context` should be the first argument of a function. | yes |
|
||||
| `context-key-type` | Not configurable | Disallows the usage of basic types in `context.WithValue`. | yes |
|
||||
| `dot-imports` | Not configurable | Forbids `.` imports. | yes |
|
||||
| `error-return` | Not configurable | The error return parameter should be last. | yes |
|
||||
| `error-strings` | Not configurable | Conventions around error strings. | yes |
|
||||
| `errors` | Not configurable | Naming of error variables. | yes |
|
||||
| `exported` | Not configurable | Naming and commenting conventions on exported symbols. | yes |
|
||||
| `if-return` | Not configurable | Redundant if when returning an error. | yes |
|
||||
| `increment-decrement` | Not configurable | Use `i++` and `i--` instead of `i += 1` and `i -= 1`. | yes |
|
||||
| `names` | Not configurable | Naming rules. | yes |
|
||||
| `package-comments` | Not configurable | Package commenting conventions. | yes |
|
||||
| `range` | Not configurable | Prevents redundant variables when iterating over a collection. | yes |
|
||||
| `receiver-name` | Not configurable | Conventions around the naming of receivers. | yes |
|
||||
| `time-name` | Not configurable | Conventions around the naming of time variables. | yes |
|
||||
| `unexpected-return` | Not configurable | Warns when a public return is from unexported type. | yes |
|
||||
| `unexpected-return` | Not configurable | Conventions around variable declarations. | yes |
|
||||
| `indent-error-flow` | Not configurable | Prevents redundant else statements. | yes |
|
||||
| `errorf` | Not configurable | Should replace `error.New(fmt.Sprintf())` with `error.Errorf()` | yes |
|
||||
| `argument-limit` | int | Specifies the maximum number of arguments a function can receive | no |
|
||||
| `cyclomatic` | int | Sets restriction for maximum Cyclomatic complexity. | no |
|
||||
| `max-public-structs` | int | The maximum number of public structs in a file. | no |
|
||||
| `file-header` | string | Header which each file should have. | no |
|
||||
|
||||
## Available Formatters
|
||||
|
||||
|
@ -28,7 +28,7 @@ var defaultRules = []lint.Rule{
|
||||
&rule.BlankImportsRule{},
|
||||
&rule.ExportedRule{},
|
||||
&rule.NamesRule{},
|
||||
&rule.ElseRule{},
|
||||
&rule.IndentErrorFlowRule{},
|
||||
&rule.IfReturnRule{},
|
||||
&rule.RangeRule{},
|
||||
&rule.ErrorfRule{},
|
||||
|
@ -1,7 +1,6 @@
|
||||
package rule
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"regexp"
|
||||
|
||||
@ -76,9 +75,6 @@ func (w lintFileHeader) Visit(n ast.Node) ast.Visitor {
|
||||
comment += text
|
||||
}
|
||||
|
||||
fmt.Println("#############")
|
||||
fmt.Println(comment)
|
||||
fmt.Println("#############")
|
||||
if !w.regex.Match([]byte(comment)) {
|
||||
w.onFailure(failure)
|
||||
}
|
||||
|
@ -7,11 +7,11 @@ import (
|
||||
"github.com/mgechev/revive/lint"
|
||||
)
|
||||
|
||||
// ElseRule lints given else constructs.
|
||||
type ElseRule struct{}
|
||||
// IndentErrorFlowRule lints given else constructs.
|
||||
type IndentErrorFlowRule struct{}
|
||||
|
||||
// Apply applies the rule to given file.
|
||||
func (r *ElseRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure {
|
||||
func (r *IndentErrorFlowRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure {
|
||||
var failures []lint.Failure
|
||||
|
||||
onFailure := func(failure lint.Failure) {
|
||||
@ -24,8 +24,8 @@ func (r *ElseRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failu
|
||||
}
|
||||
|
||||
// Name returns the rule name.
|
||||
func (r *ElseRule) Name() string {
|
||||
return "else"
|
||||
func (r *IndentErrorFlowRule) Name() string {
|
||||
return "indent-error-flow"
|
||||
}
|
||||
|
||||
type lintElse struct {
|
@ -21,7 +21,7 @@ var rules = []lint.Rule{
|
||||
&rule.BlankImportsRule{},
|
||||
&rule.ExportedRule{},
|
||||
&rule.NamesRule{},
|
||||
&rule.ElseRule{},
|
||||
&rule.IndentErrorFlowRule{},
|
||||
&rule.IfReturnRule{},
|
||||
&rule.RangeRule{},
|
||||
&rule.ErrorfRule{},
|
||||
|
Loading…
x
Reference in New Issue
Block a user