Documentation ¶
Overview ¶
Package rules contains implementations of rules that apply to Google APIs.
Rules are sorted into subpackages by the AIP (https://aip.dev/) that mandates the rule. Every rule represented in code here must be represented in English in a corresponding AIP. Conversely, anything mandated in an AIP should have a rule here if it is feasible to enforce in code (sometimes it is infeasible, however).
A rule is technically anything with a `GetName()`, `GetURI()“, and `Lint(*desc.FileDescriptorProto) []lint.Problem` method, but most rule authors will want to use the rule structs provided in the lint package (`&lint.MessageRule`, `&lint.FieldRule`, and so on). These run against each applicable descriptor in the file (`MessageRule` against every message, for example). They also have an `OnlyIf` property that can be used to run against a subset of descriptors.
A simple rule therefore looks like this:
var myRule = &lint.MessageRule{ Name: lint.NewRuleName(1234, "my-rule"), LintMessage: func(m *desc.MessageDescriptor) []lint.Problem { if isBad(m) { return []lint.Problem{{ Message: "This message is bad.", Descriptor: m, }} } return nil }, }
Once a rule is written, it needs to be registered. This involves adding the rule to the `AddRules` method for the appropriate AIP package. If this is the first rule for a new AIP, then the `rules.go` init() function must also be updated to run the `AddRules` function for the new package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
Package aip0122 contains rules defined in https://aip.dev/122.
|
Package aip0122 contains rules defined in https://aip.dev/122. |
Package aip0123 contains rules defined in https://aip.dev/123.
|
Package aip0123 contains rules defined in https://aip.dev/123. |
Package aip0124 contains rules defined in https://aip.dev/124.
|
Package aip0124 contains rules defined in https://aip.dev/124. |
Package aip0126 contains rules defined in https://aip.dev/126.
|
Package aip0126 contains rules defined in https://aip.dev/126. |
Package aip0127 contains rules defined in https://aip.dev/127.
|
Package aip0127 contains rules defined in https://aip.dev/127. |
Package aip0128 contains rules defined in https://aip.dev/128.
|
Package aip0128 contains rules defined in https://aip.dev/128. |
Package aip0131 contains rules defined in https://aip.dev/131.
|
Package aip0131 contains rules defined in https://aip.dev/131. |
Package aip0132 contains rules defined in https://aip.dev/132.
|
Package aip0132 contains rules defined in https://aip.dev/132. |
Package aip0133 contains rules defined in https://aip.dev/133.
|
Package aip0133 contains rules defined in https://aip.dev/133. |
Package aip0134 contains rules defined in https://aip.dev/134.
|
Package aip0134 contains rules defined in https://aip.dev/134. |
Package aip0135 contains rules defined in https://aip.dev/135.
|
Package aip0135 contains rules defined in https://aip.dev/135. |
Package aip0136 contains rules defined in https://aip.dev/136.
|
Package aip0136 contains rules defined in https://aip.dev/136. |
Package aip0140 contains rules defined in https://aip.dev/140.
|
Package aip0140 contains rules defined in https://aip.dev/140. |
Package aip0141 contains rules defined in https://aip.dev/141.
|
Package aip0141 contains rules defined in https://aip.dev/141. |
Package aip0142 contains rules defined in https://aip.dev/142.
|
Package aip0142 contains rules defined in https://aip.dev/142. |
Package aip0143 contains rules defined in https://aip.dev/143.
|
Package aip0143 contains rules defined in https://aip.dev/143. |
Package aip0144 contains rules defined in https://aip.dev/144.
|
Package aip0144 contains rules defined in https://aip.dev/144. |
Package aip0146 contains rules defined in https://aip.dev/146.
|
Package aip0146 contains rules defined in https://aip.dev/146. |
Package aip0148 contains rules defined in https://aip.dev/148.
|
Package aip0148 contains rules defined in https://aip.dev/148. |
Package aip0151 contains rules defined in https://aip.dev/151.
|
Package aip0151 contains rules defined in https://aip.dev/151. |
Package aip0154 contains rules defined in https://aip.dev/154.
|
Package aip0154 contains rules defined in https://aip.dev/154. |
Package aip0156 contains rules defined in https://aip.dev/156.
|
Package aip0156 contains rules defined in https://aip.dev/156. |
Package aip0158 contains rules defined in https://aip.dev/158.
|
Package aip0158 contains rules defined in https://aip.dev/158. |
Package aip0159 contains rules defined in https://aip.dev/159.
|
Package aip0159 contains rules defined in https://aip.dev/159. |
Package aip0163 contains rules defined in https://aip.dev/163.
|
Package aip0163 contains rules defined in https://aip.dev/163. |
Package aip0164 contains rules defined in https://aip.dev/164.
|
Package aip0164 contains rules defined in https://aip.dev/164. |
Package aip0191 contains rules defined in https://aip.dev/191.
|
Package aip0191 contains rules defined in https://aip.dev/191. |
Package aip0192 contains rules defined in https://aip.dev/192.
|
Package aip0192 contains rules defined in https://aip.dev/192. |
Package aip0203 contains rules defined in https://aip.dev/203.
|
Package aip0203 contains rules defined in https://aip.dev/203. |
Package aip0214 contains rules defined in https://aip.dev/214.
|
Package aip0214 contains rules defined in https://aip.dev/214. |
Package aip0215 contains rules defined in https://aip.dev/215.
|
Package aip0215 contains rules defined in https://aip.dev/215. |
Package aip0216 contains rules defined in https://aip.dev/216.
|
Package aip0216 contains rules defined in https://aip.dev/216. |
Package aip0217 contains rules defined in https://aip.dev/217.
|
Package aip0217 contains rules defined in https://aip.dev/217. |
Package aip0231 contains rules defined in https://aip.dev/231.
|
Package aip0231 contains rules defined in https://aip.dev/231. |
Package aip0233 contains rules defined in https://aip.dev/233.
|
Package aip0233 contains rules defined in https://aip.dev/233. |
Package aip0234 contains rules defined in https://aip.dev/234.
|
Package aip0234 contains rules defined in https://aip.dev/234. |
Package aip0235 contains rules defined in https://aip.dev/235.
|
Package aip0235 contains rules defined in https://aip.dev/235. |
internal
|
|
data
Package data contains constants used in multiple AIP rules.
|
Package data contains constants used in multiple AIP rules. |