diff options
author | 2020-08-13 12:55:59 +0200 | |
---|---|---|
committer | 2020-08-13 15:58:09 +0200 | |
commit | 9e8451e5243e77fef5fddfdf4f000d82f66e395f (patch) | |
tree | a855d09c583178e0a256aae041c3fedb1f09ffb0 /rust/clippy.go | |
parent | 29737cfc944f73f5c1095126d1d2d701b1a7db09 (diff) |
rust: modify linting properties
Move the linting properties to an enum with 4 possible options:
"default", "android", "vendor" or "none". The previous logic for
default, based on the module's location, is kept. It is now possible to
force the upgrade to a certain lint level for some modules (e.g.
external/[...]/android). Update the unit tests and documentation.
Bug: 163400111
Test: m
Change-Id: I8e464b04401158ed2d3c518a9b72f145a9835c99
Diffstat (limited to 'rust/clippy.go')
-rw-r--r-- | rust/clippy.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/rust/clippy.go b/rust/clippy.go index e1f567d99..6f0ed7ff1 100644 --- a/rust/clippy.go +++ b/rust/clippy.go @@ -19,8 +19,14 @@ import ( ) type ClippyProperties struct { - // whether to run clippy. - Clippy *bool + // name of the lint set that should be used to validate this module. + // + // Possible values are "default" (for using a sensible set of lints + // depending on the module's location), "android" (for the strictest + // lint set that applies to all Android platform code), "vendor" (for a + // relaxed set) and "none" (to disable the execution of clippy). The + // default value is "default". See also the `lints` property. + Clippy_lints *string } type clippy struct { @@ -32,10 +38,10 @@ func (c *clippy) props() []interface{} { } func (c *clippy) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags, PathDeps) { - if c.Properties.Clippy != nil && !*c.Properties.Clippy { - return flags, deps + enabled, lints, err := config.ClippyLintsForDir(ctx.ModuleDir(), c.Properties.Clippy_lints) + if err != nil { + ctx.PropertyErrorf("clippy_lints", err.Error()) } - enabled, lints := config.ClippyLintsForDir(ctx.ModuleDir()) flags.Clippy = enabled flags.ClippyFlags = append(flags.ClippyFlags, lints) return flags, deps |