Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

Code style

lazarin edited this page Aug 26, 2016 · 3 revisions

Basics

License

Each source file must specify the license at the very top of the file:

/*
 * Copyright (c) 2016 VMware, Inc. All Rights Reserved.
 *
 * This product is licensed to you under the Apache License, Version 2.0 (the "License").
 * You may not use this product except in compliance with the License.
 *
 * This product may include a number of subcomponents with separate copyright notices
 * and license terms. Your use of these subcomponents is subject to the terms and
 * conditions of the subcomponent's license, as noted in the LICENSE file.
 */

License header file contrib/header.txt

Line length

Length is set to 100 characters.

Import statements

The order of import statements is:

  • import static java.*
  • import static javax.*
  • blank line
  • import static all other imports
  • blank line
  • import static com.vmware.*
  • blank line
  • import java.*
  • import javax.*
  • blank line
  • import all other imports
  • blank line
  • import com.vmware.*

Comments

Comments are always placed at independent line. Do not append the comment at the end of the line.

Wrong

host.setLoggingLevel(Level.OFF);  // setting log level OFF

Correct

// setting log level OFF
host.setLoggingLevel(Level.OFF);

Commit message

Follow the widely used format:

Checkstyle

Checkstyle runs as part of maven validate lifecycle.

You can call it manually like mvn validate or mvn checkstyle:checkstyle.

Checkstyle file: checkstyle.xml