You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

 

Summary

Since Sqoop2 is primarily JAVA, we will be using the google JAVA coding standards for the most parts. Some of the custom nuances that already exist in Sqoop are also highlighted with code examples,so new contributors spend your time wisely.! When in doubt, use the google guide as a reference and email the dev@sqoop.apache.org about a convention you deem is important for us to follow.

General Rules

  • No wildcard imports.
  • Overloads appear sequentially.
  • Braces are used even when the body is empty or contains a single statement.
  • 2 spaces indentation.
  • Column limit can be 80 or 100 characters.
  • No C-style array declarations.
  • The default statement in switch statements are required.
  • Modifiers appear in the order recommended by the Java Language Specification.
  • Constants use CONSTANT_CASE. Note that every constant is a static final field, but not all static final fields are constants

Must Follow Rules

License or copyright information

The Apache License info must be present for all files. So please use a simple script to check this license header exists before uploading the patch. ! 

Wild card imports

Unless the entire set of imports are used in the file. For example in DerbySchemaUpgradeQuery.java every single constant in DerbySchemaConstants is used. In this case, it is ok to use wildcard. 

Column Limit and Line Wrapping

https://google-styleguide.googlecode.com/svn/trunk/javaguide.html#s4.4-column-limit

We can use the 100 character limit.

 Having said that,  I have to steal this line from the Kafka Style guide.

 

There is not a maximum line length (certainly not 80 characters, we don't work on punch cards any more), but be reasonable

Import Order and Grouping 

https://google-styleguide.googlecode.com/svn/trunk/javaguide.html#s3.3.3-import-ordering-and-spacing

Import statements are not line-wrapped

  1. All static imports in a single group
  2. com.* imports (only if this source file is in the com.google package space)
  3. Third-party imports, one group per top-level package, in ASCII sort orderjava imports
    • for example: androidcomjunitorgsun
  4. java imports

  5. javax imports

Method Names in APIs

https://google-styleguide.googlecode.com/svn/trunk/javaguide.html#s5.2.3-method-names

Method names are typically verbs or verb phrases. For example, sendMessage or stopJob. We do not recommend messageSend or jobStop.!

Do not ignore caught Exceptions

https://google-styleguide.googlecode.com/svn/trunk/javaguide.html#s6.2-caught-exceptions

If in case, you have very legit reason to ignore it , have a comment, DO NOT leave it blank

try {
  ....
} catch (SqoopException ok) {
  // its ok for me ignore this, since it is harmless
}

 

 

Some conventions in Sqoop that you should follow!

  1. All test classes should be in the exact same package hierarchy as the source java class
  2. All test classes should begin with Test for instance TestCSVInternmediateFormat.java instead of CSVIntermediateFormatTest. 
  3. If you see code duplicated, please create a JIRA and let us all know, we can collectively do the cleanup.

  4. Do not try to catch exceptions that you do not know how to handle, let it bubble up. 

  5. Apache Kafka Coding Guide very beautifully documents some of the basic stuff of writing code. Kindly read it. 

        Few of our favorites are:

    •  Clear code is preferable to comments. When possible make your naming so good you don't need comments. When that isn't possible comments should be thought of as mandatory, write them to beread.
    •  Don't be sloppy. Don't check in commented out code: we use version control, it is still there in the history. Don't leave TODOs in the code or FIXMEs if you can help it. Don't leave println statements in the code. Hopefully this is all  obvious. 
    •  Don't duplicate code (duh). Not even in tests.

 

 

Some conventions in Sqoop that may be only applicable here !

Dont ask me which coding standard prescribes the following conventions, but it exists in Sqoop and the committers follow this religiously!. 

  • Enum classes, the semicolon needs to be in its own line. 
public enum AuditLoggerError implements ErrorCode {
  /** An unknown error has occurred. */
  AUDIT_0000("An unknown error has occurred"),
  /** The system was unable to find or load the audit logger provider. */
  AUDIT_0001("The system was unable to find or load audit logger class"),
  /** The audit logger output file is not given. */
  AUDIT_0002("The output file for FileAuditLogger is not given"),
  ;

 

  • Also the Error codes have a format! 

 

 

 

Before you get on to uploading the patch, also read this wiki that will help with getting through larger feature reviews quicker

Sqoop 2 Review Board Guidelines

  • No labels