You are on page 1of 18

Sonar

Throwable.printStackTrace(
...) should never be called

Use play.Logger;

System.out and System.err


should not be used as loggers
Again, use Loggers

Constant names should


comply with a naming
convention

Use only uppercase words separated by


underscore _ and numbers (not at the
beginning)

if/else/for/while/do statements
should always use curly braces

if/else/for/while/do statements
should always use curly braces

For this case, use ternary operator

Strings literals should be placed on


the left side when checking for
equality

Use someText.equals(aVar) , because in


this way u dont need to validate null for
aVar

Class variable fields should


not have public accessibility
Use private modifier and
setter and getter
methods

Class variable fields should


not have public accessibility

Local variable and method


parameter names should comply
with a naming convention

Dont use underscore


on variable names

Field names should comply


with a naming convention

Dont use underscore _ on local


variable names

Unused local variables


should be removed

Just delete these!

Method parameters, caught exceptions


and foreach variables should not be
reassigned

Dont reassigned method parameters,


use:

Log[] otherVariable = contactsIds; and


use this, because the parameter could be
used after this method by his original
source

Right curly brace and next "else", "catch" and


"finally" keywords should be located on the
same line
AVOID

USE

Class names should comply


with a naming convention

http://howtodoinjava.com/2013/04/04/java-e
xception-handling-best-practices
/

You might also like