-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrevive.toml
159 lines (111 loc) · 6.34 KB
/
revive.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Base
ignoreGeneratedHeader = false
severity = "warning"
confidence = 0.8
errorCode = 0
warningCode = 0
# Suggests using constant for magic numbers and string literals.
# [rule.add-constant]
# arguments = [{ maxLitCount = "3", allowStrs="\"\"",allowInts="0,1,2,3,4,5,6,7,8,9,200,299",allowFloats="" }]
# Warns when a function receives more parameters than the maximum.
[rule.argument-limit]
arguments = [5]
# Check for commonly mistaken usages of the sync/atomic package.
[rule.atomic]
# Blank import should be only in a main or test package, or have a comment justifying it.
[rule.blank-imports]
# Using Boolean literals (true, false) in logic expressions may make the code less readable.
[rule.bool-literal-in-expr]
# Explicitly invoking the garbage collector is, except for specific uses in benchmarking, very dubious.
[rule.call-to-gc]
# Methods or fields of struct that have names different only by capitalization could be confusing.
[rule.confusing-naming]
# Function or methods that return multiple, no named, values of the same type could induce error.
[rule.confusing-results]
# Spots logical expressions that evaluate always to the same value.
[rule.constant-logical-expr]
# By convention, context.Context should be the first parameter of a function. This rule spots function declarations that do not follow the convention.
[rule.context-as-argument]
# Basic types should not be used as a key in context.WithValue.
[rule.context-keys-type]
# Cyclomatic complexity is a measure of code complexity. Enforcing a maximum complexity per function helps to keep code readable and maintainable.
# [rule.cyclomatic]
# arguments = [10]
# Packages exposing functions that can stop program execution by exiting are hard to reuse.
[rule.deep-exit]
# Importing with . makes the programs much harder to understand because it is unclear whether names belong to the current package or to an imported package.
[rule.dot-imports]
# Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring.
[rule.empty-block]
# Sometimes gofmt is not enough to enforce a common formatting of a code-base. This rule warns when there are heading or trailing newlines in code blocks.
[rule.empty-lines]
# By convention, for the sake of readability, variables of type error must be named with the prefix err.
[rule.error-naming]
# By convention, for the sake of readability, the errors should be last in the list of returned values by a function.
[rule.error-return]
# By convention, for better readability, error messages should not be capitalized or end with punctuation or a newline.
[rule.error-strings]
# It is possible to get a simpler program by replacing errors.New(fmt.Sprintf()) with fmt.Errorf().
[rule.errorf]
# Exported function and methods should have comments.
[rule.exported]
# This rule helps to enforce a common header for all source files in a project by spotting those files that do not have the specified header.
#[rule.file-header]
#arguments = [""]
# If a function controls the flow of another by passing it information on what to do, both functions are said to be control-coupled. Coupling among functions must be minimized for better maintainability of the code.
[rule.flag-parameter]
# Functions returning too many results can be hard to understand/use.
[rule.function-result-limit]
arguments = [2]
# Typically, functions with names prefixed with Get are supposed to return a value.
[rule.get-return]
# Checking if an error is nil to just after return the error or nil is redundant.
[rule.if-return]
# By convention, for better readability, incrementing an integer variable by 1 is recommended to be done using the ++ operator.
[rule.increment-decrement]
# To improve the readability of code, it is recommended to reduce the indentation as much as possible.
[rule.indent-error-flow]
# Warns when importing black-listed packages.
[rule.imports-blacklist]
arguments = []
# Warns in the presence of code lines longer than a configured maximum.
[rule.line-length-limit]
arguments = [120]
# Packages declaring too many public structs can be hard to understand/use, and could be a symptom of bad design.
[rule.max-public-structs]
arguments = [10]
# A function that modifies its parameters can be hard to understand.
[rule.modifies-parameter]
# A method that modifies its receiver value can have undesired behavior.
[rule.modifies-value-receiver]
# Packages should have comments.
[rule.package-comments]
# This rule suggests a shorter way of writing ranges that do not use the second value.
[rule.range]
# Range variables in a loop are reused at each iteration. Therefore a goroutine created in a loop will point to the range variable with from the upper scope.
[rule.range-val-in-closure]
# By convention, receiver names in a method should reflect their identity.
[rule.receiver-naming]
# Constant names like false, true, nil, function names like append, make, and basic type names like bool, and byte are not reserved words of the language, therefore they can be redefined.
[rule.redefines-builtin-id]
# Struct tags are not checked at compile time. This rule checks and warns if it finds errors in common struct tags types like: asn1, default, json, protobuf, xml, yaml.
[rule.struct-tag]
# To improve the readability of code, it is recommended to reduce the indentation as much as possible. This rule highlights redundant else-blocks that can be eliminated from the code.
[rule.superfluous-else]
# Using unit-specific suffix like "Secs", "Mins", ... when naming variables of type time.Duration can be misleading, this rule highlights those cases.
[rule.time-naming]
# This rule warns when variable or package naming conventions are not followed.
[rule.var-naming]
arguments = [["API", "ID", "HTTP", "URL"], []]
# This rule proposes simplifications of variable declarations.
[rule.var-declaration]
# This rule warns when an exported function or method returns a value of an un-exported type.
[rule.unexported-return]
# This rule suggests to remove redundant statements like a break at the end of a case block, for improving the code readability.
[rule.unnecessary-stmt]
# This rule spots and proposes to remove unreachable code.
[rule.unreachable-code]
# This rule warns on unused parameters.
#[rule.unused-parameter]
# Function parameters that are passed by value, are in fact a copy of the original argument. Passing a copy of a sync.WaitGroup is usually not what the developer wants to do.
[rule.waitgroup-by-value]