Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adds initial style guide. (#1208)
  • Loading branch information
coollog committed Nov 15, 2018
1 parent f88fd29 commit 5e70a9a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -35,7 +35,7 @@ To build, use the provided `build.sh` which builds and tests each of the compone
If you're a Googler or other corporate contributor,
use your corporate email address here, not your personal address.
2. Fork the repository into your own Github account.
3. We follow the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html)
3. We follow our own [Java style guide](STYLE_GUIDE.md) that extends the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html).
3. Please include unit tests (and integration tests if applicable) for all new code.
4. Make sure all existing tests pass (but see the note below about integration tests).
* In `jib-core`, run `./gradlew clean goJF build integrationTest`
Expand Down
48 changes: 48 additions & 0 deletions STYLE_GUIDE.md
@@ -0,0 +1,48 @@
# Style guide

This style guide defines specific coding standards and advice for this Java codebase. The rules here are extensions to the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html).

Please see the [contributing guide](CONTRIBUTING.md) for general guidance for contributing to this project.

### Automatic formatting

Automatic formatting should be performed with `./gradlew goJF` or `./mvnw fmt:format`. Formatting all projects can be done with `./build.sh format`.

### Class member order

*Extends [3.4.2](https://google.github.io/styleguide/javaguide.html#s3.4.2-ordering-class-contents)*

Class members should be in the following order, in decreasing priority:

1. Static before non-static
1. Nested classes/interfaces before fields before constructors before methods
1. Public before private
1. Final before non-final

### Public APIs

User-facing methods (such as those in Jib Core) should not have types in their signature that are not standard JDK classes. For example, a parameter should take type `List` rather than Guava's `ImmutableList`.

### Package hierarchy

Packages should depend on each other without cycles.

The following is a list of current `jib-core` packages (under `com.google.cloud.tools.jib`) and their immediate dependencies. These can be amended as code changes, but there should not be cyclical dependencies.

- `api`
- `async`
- `blob` - `filesystem`, `hash`, `image` (cycle - should fix)
- `builder` - `async`, `blob`, `builder`, `cache` `configuration`, `docker`, `event`, `filesystem`, `global`, `http`, `image`, `json`, `registry`
- `cache` - `blob`, `filesystem`, `hash`, `image`, `json`
- `configuration` - `cache`, `filesystem`, `event`, `image`, `registry`
- `docker` - `blob`, `cache`, `image`, `json`, `tar`
- `event`
- `filesystem`
- `frontend` - `configuration`, `event`, `filesystem`, `image`, `registry`
- `global`
- `hash` - `blob`, `image`
- `http` - `blob`
- `image` - `blob`, `configuration` (cycle - should fix - `ImageToJsonTranslator`), `filesystem`, `json`, `tar`
- `json` - `blob`
- `registry` - `blob`, `builder` (cycle - should fix - `RegistryClient`), `configuration` (cycle - should fix - `DockerConfigCredentialRetriever`), `event`, `global`, `http`, `image`, `json`
- `tar` - `blob`

0 comments on commit 5e70a9a

Please sign in to comment.