Skip to content

Commit

Permalink
Android: Institute groovy style and lint guidance
Browse files Browse the repository at this point in the history
Add the groovy style guide and linter resources (for VS code) to
//third_party/android_deps/README.md since this is the only project we
have that contains groovy code.

Re-format and fix our existing code to be more idiomatic and to conform
to the groovy code linter with the settings listed in the README.md.
This allows us to automatically fix-up style issues locally as we work
on the code, and also makes it easier for new code to be more idomatic
when extending our existing code.

Bug: 1216032
Cq-Include-Trybots: luci.chromium.try:3pp-linux-amd64-packager
Change-Id: Ie9a848912d69233df462f749406765622ddeb3ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2940907
Reviewed-by: Mohamed Heikal <mheikal@chromium.org>
Commit-Queue: Peter Wen <wnwen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#889727}
  • Loading branch information
Peter Wen authored and Chromium LUCI CQ committed Jun 7, 2021
1 parent 7cf160a commit 3d4d87f
Show file tree
Hide file tree
Showing 4 changed files with 1,068 additions and 1,072 deletions.
42 changes: 41 additions & 1 deletion third_party/android_deps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,44 @@ features. An alternative way to implement it is to mix gradle to purely fetch
dependencies and their pom.xml files, and use Python to process and generate
the files. This approach was not as successful, as some information about the
dependencies does not seem to be available purely from the POM file, which
resulted in expecting dependencies that gradle considered unnecessary.
resulted in expecting dependencies that gradle considered unnecessary. This is
especially true nowadays that pom.xml files for many dependencies are no longer
maintained by the package authors.

#### Groovy Style Guide
The groovy code in `//third_party/android_deps/buildSrc/src/main/groovy` loosely
follows the [Groovy Style Guide][groovy_style_guide], and can be linted by each
dev with [npm-groovy-lint][npm_groovy_lint] via the
[VS Code extension][vs_code_groovy_lint]. The line length limit for groovy is
**120** characters.

Here is a sample `.groovylintrc.json` file:

```
{
"extends": "recommended",
"rules": {
"CatchException": "off",
"CompileStatic": "off",
"DuplicateMapLiteral": "off",
"DuplicateNumberLiteral": "off",
"DuplicateStringLiteral": "off",
"FactoryMethodName": "off",
"JUnitPublicProperty": "off",
"JavaIoPackageAccess": "off",
"MethodCount": "off",
"NestedForLoop": "off",
"ThrowRuntimeException": "off",
"formatting.Indentation": {
"spacesPerIndentLevel": 4
}
}
}
```

This is a list of rule names: [Groovy Rule Index by Name][groovy_rule_index].

[groovy_style_guide]: https://groovy-lang.org/style-guide.html
[npm_groovy_lint]: https://github.com/nvuillam/npm-groovy-lint
[vs_code_groovy_lint]: https://marketplace.visualstudio.com/items?itemName=NicolasVuillamy.vscode-groovy-lint
[groovy_rule_index]: https://codenarc.org/codenarc-rule-index-by-name.html
Loading

0 comments on commit 3d4d87f

Please sign in to comment.