Dino Oliva | 1efde74 | 2016-07-08 10:25:14 -0700 | [diff] [blame] | 1 | # How to submit a bug report |
| 2 | |
| 3 | If you received an error message, please include it and any exceptions. |
| 4 | |
| 5 | We commonly need to know what platform you are on: |
Bogdan Drutu | df6294e | 2017-03-24 10:51:48 -0700 | [diff] [blame] | 6 | |
| 7 | * JDK/JRE version (i.e., `java -version`) |
| 8 | * Operating system (i.e., `uname -a`) |
Dino Oliva | 1efde74 | 2016-07-08 10:25:14 -0700 | [diff] [blame] | 9 | |
| 10 | # How to contribute |
| 11 | |
Yang Song | c63da24 | 2017-11-29 15:06:25 -0800 | [diff] [blame] | 12 | We definitely welcome patches and contributions to OpenCensus! Here are |
Bogdan Drutu | df6294e | 2017-03-24 10:51:48 -0700 | [diff] [blame] | 13 | some guidelines and information about how to do so. |
Dino Oliva | 1efde74 | 2016-07-08 10:25:14 -0700 | [diff] [blame] | 14 | |
| 15 | ## Before getting started |
| 16 | |
| 17 | In order to protect both you and ourselves, you will need to sign the |
| 18 | [Contributor License Agreement](https://cla.developers.google.com/clas). |
| 19 | |
Dino Oliva | 1efde74 | 2016-07-08 10:25:14 -0700 | [diff] [blame] | 20 | [Eclipse](https://google-styleguide.googlecode.com/svn/trunk/eclipse-java-google-style.xml) |
| 21 | and |
| 22 | [IntelliJ](https://google-styleguide.googlecode.com/svn/trunk/intellij-java-google-style.xml) |
| 23 | style configurations are commonly useful. For IntelliJ 14, copy the style to |
| 24 | `~/.IdeaIC14/config/codestyles/`, start IntelliJ, go to File > Settings > Code |
| 25 | Style, and set the Scheme to `GoogleStyle`. |
| 26 | |
Kristen Kozak | 08f0953 | 2017-03-28 15:21:02 -0700 | [diff] [blame] | 27 | ## Style |
Kristen Kozak | f815809 | 2017-03-28 14:06:39 -0700 | [diff] [blame] | 28 | We follow the [Google Java Style |
| 29 | Guide](https://google.github.io/styleguide/javaguide.html). Our |
| 30 | build automatically will provide warnings for simple style issues. |
| 31 | |
Yang Song | 9def757 | 2018-02-28 13:11:01 -0800 | [diff] [blame] | 32 | Run the following command to format all files. This formatter uses |
| 33 | [google-java-format](https://github.com/google/google-java-format): |
| 34 | |
| 35 | ### OS X or Linux |
| 36 | |
| 37 | `./gradlew goJF` |
| 38 | |
| 39 | ### Windows |
| 40 | |
| 41 | `gradlew.bat goJF` |
| 42 | |
Kristen Kozak | f815809 | 2017-03-28 14:06:39 -0700 | [diff] [blame] | 43 | We also follow these project-specific guidelines: |
| 44 | |
| 45 | ### Javadoc |
| 46 | |
| 47 | * All public classes and their public and protected methods MUST have javadoc. |
| 48 | It MUST be complete (all params documented etc.) Everything else |
| 49 | (package-protected classes, private) MAY have javadoc, at the code writer's |
| 50 | whim. It does not have to be complete, and reviewers are not allowed to |
| 51 | require or disallow it. |
Kristen Kozak | b6aad9a | 2018-02-07 20:15:04 -0800 | [diff] [blame] | 52 | * Each API element should have a `@since` tag specifying the minor version when |
| 53 | it was released (or the next minor version). |
Kristen Kozak | f815809 | 2017-03-28 14:06:39 -0700 | [diff] [blame] | 54 | * There MUST be NO javadoc errors. |
| 55 | * See |
| 56 | [section 7.3.1](https://google.github.io/styleguide/javaguide.html#s7.3.1-javadoc-exception-self-explanatory) |
| 57 | in the guide for exceptions to the Javadoc requirement. |
| 58 | * Reviewers may request documentation for any element that doesn't require |
| 59 | Javadoc, though the style of documentation is up to the author. |
| 60 | * Try to do the least amount of change when modifying existing documentation. |
| 61 | Don't change the style unless you have a good reason. |
| 62 | |
| 63 | ### AutoValue |
Kristen Kozak | 08f0953 | 2017-03-28 15:21:02 -0700 | [diff] [blame] | 64 | |
| 65 | * Use [AutoValue](https://github.com/google/auto/tree/master/value), when |
| 66 | possible, for any new value classes. Remember to add package-private |
| 67 | constructors to all AutoValue classes to prevent classes in other packages |
| 68 | from extending them. |
| 69 | |
Yang Song | c63da24 | 2017-11-29 15:06:25 -0800 | [diff] [blame] | 70 | ## Building opencensus-java |
Kristen Kozak | 9cdff72 | 2017-03-29 13:29:13 -0700 | [diff] [blame] | 71 | |
Kristen Kozak | 7860be9 | 2017-12-28 19:01:29 -0800 | [diff] [blame] | 72 | Continuous integration builds the project, runs the tests, and runs multiple |
| 73 | types of static analysis. |
| 74 | |
| 75 | Run the following commands to build, run tests and most static analysis, and |
| 76 | check formatting: |
| 77 | |
| 78 | ### OS X or Linux |
| 79 | |
| 80 | `./gradlew clean assemble check verGJF` |
| 81 | |
| 82 | ### Windows |
| 83 | |
| 84 | `gradlew.bat clean assemble check verGJF` |
| 85 | |
| 86 | Use these commands to run Checker Framework null analysis: |
| 87 | |
| 88 | ### OS X or Linux |
| 89 | |
| 90 | `./gradlew clean assemble -PcheckerFramework` |
| 91 | |
| 92 | ### Windows |
| 93 | |
| 94 | `gradlew.bat clean assemble -PcheckerFramework` |
| 95 | |
| 96 | ### Checker Framework null analysis |
| 97 | |
| 98 | OpenCensus uses the [Checker Framework](https://checkerframework.org/) to |
| 99 | prevent NullPointerExceptions. Since the project uses Java 6, and Java 6 doesn't |
| 100 | allow annotations on types, all Checker Framework type annotations must be |
| 101 | [put in comments](https://checkerframework.org/manual/#backward-compatibility). |
| 102 | Putting all Checker Framework annotations and imports in comments also avoids a |
| 103 | dependency on the Checker Framework library. |
| 104 | |
| 105 | OpenCensus uses `org.checkerframework.checker.nullness.qual.Nullable` for all |
| 106 | nullable annotations on types, since `javax.annotation.Nullable` cannot be |
| 107 | applied to types. However, it uses `javax.annotation.Nullable` in API method |
| 108 | signatures whenever possible, so that the annotations can be uncommented and |
| 109 | be included in .class files and Javadocs. |
Kristen Kozak | 9cdff72 | 2017-03-29 13:29:13 -0700 | [diff] [blame] | 110 | |
Kristen Kozak | 91820a0 | 2018-04-18 12:37:16 -0700 | [diff] [blame] | 111 | ### Checkstyle import control |
| 112 | |
| 113 | This project uses Checkstyle to specify the allowed dependencies between |
| 114 | packages, using its ImportControl feature |
| 115 | (http://checkstyle.sourceforge.net/config_imports.html#ImportControl). |
Kristen Kozak | cffa220 | 2018-04-18 14:33:35 -0700 | [diff] [blame] | 116 | `buildscripts/import-control.xml` specifies the allowed imports and contains |
| 117 | some guidelines on OpenCensus' inter-package dependencies. An error messsage |
| 118 | such as |
Kristen Kozak | 91820a0 | 2018-04-18 12:37:16 -0700 | [diff] [blame] | 119 | `Disallowed import - edu.umd.cs.findbugs.annotations.SuppressFBWarnings. [ImportControl]` |
| 120 | could mean that `import-control.xml` needs to be updated. |
| 121 | |
Bogdan Drutu | c0e0b22 | 2018-09-11 00:08:18 -0700 | [diff] [blame] | 122 | ## Benchmarks |
| 123 | |
| 124 | ### Invoke all benchmarks on a sub-project |
| 125 | |
| 126 | ```bash |
| 127 | $ ./gradlew clean :opencensus-impl-core:jmh |
| 128 | ``` |
| 129 | |
| 130 | ### Invoke on a single benchmark class |
| 131 | |
| 132 | ```bash |
| 133 | ./gradlew -PjmhIncludeSingleClass=BinaryFormatImplBenchmark clean :opencensus-impl-core:jmh |
| 134 | ``` |
| 135 | |
| 136 | ### Debug compilation errors |
| 137 | When you make incompatible changes in the Benchmarks classes you may get compilation errors which |
| 138 | are related to the old code not being compatible with the new code. Some of the reasons are: |
| 139 | * Any plugin cannot delete the generated code (jmh generates code) because if the user configured |
| 140 | the directory as the same as source code the plugin will delete users source code. |
| 141 | * After you run jmh, a gradle daemon will stay alive which may cache the generated code in memory |
| 142 | and use use that generated code even if the files were changed. This is an issue for classes |
| 143 | generated with auto-value. |
| 144 | |
| 145 | Run this commands to clean the Gradle's cache: |
| 146 | ```bash |
| 147 | ./gradlew --stop |
| 148 | rm -fr .gradle/ |
| 149 | rm -fr benchmarks/build |
| 150 | ``` |
| 151 | |
Dino Oliva | 1efde74 | 2016-07-08 10:25:14 -0700 | [diff] [blame] | 152 | ## Proposing changes |
| 153 | |
Kristen Kozak | d14f40b | 2018-04-18 21:26:43 -0700 | [diff] [blame] | 154 | Create a Pull Request with your changes. Please add any user-visible changes to |
| 155 | CHANGELOG.md. The continuous integration build will run the tests and static |
| 156 | analysis. It will also check that the pull request branch has no merge commits. |
| 157 | When the changes are accepted, they will be merged or cherry-picked by an |
| 158 | OpenCensus core developer. |