代码格式规范的 check style 以及 find bugs的一些规则

问题中文类型
JavadocType检查类和接口的javadoc(默认不检查author以及version)check style
JavadocMethod检查方法的javadoc的注释check style
JavadocVariable检查变量是否具有javadoc注释check style
LineLength检查编译工具中每行源代码的长度(目前设置为180个字符)check style
MethodLength检查方法和构造器的长度(目前默认设置100行)check style
OperatorWarp检查代码自动换行时运算符所处的位置(目前设置为同一行)check  style
EmptyForInitializerPad检查空的for循环初始化语句是否使用空格check style
EmptyForIteratorPad检查for iterator语句是否使用空格check style
AvoidStarImport检查import语句使用*符号(目前排除io,util)check style
IllegalImport检查是否导入了指定的非法包check style
EmptyBlock检查是否有空的代码块check style
NeedBraces检查代码块是否确实{}find bugs
LeftCurly检查左大括号的位置check style
RightCurly检查右大括号的位置check style
ModifierOrder检查代码中标识符的顺序是否符合规范check style
AvoidNestedBlocks找到嵌套代码块,也就是在代码中无节制使用的代码块check style
PackageName检查包的名称是否符合命名规范check style 
TypeName检查类的名称是否符合命名规范check style
MemberName检查成员变量(非静态字段)的名称是否遵守命名规约check style
ParameterName检查参数名称是否遵守命名规约check style
StaticVariableName检查静态变量(用static修饰,但没用final修饰的字段)的名称是否遵守命名规约check style
LambdaParameterName检查lambda表达式是否符合命名规范check style
ClassTypeParameterName检查类的命名是否符合规范check style
InterfaceTypeParameterName检查接口的命名是否符合命名规范check style
Indentation检查代码首行缩进是否符合规范check style
OverloadMethodsDeclarationOrder检查重载方法的先后顺序check style
RedundantImport检查是否存在多余的导入语句check style
UnusedImports检查未使用的导入语句check style
MethodParamPad检查方法名之后是否跟着左圆括号“(”check style
TypecastParenPad在类型转换时,不允许左圆括号右边有空格,也不允许与右圆括号左边有空格check style
NoWhitespaceBefore检查在某个特定关键字之前应保留空格check style
AnnotationLocation检查注解的位置是否合规check style
AllowMissingPropertyJavadoc允许get set 方法没有注释(默认为true)check style
CovariantEquals检查定义了共变equals()方法的类中是否同样覆盖了equals(java.lang.Object)方法find bugs
DefaultComesLast检查switch语句中的default是否在所有的case分支之后check style
EmptyStatement检查空的代码段check style
EqualsHashCode检查覆盖了equals()方法的类是否也覆盖了hashcode()find bugs
ExplicitInitialization检查类或对象的成员是否显式地初始化为成员变量所属的类型的默认值check style
FallThrough检查switch语句中是否存在跨越分支find bugs
FinalLocalVariable检查变量值没有改动的情况下,该变量是否定义成了finalcheck style
IllegalCatch非法异常捕捉,不允许捕捉java.lang.Exception、java.lang.Error、java.lang.RuntimeException的行为find bugs
MagicNumber检查是否有魔术数字(目前忽略的是 0和1 其他的最好用定义的变量来代替)check style
StringLiteralEqualityString的比较不能用!= 和 ==find bugs
MissingSwitchDefault检查switch语句中是否含有default子句check style
NestedForDepth限制for循环嵌套层数(目前是2层)check style
NestedIfDepth限制if-else代码块中嵌套的层数(目前是3层)check style
NestedTryDepth限制try代码块的嵌套层数(默认值为1)check style
UpperEll检查long类型的常量在定义时是否由大写的“L”开头check style
SuperCloneclone方法必须调用了super.clone()check style
SuperFinalizefinalize 必须调用了super.finalize()check style
ImportOrder检查导入包的顺序/分组check style
AnonInnerLength检查匿名内部类的长度(目前设置最大20行)check style
ExecutableStatementCount检查要执行的语句的数目,将可执行语句的数量限制为一个指定的限值check style
FileLength检查源码文件的长度(目前定义不超过1800行)check style
AvoidInlineConditionals检查是否在同一行初始化, 例如:private int Age = nGe==1 ? 100 : 0;就应该避免check style
InnerAssignment检查子表达式中是否有赋值操作check style
SimplifyBooleanExpression检查是否有过于复杂的布尔表达式。现在能够发现诸如if (b == true)、b || true、!false等类型的代码check style
StrictDuplicateCode逐行地比较所有的代码行,如果有若干行只有缩进有所不同,那么就报告存在重复代码(目前允许重复最小行为7)check style
BooleanExpressionComplexity限制一个表达式中的&&、||、&、|、^等逻辑运算符的数量(目前允许在一条语句中最大数目为7)check style
Hardcoded constant database password代码中创建DB的密码时采用了写死的密码find bugs
Empty database password创建数据库连接时没有为数据库设置密码,这会使数据库没有必要的保护find bugs
Nonconstant string passed to execute method on an SQL statement该方法以字符串的形式来调用SQLstatement的execute方法,它似乎是动态生成SQL语句的方法。这会更容易受到SQL注入攻击find bugs
JSP reflected cross site scripting vulnerability在代码中在JSP输出中直接写入一个HTTP参数,这会造成一个跨站点的脚本漏洞。find bugs
Creates an empty jar file entry调用putNextEntry()方法写入新的 jar 文件条目时立即调用closeEntry()方法。这样会造成JarFile条目为空。find bugs
Creates an empty zip file entry调用putNextEntry()方法写入新的 zip 文件条目时立即调用closeEntry()方法。这样会造成ZipFile条目为空。find bugs
Equals method should not assume anything about the type of its argumentequals(Object o)方法不能对参数o的类型做任何的假设。比较此对象与指定的对象。当且仅当该参数不为 null,并且是表示与此对象相同的类型的对象时,结果才为 true。find bugs
Random object created and used only once随机创建对象只使用过一次就抛弃find bugs
Check for sign of bitwise operation检查位操作符运行是否合理find bugs
Class defines clone() but doesn't implement Cloneable类中定义了clone方法但是它没有实现Cloneable接口find bugs
Abstract class defines covariant compareTo() method抽象类中定义了多个compareTo()方法,正确的是覆写Comparable中的compareTo方法,方法的参数为Objectfind bugs
Covariant compareTo() method defined类中定义了多个compareTo()方法,正确的是覆写Comparable中的compareTo方法,方法的参数为Object类型find bugs
Method might drop exception方法可能抛出异常find bugs
Method might ignore exception方法可能忽略异常find bugs
Don't use removeAll to clear a collection不要用removeAll方法去clear一个集合find bugs
Classloaders should only be created inside doPrivileged block类加载器只能建立在特殊的方法体内find bugs
Method invokes System.exit(...)在方法中调用System.exit(...)语句,考虑用RuntimeException来代替find bugs
Method invokes dangerous method runFinalizersOnExit在方法中调用了System.runFinalizersOnExit 或者Runtime.runFinalizersOnExit方法,因为这样做是很危险的。find bugs
Comparison of String parameter using == or !=用==或者!=方法去比较String类型的参数find bugs
Comparison of String objects using == or !=用==或者!=去比较String类型的对象find bugs
Equals checks for noncompatible operand equals方法检查不一致的操作。两个类根本就是父子关系而去调用equals方法去判读对象是否相等。find bugs
Class defines compareTo(...) and uses Object.equals() 类中定义了compareTo方法但是继承了Object中的compareTo方法find bugs
equals method fails for subtypes类中的equals方法可能被子类中的方法所破坏,当使用类似于Foo.class == o.getClass()的判断时考虑用find bugs
Covariant equals() method defined类中定义了多个equals方法。正确的做法是覆写Object中的equals方法,它的参数为Object类型的对象。find bugs
Empty finalizer should be deleted为空的finalizer方法应该删除。一下关于finalizer的内容省略find bugs
Class defines equals() but not hashCode()方法定义了equals方法却没有定义hashCode方法find bugs
Class defines hashCode() but not equals()类定义了hashCode方法去没有定义equal方法find bugs
Class inherits equals() and uses Object.hashCode() 子类继承了父类的equals方法却使用了Object的hashCode方法find bugs
Dubious catching of IllegalMonitorStateException捕捉违法的监控状态异常,例如当没有获取到对象锁时使用其wait和notify方法find bugs
Needless instantiation of class that only supplies static methods为使用静态方法而创建一个实例对象。调用静态方法时只需要使用类名+静态方法名就可以了。find bugs
Iterator next() method can't throw NoSuchElementException迭代器的next方法不能够抛出NoSuchElementExceptionfind bugs
Store of non serializable object into HttpSession在HttpSession对象中保存非连续的对象find bugs
Method with Boolean return type returns explicit null返回值为boolean类型的方法直接返回null,这样会导致空指针异常find bugs
equals() method does not check for null argument变量调用equals方法时没有进行是否为null的判断find bugs
toString method may return nulltoString方法可能返回nullfind bugs
Class names should start with an upper case letter类的名称以大写字母名称开头check style
Class is not derived from an Exception, even though it is named as such类的名称中含有Exception但是却不是一个异常类的子类,这种名称会造成混淆check style
Confusing method names令人迷惑的方法命名check style
Field names should start with a lower case letter非final类型的字段需要遵循驼峰命名原则find bugs
Use of identifier that is a keyword in later versions of Java 验证是否是java预留关键字find bugs
Use of identifier that is a keyword in later versions of Java 验证是否时java中的关键字find bugs
Method names should start with a lower case letter方法名称应该以小写字母开头check style
Class names shouldn't shadow simple name of implemented interface实现同一接口实现类不能使用相同的名称,即使它们位于不同的包中find bugs
Class names shouldn't shadow simple name of superclass继承同一父类的子类不能使用相同的名称,即使它们位于不同的包中find bugs
Very confusing method names (but perhaps intentional)很容易混淆的方法命名,例如方法的名称名称使用使用大小写来区别两个不同的方法。find bugs
Method doesn't override method in superclass due to wrong package for parameter由于错误引用了不同包中相同类名的对象而不能够正确的覆写父类中的方法find bugs
Method may fail to close database resource方法中可能存在关闭数据连接失败的情况find bugs
Method may fail to close stream方法中可能存在关闭流失败的情况find bugs
 Method ignores results of InputStream.read()InputStream.read方法忽略返回的多个字符,如果对结果没有检查就没法正确处理用户读取少量字符请求的情况。find bugs
Method ignores exceptional return value 方法忽略返回值的异常信息find bugs
Static initializer creates instance before all static final fields assigned在所有的static final字段赋值之前去使用静态初始化的方法创建一个类的实例。find bugs
Non-serializable value stored into instance field of a serializable class 非序列化的值保存在声明为序列化的的非序列化字段中find bugs
Comparator doesn't implement SerializableComparator接口没有实现Serializable接口find bugs
Serializable inner class序列化内部类find bugs
Class is Serializable but its superclass doesn't define a void constructor子类序列化时父类没有提供一个void的构造函数find bugs
Usage of GetResource may be unsafe if class is extended当一个类被子类继承后不要使用this.getClass().getResource(...)来获取资源find bugs
Impossible cast不可能的类转换,执行时会抛出ClassCastExceptionfind bugs
Impossible downcast父类在向下进行类型转换时抛出ClassCastExceptionfind bugs
instanceof will always return false采用instaneof方法进行比较时总是返回false。前提是保证它不是由于某些逻辑错误造成的。find bugs
Incompatible bit masks错误的使用&位操作符,例如(e & C)find bugs
Incompatible bit masks错误的使用|位操作符,例如(e | C)find bugs
Primitive value is unboxed and coerced for ternary operator 在三元运算符操作时如果没有对值进行封装或者类型转换。例如:b ? e1 : e2find bugs
Collections should not contain themselves集合没有包含他们自己本身。find bugs
Call to equals() with null argument调用equals的对象为nullfind bugs
equals method always returns false使用equals方法返回值总是falsefind bugs
equals method always returns trueequals方法返回值总是truefind bugs
equals method compares class names rather than class objects使用equals方法去比较一个类的实例和类的类型find bugs
Format string placeholder incompatible with passed argument错误使用参数类型来格式化字符串find bugs
The type of a supplied argument doesn't match format specifier指定的格式字符串和参数类型不匹配,例如:String.format("%d", "1")find bugs
Illegal format string格式化String对象语句错误find bugs
integral value cast to double and then passed to Math.ceilintegral的值转换为double后使用了Math.ceil方法find bugs
int value cast to float and then passed to Math.roundint 类型的值转换为float类型之后调用了Math.round方法find bugs
JUnit assertion in run method will not be noticed by Junit在JUnit中的断言在run方法中不会被告知find bugs
A collection is added to itself集合本身作为add方法的参数,这样会引起内容溢出。find bugs
An apparent infinite loop方法的自调用引起的死循环find bugs
Integer multiply of result of integer remainder和整数余数进行乘法运算。例如:i % 60 * 1000 是进行(i % 60) * 1000运算而不是 i % (60 * 1000)find bugs
Bad comparison of nonnegative value with negative constant保证非负数和负数进行比较find bugs
Class defines field that masks a superclass field子类中定义了和父类中同名的字段。在调用时会出错find bugs
Method defines a variable that obscures a field在方法中定义的局部变量和类变量或者父类变量同名,从而引起字段混淆。find bugs
Null pointer dereference对象赋为null值后 没有被重新赋值find bugs
Null pointer dereference in method on exception path空指针引用上调用去除引用方法,将发生空指针异常find bugs
Method does not check for null argument 方法没有判断参数是否为空find bugs
Method call passes null to a nonnull parameter方法中为null的参数没有被重新赋值find bugs
A known null value is checked to see if it is an instance of a type检查一个为null的值是否是想要的类型对象,而不是由于粗心或者逻辑错误引起的find bugs
Possible null pointer dereference对象可能没有重新赋值find bugs
Method call passes null for nonnull parameter方法参数中声明为nonnull类型的参数为nullfind bugs
Store of null value into field annotated NonNull为一个已经声明为不能为null值的属性赋值为nullfind bugs
Apparent method/constructor confusion构造方法定义混乱,保证一个标准的构造函数find bugs
Very confusing method names混乱的方法命名,如getName和getname方法同时出现的时候find bugs
Method doesn't override method in superclass due to wrong package for parameter方法因为取了不同包中的同名的对象而没有正确覆写父类中的同名方法find bugs
Method assigns boolean literal in boolean expression在if或者while表达式中使用boolean类型的值时应该使用==去判断,而不是采用=操作find bugs
Suspicious reference comparison比较两个对象值是否相等时应该采用equals方法,而不是==方法find bugs
Invalid syntax for regular expression 对正则表达式使用了错误的语法,会抛出未经检查的异常,表明正则表达式模式中的语法错误。find bugs
Random value from 0 to 1 is coerced to the integer 0从0到1随机值被强制为整数值0。在强制得到一个整数之前,你可能想得到多个随机值。或使用Random.nextInt(n)的方法。find bugs
Method ignores return value该方法的返回值应该进行检查。这种警告通常出现在调用一个不可变对象的方法,认为它更新了对象的值。find bugs
Double assignment of field方法中的字段包含了双重任务find bugs
Dead store due to switch statement fall through to throw 在swtich中因为出现异常而忽略了对case值的保存。find bugs
Field only ever set to null字段的值总是为null值,所有读取该字段的值都为null。检查错误,如果它确实没有用就删除掉。find bugs
Empty synchronized block该代码包含一个空的同步块:synchronized() {}find bugs
Non serializable object written to ObjectOutput代码中让一个非序列化的对象出现在ObjectOutput.writeObject()方法中,这样会引起一个错误。find bugs
Useless control flow to next line无效的条件控制语句,注意if (argv.length == 1);以“;”结尾,下面的语句无论是否满足都会运行find bugs
Method directly allocates a specific implementation of xml interfaces方法自定义了一种XML接口的实现类。最好是使用官方提供的工厂类来创建这些对象,以便可以在运行期中改变。find bugs
Check to see if ((...) & 0) == 0检查恒等的逻辑错误find bugs
Self assignment of field方法中包含自己对自己赋值的字段find bugs
JavadocType检查类和接口的javadoc(默认不检查author以及version)check style
JavadocMethod检查方法的javadoc的注释check style
JavadocVariable检查变量是否具有javadoc注释check style
LineLength检查编译工具中每行源代码的长度(目前设置为180个字符)check style
MethodLength检查方法和构造器的长度(目前默认设置100行)check style
OperatorWarp检查代码自动换行时运算符所处的位置(目前设置为同一行)check  style
EmptyForInitializerPad检查空的for循环初始化语句是否使用空格check style
EmptyForIteratorPad检查for iterator语句是否使用空格check style
AvoidStarImport检查import语句使用*符号(目前排除io,util)check style
IllegalImport检查是否导入了指定的非法包check style
EmptyBlock检查是否有空的代码块check style
NeedBraces检查代码块是否确实{}find bugs
LeftCurly检查左大括号的位置check style
RightCurly检查右大括号的位置check style
ModifierOrder检查代码中标识符的顺序是否符合规范check style
AvoidNestedBlocks找到嵌套代码块,也就是在代码中无节制使用的代码块check style
PackageName检查包的名称是否符合命名规范check style 
TypeName检查类的名称是否符合命名规范check style
MemberName检查成员变量(非静态字段)的名称是否遵守命名规约check style
ParameterName检查参数名称是否遵守命名规约check style
StaticVariableName检查静态变量(用static修饰,但没用final修饰的字段)的名称是否遵守命名规约check style
LambdaParameterName检查lambda表达式是否符合命名规范check style
ClassTypeParameterName检查类的命名是否符合规范check style
InterfaceTypeParameterName检查接口的命名是否符合命名规范check style
Indentation检查代码首行缩进是否符合规范check style
OverloadMethodsDeclarationOrder检查重载方法的先后顺序check style
RedundantImport检查是否存在多余的导入语句check style
UnusedImports检查未使用的导入语句check style
MethodParamPad检查方法名之后是否跟着左圆括号“(”check style
TypecastParenPad在类型转换时,不允许左圆括号右边有空格,也不允许与右圆括号左边有空格check style
NoWhitespaceBefore检查在某个特定关键字之前应保留空格check style
AnnotationLocation检查注解的位置是否合规check style
AllowMissingPropertyJavadoc允许get set 方法没有注释(默认为true)check style
CovariantEquals检查定义了共变equals()方法的类中是否同样覆盖了equals(java.lang.Object)方法find bugs
DefaultComesLast检查switch语句中的default是否在所有的case分支之后check style
EmptyStatement检查空的代码段check style
EqualsHashCode检查覆盖了equals()方法的类是否也覆盖了hashcode()find bugs
ExplicitInitialization检查类或对象的成员是否显式地初始化为成员变量所属的类型的默认值check style
FallThrough检查switch语句中是否存在跨越分支find bugs
FinalLocalVariable检查变量值没有改动的情况下,该变量是否定义成了finalcheck style
IllegalCatch非法异常捕捉,不允许捕捉java.lang.Exception、java.lang.Error、java.lang.RuntimeException的行为find bugs
MagicNumber检查是否有魔术数字(目前忽略的是 0和1 其他的最好用定义的变量来代替)check style
StringLiteralEqualityString的比较不能用!= 和 ==find bugs
MissingSwitchDefault检查switch语句中是否含有default子句check style
NestedForDepth限制for循环嵌套层数(目前是2层)check style
NestedIfDepth限制if-else代码块中嵌套的层数(目前是3层)check style
NestedTryDepth限制try代码块的嵌套层数(默认值为1)check style
UpperEll检查long类型的常量在定义时是否由大写的“L”开头check style
SuperCloneclone方法必须调用了super.clone()check style
SuperFinalizefinalize 必须调用了super.finalize()check style
ImportOrder检查导入包的顺序/分组check style
AnonInnerLength检查匿名内部类的长度(目前设置最大20行)check style
ExecutableStatementCount检查要执行的语句的数目,将可执行语句的数量限制为一个指定的限值check style
FileLength检查源码文件的长度(目前定义不超过1800行)check style
AvoidInlineConditionals检查是否在同一行初始化, 例如:private int Age = nGe==1 ? 100 : 0;就应该避免check style
InnerAssignment检查子表达式中是否有赋值操作check style
SimplifyBooleanExpression检查是否有过于复杂的布尔表达式。现在能够发现诸如if (b == true)、b || true、!false等类型的代码check style
StrictDuplicateCode逐行地比较所有的代码行,如果有若干行只有缩进有所不同,那么就报告存在重复代码(目前允许重复最小行为7)check style
BooleanExpressionComplexity限制一个表达式中的&&、||、&、|、^等逻辑运算符的数量(目前允许在一条语句中最大数目为7)check style
Hardcoded constant database password代码中创建DB的密码时采用了写死的密码find bugs
Empty database password创建数据库连接时没有为数据库设置密码,这会使数据库没有必要的保护find bugs
Nonconstant string passed to execute method on an SQL statement该方法以字符串的形式来调用SQLstatement的execute方法,它似乎是动态生成SQL语句的方法。这会更容易受到SQL注入攻击find bugs
JSP reflected cross site scripting vulnerability在代码中在JSP输出中直接写入一个HTTP参数,这会造成一个跨站点的脚本漏洞。find bugs
Creates an empty jar file entry调用putNextEntry()方法写入新的 jar 文件条目时立即调用closeEntry()方法。这样会造成JarFile条目为空。find bugs
Creates an empty zip file entry调用putNextEntry()方法写入新的 zip 文件条目时立即调用closeEntry()方法。这样会造成ZipFile条目为空。find bugs
Equals method should not assume anything about the type of its argumentequals(Object o)方法不能对参数o的类型做任何的假设。比较此对象与指定的对象。当且仅当该参数不为 null,并且是表示与此对象相同的类型的对象时,结果才为 true。find bugs
Random object created and used only once随机创建对象只使用过一次就抛弃find bugs
Check for sign of bitwise operation检查位操作符运行是否合理find bugs
Class defines clone() but doesn't implement Cloneable类中定义了clone方法但是它没有实现Cloneable接口find bugs
Abstract class defines covariant compareTo() method抽象类中定义了多个compareTo()方法,正确的是覆写Comparable中的compareTo方法,方法的参数为Objectfind bugs
Covariant compareTo() method defined类中定义了多个compareTo()方法,正确的是覆写Comparable中的compareTo方法,方法的参数为Object类型find bugs
Method might drop exception方法可能抛出异常find bugs
Method might ignore exception方法可能忽略异常find bugs
Don't use removeAll to clear a collection不要用removeAll方法去clear一个集合find bugs
Classloaders should only be created inside doPrivileged block类加载器只能建立在特殊的方法体内find bugs
Method invokes System.exit(...)在方法中调用System.exit(...)语句,考虑用RuntimeException来代替find bugs
Method invokes dangerous method runFinalizersOnExit在方法中调用了System.runFinalizersOnExit 或者Runtime.runFinalizersOnExit方法,因为这样做是很危险的。find bugs
Comparison of String parameter using == or !=用==或者!=方法去比较String类型的参数find bugs
Comparison of String objects using == or !=用==或者!=去比较String类型的对象find bugs
Equals checks for noncompatible operand equals方法检查不一致的操作。两个类根本就是父子关系而去调用equals方法去判读对象是否相等。find bugs
Class defines compareTo(...) and uses Object.equals() 类中定义了compareTo方法但是继承了Object中的compareTo方法find bugs
equals method fails for subtypes类中的equals方法可能被子类中的方法所破坏,当使用类似于Foo.class == o.getClass()的判断时考虑用find bugs
Covariant equals() method defined类中定义了多个equals方法。正确的做法是覆写Object中的equals方法,它的参数为Object类型的对象。find bugs
Empty finalizer should be deleted为空的finalizer方法应该删除。一下关于finalizer的内容省略find bugs
Class defines equals() but not hashCode()方法定义了equals方法却没有定义hashCode方法find bugs
Class defines hashCode() but not equals()类定义了hashCode方法去没有定义equal方法find bugs
Class inherits equals() and uses Object.hashCode() 子类继承了父类的equals方法却使用了Object的hashCode方法find bugs
Dubious catching of IllegalMonitorStateException捕捉违法的监控状态异常,例如当没有获取到对象锁时使用其wait和notify方法find bugs
Needless instantiation of class that only supplies static methods为使用静态方法而创建一个实例对象。调用静态方法时只需要使用类名+静态方法名就可以了。find bugs
Iterator next() method can't throw NoSuchElementException迭代器的next方法不能够抛出NoSuchElementExceptionfind bugs
Store of non serializable object into HttpSession在HttpSession对象中保存非连续的对象find bugs
Method with Boolean return type returns explicit null返回值为boolean类型的方法直接返回null,这样会导致空指针异常find bugs
equals() method does not check for null argument变量调用equals方法时没有进行是否为null的判断find bugs
toString method may return nulltoString方法可能返回nullfind bugs
Class names should start with an upper case letter类的名称以大写字母名称开头check style
Class is not derived from an Exception, even though it is named as such类的名称中含有Exception但是却不是一个异常类的子类,这种名称会造成混淆check style
Confusing method names令人迷惑的方法命名check style
Field names should start with a lower case letter非final类型的字段需要遵循驼峰命名原则find bugs
Use of identifier that is a keyword in later versions of Java 验证是否是java预留关键字find bugs
Use of identifier that is a keyword in later versions of Java 验证是否时java中的关键字find bugs
Method names should start with a lower case letter方法名称应该以小写字母开头check style
Class names shouldn't shadow simple name of implemented interface实现同一接口实现类不能使用相同的名称,即使它们位于不同的包中find bugs
Class names shouldn't shadow simple name of superclass继承同一父类的子类不能使用相同的名称,即使它们位于不同的包中find bugs
Very confusing method names (but perhaps intentional)很容易混淆的方法命名,例如方法的名称名称使用使用大小写来区别两个不同的方法。find bugs
Method doesn't override method in superclass due to wrong package for parameter由于错误引用了不同包中相同类名的对象而不能够正确的覆写父类中的方法find bugs
Method may fail to close database resource方法中可能存在关闭数据连接失败的情况find bugs
Method may fail to close stream方法中可能存在关闭流失败的情况find bugs
 Method ignores results of InputStream.read()InputStream.read方法忽略返回的多个字符,如果对结果没有检查就没法正确处理用户读取少量字符请求的情况。find bugs
Method ignores exceptional return value 方法忽略返回值的异常信息find bugs
Static initializer creates instance before all static final fields assigned在所有的static final字段赋值之前去使用静态初始化的方法创建一个类的实例。find bugs
Non-serializable value stored into instance field of a serializable class 非序列化的值保存在声明为序列化的的非序列化字段中find bugs
Comparator doesn't implement SerializableComparator接口没有实现Serializable接口find bugs
Serializable inner class序列化内部类find bugs
Class is Serializable but its superclass doesn't define a void constructor子类序列化时父类没有提供一个void的构造函数find bugs
Usage of GetResource may be unsafe if class is extended当一个类被子类继承后不要使用this.getClass().getResource(...)来获取资源find bugs
Impossible cast不可能的类转换,执行时会抛出ClassCastExceptionfind bugs
Impossible downcast父类在向下进行类型转换时抛出ClassCastExceptionfind bugs
instanceof will always return false采用instaneof方法进行比较时总是返回false。前提是保证它不是由于某些逻辑错误造成的。find bugs
Incompatible bit masks错误的使用&位操作符,例如(e & C)find bugs
Incompatible bit masks错误的使用|位操作符,例如(e | C)find bugs
Primitive value is unboxed and coerced for ternary operator 在三元运算符操作时如果没有对值进行封装或者类型转换。例如:b ? e1 : e2find bugs
Collections should not contain themselves集合没有包含他们自己本身。find bugs
Call to equals() with null argument调用equals的对象为nullfind bugs
equals method always returns false使用equals方法返回值总是falsefind bugs
equals method always returns trueequals方法返回值总是truefind bugs
equals method compares class names rather than class objects使用equals方法去比较一个类的实例和类的类型find bugs
Format string placeholder incompatible with passed argument错误使用参数类型来格式化字符串find bugs
The type of a supplied argument doesn't match format specifier指定的格式字符串和参数类型不匹配,例如:String.format("%d", "1")find bugs
Illegal format string格式化String对象语句错误find bugs
integral value cast to double and then passed to Math.ceilintegral的值转换为double后使用了Math.ceil方法find bugs
int value cast to float and then passed to Math.roundint 类型的值转换为float类型之后调用了Math.round方法find bugs
JUnit assertion in run method will not be noticed by Junit在JUnit中的断言在run方法中不会被告知find bugs
A collection is added to itself集合本身作为add方法的参数,这样会引起内容溢出。find bugs
An apparent infinite loop方法的自调用引起的死循环find bugs
Integer multiply of result of integer remainder和整数余数进行乘法运算。例如:i % 60 * 1000 是进行(i % 60) * 1000运算而不是 i % (60 * 1000)find bugs
Bad comparison of nonnegative value with negative constant保证非负数和负数进行比较find bugs
Class defines field that masks a superclass field子类中定义了和父类中同名的字段。在调用时会出错find bugs
Method defines a variable that obscures a field在方法中定义的局部变量和类变量或者父类变量同名,从而引起字段混淆。find bugs
Null pointer dereference对象赋为null值后 没有被重新赋值find bugs
Null pointer dereference in method on exception path空指针引用上调用去除引用方法,将发生空指针异常find bugs
Method does not check for null argument 方法没有判断参数是否为空find bugs
Method call passes null to a nonnull parameter方法中为null的参数没有被重新赋值find bugs
A known null value is checked to see if it is an instance of a type检查一个为null的值是否是想要的类型对象,而不是由于粗心或者逻辑错误引起的find bugs
Possible null pointer dereference对象可能没有重新赋值find bugs
Method call passes null for nonnull parameter方法参数中声明为nonnull类型的参数为nullfind bugs
Store of null value into field annotated NonNull为一个已经声明为不能为null值的属性赋值为nullfind bugs
Apparent method/constructor confusion构造方法定义混乱,保证一个标准的构造函数find bugs
Very confusing method names混乱的方法命名,如getName和getname方法同时出现的时候find bugs
Method doesn't override method in superclass due to wrong package for parameter方法因为取了不同包中的同名的对象而没有正确覆写父类中的同名方法find bugs
Method assigns boolean literal in boolean expression在if或者while表达式中使用boolean类型的值时应该使用==去判断,而不是采用=操作find bugs
Suspicious reference comparison比较两个对象值是否相等时应该采用equals方法,而不是==方法find bugs
Invalid syntax for regular expression 对正则表达式使用了错误的语法,会抛出未经检查的异常,表明正则表达式模式中的语法错误。find bugs
Random value from 0 to 1 is coerced to the integer 0从0到1随机值被强制为整数值0。在强制得到一个整数之前,你可能想得到多个随机值。或使用Random.nextInt(n)的方法。find bugs
Method ignores return value该方法的返回值应该进行检查。这种警告通常出现在调用一个不可变对象的方法,认为它更新了对象的值。find bugs
Double assignment of field方法中的字段包含了双重任务find bugs
Dead store due to switch statement fall through to throw 在swtich中因为出现异常而忽略了对case值的保存。find bugs
Field only ever set to null字段的值总是为null值,所有读取该字段的值都为null。检查错误,如果它确实没有用就删除掉。find bugs
Empty synchronized block该代码包含一个空的同步块:synchronized() {}find bugs
Non serializable object written to ObjectOutput代码中让一个非序列化的对象出现在ObjectOutput.writeObject()方法中,这样会引起一个错误。find bugs
Useless control flow to next line无效的条件控制语句,注意if (argv.length == 1);以“;”结尾,下面的语句无论是否满足都会运行find bugs
Method directly allocates a specific implementation of xml interfaces方法自定义了一种XML接口的实现类。最好是使用官方提供的工厂类来创建这些对象,以便可以在运行期中改变。find bugs
Check to see if ((...) & 0) == 0检查恒等的逻辑错误find bugs
Self assignment of field方法中包含自己对自己赋值的字段find bugs
   
   
   
   
   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值