Skip to content

Development coding standards

Tom Morris edited this page Nov 25, 2022 · 2 revisions

Development processes / standards

All code is peer reviewed before merging. All unit tests must pass before requesting a code review via a Pull Request. Draft Pull Requests can be used for Work in Progress.

Branches are named with the issue number that they address, followed by a dash, and a short descriptive name, e.g. 1234-fix-import-encoding [Some projects differentiate bug vs feature branches, but I think that's unnecessary - tfm]

Java coding standards

Clean diffs are important for reviewers, so keep functional changes and formatting changes separate. Do not make gratuitous formatting changes.

The CI pipeline will fail for PRs which don't match the prescribed code style, so make sure you run mvn formatter:format before submitting a PR. The project uses the Google Java style [or Oracle? Eclipse? SEI?] with the following exceptions:

  • Import order is static, java, javax, org, com, com.google, com.google.refine with each section separated by a single line
  • The standard module header is

Copyright ${year}, ${user} All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Logging

All debug output should be done using SLF4J, not print statements. For static loggers use (be sure to update class name when copying!):

static final private Logger logger = LoggerFactory.getLogger(MyClassName.class);

and for instance loggers use:

final protected Logger logger = LoggerFactory.getLogger(getClass());

If you see instances of Throwable.printStackTrace(), please convert them to use logging.

Javascript coding standards

[Anyone have candidates or a favorite?]

Clone this wiki locally