Skip to content

Commit 63895f8

Browse files
authored
Merge pull request GoogleCloudPlatform#313 from GoogleCloudPlatform/tswast-style
Add style guidelines to CONTRIBUTING file.
2 parents 7cec9ea + ccbb014 commit 63895f8

File tree

1 file changed

+49
-9
lines changed

1 file changed

+49
-9
lines changed

CONTRIBUTING.md

+49-9
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,67 @@ Please fill out either the individual or corporate Contributor License Agreement
99
(CLA).
1010

1111
* If you are an individual writing original source code and you're sure you
12-
own the intellectual property, then you'll need to sign an [individual CLA]
13-
(https://developers.google.com/open-source/cla/individual).
12+
own the intellectual property, then you'll need to sign an [individual
13+
CLA](https://developers.google.com/open-source/cla/individual).
1414
* If you work for a company that wants to allow you to contribute your work,
15-
then you'll need to sign a [corporate CLA]
16-
(https://developers.google.com/open-source/cla/corporate).
15+
then you'll need to sign a [corporate
16+
CLA](https://developers.google.com/open-source/cla/corporate).
1717

1818
Follow either of the two links above to access the appropriate CLA and
1919
instructions for how to sign and return it. Once we receive it, we'll be able to
2020
accept your pull requests.
2121

22-
## Contributing A Patch
22+
## Contributing a Patch
2323

2424
1. Submit an issue describing your proposed change to the repo in question.
2525
1. The repo owner will respond to your issue promptly.
2626
1. If your proposed change is accepted, and you haven't already done so, sign a
2727
Contributor License Agreement (see details above).
2828
1. Fork the desired repo, develop and test your code changes.
2929
1. Ensure that your code adheres to the existing style in the sample to which
30-
you are contributing. Refer to the
31-
[Google Cloud Platform Samples Style Guide]
32-
(https://github.com/GoogleCloudPlatform/Template/wiki/style.html) for the
33-
recommended coding standards for this organization.
30+
you are contributing.
3431
1. Ensure that your code has an appropriate set of unit tests which all pass.
3532
1. Submit a pull request.
33+
34+
## Style
35+
36+
Samples in this repository follow the [Google Java Style Guide][java-style].
37+
This is enforced using the [Maven Checkstyle Plugin][checkstyle-plugin].
38+
39+
[java-style]: https://google.github.io/styleguide/javaguide.html
40+
[checkstyle-plugin]: https://maven.apache.org/plugins/maven-checkstyle-plugin/
41+
42+
Use the [google-java-format][google-java-format] tool to automatically reformat
43+
your source code to adhere to the style guide. It is available as a command-line
44+
tool or IntelliJ plugin.
45+
46+
[google-java-format]: https://github.com/google/google-java-format
47+
48+
### Running the Linter
49+
50+
To run the checkstyle plugin on an existing sample, run
51+
52+
```shell
53+
mvn clean verify -DskipTests
54+
```
55+
56+
The `-DskipTests` is optional. It is useful if you want to verify that your code
57+
builds and adheres to the style guide without waiting for tests to complete.
58+
59+
### Adding the Checkstyle Plugin to New Samples
60+
61+
The samples in this repository use a common parent POM to define plugins used
62+
for linting and testing. Add the following to your sample POM to ensure that it
63+
uses the common Checkstyle configuration.
64+
65+
```xml
66+
<parent>
67+
<groupId>com.google.cloud</groupId>
68+
<artifactId>doc-samples</artifactId>
69+
<version>1.0.0</version>
70+
<!-- Change relativePath to point to the root directory. -->
71+
<relativePath>../..</relativePath>
72+
</parent>
73+
```
74+
75+
This is just used for testing. The sample should build without a parent defined.

0 commit comments

Comments
 (0)