JAVA代码规则对照表

JAVA代码规则对照表

Try-with-resources should be used
应该使用带有资源的Try-with-resources
Creating cookies without the “secure” flag is security-sensitive
创建没有“secure”标志的cookie是安全敏感的
Return values should not be ignored when they contain the operation status code
当返回值包含操作状态码时,不应忽略它们
Resources should be closed
资源应该关闭
Asserts should not be used to check the parameters of a public method
不应该使用断言检查公共方法的参数
Classes should not be empty
类不应该是空的
Getters and setters should access the expected fields
getter和setter应该访问预期的字段
Enabling Cross-Origin Resource Sharing is security-sensitive
启用跨源资源共享是安全敏感的
Min and max used in combination should not always return the same value
组合使用的Min和max不应该总是返回相同的值
“equals(Object obj)” should test argument type
“equals(Object obj)“应该测试参数类型
“main” should not “throw” anything
“主”不应该“抛出”任何东西
Packages containing only “package-info.
包只包含“包信息”。
java” should be removed
应该删除java
“getClass” should not be used for synchronization
“getClass”不应该用于同步
“enum” fields should not be publicly mutable
“enum”字段不应该被公开修改
“Stream” call chains should be simplified when possible
“流”调用链应该尽可能简化
Functional Interfaces should be as specialised as possible
功能接口应该尽可能的专门化
“Bean Validation” (JSR 380) should be properly configured
应该正确配置“Bean验证”(JSR 380)
Modifiers should be declared in the correct order
修饰词应该按照正确的顺序声明
Equality operators should not be used in “for” loop termination conditions
相等运算符不应在“for”循环终止条件中使用
Duplicate values should not be passed as arguments
重复的值不应该作为参数传递
Fields should not be initialized to default values
字段不应初始化为默认值
Map values should not be replaced unconditionally
不应该无条件地替换映射值
Methods should not have identical implementations
方法不应该有相同的实现
HTTP referers should not be relied on
不应该依赖HTTP引用
“Stream.collect()” calls should not be redundant
“Stream.collect()”调用不应该是多余的
Local constants should follow naming conventions for constants
局部常量应该遵循常量的命名约定
“java.nio.
“nio。
Files#delete” should be preferred
文件#delete”应该是首选
Comments should not be located at the end of lines of code
注释不应该位于代码行的末尾
Assignments should not be redundant
任务不应该是多余的
“volatile” variables should not be used with compound operators
“volatile”变量不应该与复合操作符一起使用
Non-primitive fields should not be “volatile”
非原语字段不应该是“易变的”
Spring components should use constructor injection
Spring组件应该使用构造函数注入
“throws” declarations should not be superfluous
“抛出”声明不应该是多余的
The diamond operator (”<>”) should be used
应该使用diamond操作符(“<>”)
“compareTo” should not be overloaded
“compareTo”不应该超载
Broadcasting intents is security-sensitive
广播意图是安全敏感的
“toArray” should be passed an array of the proper type
“toArray”应该被传递一个正确类型的数组
An open curly brace should be located at the beginning of a line
左花括号应该位于一行的开头
Class variable fields should not have public accessibility
类变量字段不应该具有公共可访问性
Close curly brace and the next “else”, “catch” and “finally” keywords should be on two different lines
右花括号和下一个“else”、“catch”和“finally”关键字应该在两个不同的行上
The non-serializable super class of a “Serializable” class should have a no-argument constructor
“可序列化”类的非序列化超类应该有一个无参数构造函数
Class names should not shadow interfaces or superclasses
类名不应该隐藏接口或超类
Inappropriate “Collection” calls should not be made
不应打不适当的“托收”电话
Accessing Android external storage is security-sensitive
访问Android外部存储是安全敏感的
Short-circuit logic should be used in boolean contexts
短路逻辑应该在布尔上下文中使用
“Serializable” classes should have a “serialVersionUID”
“Serializable"类应该有一个"serialVersionUID”
Child class methods named for parent class methods should be overrides
应该重写以父类方法命名的子类方法
Receiving intents is security-sensitive
接收意图是安全敏感的
“Serializable” inner classes of “Serializable” classes should be static
"Serializable"类的内部类应该是静态的
String function use should be optimized for single characters
字符串函数的使用应该针对单个字符进行优化
Validating SSL/TLS connections is security-sensitive
验证SSL/TLS连接是安全敏感的
Future keywords should not be used as names
将来的关键字不应该用作名称
Classes from “sun.
类从“太阳。
*” packages should not be used
*“不应该使用包装
String literals should not be duplicated
字符串文字不应该被复制
Exception types should not be tested using “instanceof” in catch blocks
异常类型不应该在catch块中使用“instanceof”进行测试
Subclasses that add fields should override “equals”
添加字段的子类应该覆盖“equals”
“java.lang.
" . lang。
Error” should not be extended
错误“不应扩展
Static fields should not be updated in constructors
在构造函数中不应更新静态字段
“action” mappings should not have too many “forward” entries
“动作”映射不应该有太多的“转发”条目
Array designators “[]” should be located after the type in method signatures
数组指示符“[]”应该位于方法签名中的类型之后
“equals” methods should be symmetric and work for subclasses
“equals”方法应该是对称的,并且适用于子类
URIs should not be hardcoded
uri不应该硬编码
“finalize” should not set fields to “null”
“finalize”不应该将字段设置为“null”
Default annotation parameter values should not be passed as arguments
默认的注释参数值不应该作为参数传递
Changing or bypassing accessibility is security-sensitive
更改或绕过可访问性是安全敏感的
Array designators “[]” should be on the type, not the variable
数组指示符“[]”应该在类型上,而不是变量上
Math should not be performed on floats
不应该在浮点数上执行数学运算
Struts validation forms should have unique names
Struts验证表单应该有唯一的名称
“ThreadGroup” should not be used
不应该使用“ThreadGroup”
“compareTo” should not return “Integer.MIN_VALUE”
“compareTo"不应该返回"Integer.MIN_VALUE”
Nested code blocks should not be used
不应该使用嵌套代码块
Classes named like “Exception” should extend “Exception” or a subclass
像“Exception”这样的类应该扩展“Exception”或子类
“iterator” should not return “this”
“迭代器”不应该返回“this”
Double-checked locking should not be used
不应该使用双重检查锁定
The names of methods with boolean return values should start with “is” or “has”
具有布尔返回值的方法的名称应该以“is”或“has”开头
“write(byte[],int,int)” should be overridden
“写(字节[],int,int)”应该被覆盖
“SecureRandom” seeds should not be predictable
“安全”种子不应该是可预测的
Default EJB interceptors should be declared in “ejb-jar.xml”
默认的EJB拦截器应该在“EJB -jar.xml”中声明。
SHA-1 and Message-Digest hash algorithms should not be used in secure contexts
SHA-1和消息摘要散列算法不应在安全上下文中使用
EJB interceptor exclusions should be declared as annotations
EJB拦截器的排除应该声明为注释
Track uses of disallowed constructors
跟踪不允许的构造函数的使用
Switches should be used for sequences of simple “String” tests
开关应该用于简单的“字符串”测试序列
“writeObject” should not be the only “synchronized” code in a class
“writeObject”不应该是类中唯一的“同步”代码
Empty statements should be removed
应该删除空语句
Formatting SQL queries is security-sensitive
格式化SQL查询是安全敏感的
Modulus results should not be checked for direct equality
模数结果不应检查直接相等
SMTP SSL connection should check server identity
SMTP SSL连接应该检查服务器身份
Multiple loops over the same set should be combined
同一个集合上的多个循环应该被合并
“wait” should not be called when multiple locks are held
当持有多个锁时,不应该调用“wait”
Authentication should not rely on insecure “PasswordEncoder”
认证不应该依赖于不安全的“密码编码器”
Magic numbers should not be used
不应该使用魔法数字
Standard outputs should not be used directly to log anything
标准输出不应直接用于记录任何内容
“Externalizable” classes should have no-arguments constructors
“Externalizable”类应该有无参数的构造函数
Ints and longs should not be shifted by zero or more than their number of bits-1
整数和整数的移位不应大于或等于其位数1
“readResolve” methods should be inheritable
“readResolve”方法应该是可继承的
Classes should not have too many “static” imports
类不应该有太多的“静态”导入
Custom serialization method signatures should meet requirements
自定义序列化方法签名应满足要求
Silly math should not be performed
不应该进行愚蠢的数学运算
JEE applications should not “getClassLoader”
JEE应用程序不应该“获取类加载器”
Math operands should be cast before assignment
数学操作数应该在赋值之前进行转换
Comparators should be “Serializable”
比较器应该是“可序列化的”
“Serializable” inner classes of non-serializable classes should be “static”
非序列化类的内部类应该是“静态的”
Raw byte values should not be used in bitwise operations in combination with shifts
原始字节值不应与移位一起用于按位操作
TestCases should contain tests
测试用例应该包含测试
Fields in non-serializable classes should not be “transient”
非序列化类中的字段不应该是“瞬态的”
Composed “@RequestMapping” variants should be preferred
应该首选组合的“@RequestMapping”变体
JUnit assertions should not be used in “run” methods
JUnit断言不应该在“运行”方法中使用
Credentials should not be hard-coded
凭证不应该硬编码
Loops should not be infinite
循环不应该是无限的
“private” methods called only by inner classes should be moved to those classes
只被内部类调用的“私有”方法应该被移动到那些类中
JUnit test cases should call super methods
JUnit测试用例应该调用超方法
Abstract methods should not be redundant
抽象方法不应该是多余的
Regex patterns should not be created needlessly
不应该不必要地创建正则表达式模式
Methods should not have too many lines
方法不应该有太多行
Loops should not contain more than a single “break” or “continue” statement
循环应该只包含一个“break”或“continue”语句
Deprecated elements should have both the annotation and the Javadoc tag
废弃的元素应该同时具有注释和Javadoc标记
Lambdas containing only one statement should not nest this statement in a block
只包含一条语句的Lambdas不应将此语句嵌套在块中
“Object.wait(…)” should never be called on objects that implement “java.util.concurrent.locks.Condition”
不应该在实现“java.util.concurrent.locks.Condition”的对象上调用“Object.wait(…)”
Methods and field names should not be the same or differ only by capitalization
方法和字段名不应相同或仅按大小写不同
Anonymous inner classes containing only one method should become lambdas
只包含一个方法的匿名内部类应该成为lambdas
“Iterator.hasNext()” should not call “Iterator.next()”
"Iterator.hasNext()“不应该调用"Iterator.next()”
Tests should not be ignored
不应该忽略测试
Use Java 12 “switch” expression
使用Java 12“开关”表达式
Switch cases should end with an unconditional “break” statement
开关情况应该以无条件的“break”语句结束
Methods should not be too complex
方法不应该太复杂
“if …
“如果……
else if” constructs should end with “else” clauses
else if结构应该以else子句结尾
Track comments matching a regular expression
跟踪与正则表达式匹配的注释
Annotation repetitions should not be wrapped
注释重复不应该被包装
Standard functional interfaces should not be redefined
不应该重新定义标准的功能接口
“Thread.
“线程。
sleep” should not be used in tests
“睡眠”不应该用于测试
JUnit rules should be used
应该使用JUnit规则
Control flow statements “if”, “for”, “while”, “switch” and “try” should not be nested too deeply
控制流语句“if”、“for”、“while”、“switch”和“try”不应该嵌套得太深
Local variables should not shadow class fields
局部变量不应该隐藏类字段
All branches in a conditional structure should not have exactly the same implementation
条件结构中的所有分支不应该具有完全相同的实现
Exceptions should not be thrown from servlet methods
不应该从servlet方法抛出异常
“DateUtils.
“DateUtils。
truncate” from Apache Commons Lang library should not be used
不应该使用Apache Commons Lang库中的truncate”
Unnecessary semicolons should be omitted
不必要的分号应该省略
Synchronization should not be based on Strings or boxed primitives
同步不应该基于字符串或盒装原语
Related “if/else if” statements should not have the same condition
相关的“if/else if”语句不应具有相同的条件
@FunctionalInterface annotation should be used to flag Single Abstract Method interfaces
@FunctionalInterface注释应该用来标记单个抽象方法接口
Parentheses should be removed from a single lambda input parameter when its type is inferred
在推断一个lambda输入参数的类型时,应该从该参数中删除括号
Literal boolean values should not be used in assertions
不应在断言中使用文字布尔值
Lambdas should be replaced with method references
应该用方法引用替换Lambdas
Dead stores should be removed
死亡的物品应该被移走
“toString()” should never be called on a String object
“toString()”不应该在String对象上调用
“instanceof” operators that always return “true” or “false” should be removed
应该删除总是返回“true”或“false”的instanceof操作符
Abstract classes without fields should be converted to interfaces
没有字段的抽象类应该转换为接口
Expanding archive files is security-sensitive
展开归档文件是安全敏感的
“switch” statements should have “default” clauses
“switch”语句应该有“default”子句
“@Deprecated” code should not be used
不应该使用“@Deprecated”代码
“deleteOnExit” should not be used
不应该使用“deleteOnExit”
Close curly brace and the next “else”, “catch” and “finally” keywords should be located on the same line
右大括号和下一个“else”、“catch”和“finally”关键字应该位于同一行
“ThreadLocal.
“ThreadLocal。
withInitial” should be preferred
最好是“潜在的”
Redundant casts should not be used
不应该使用冗余强制类型转换
Extensions and implementations should not be redundant
扩展和实现不应该是冗余的
Variables should not be declared before they are relevant
变量在相关之前不应该声明
Classes should not have too many fields
类不应该有太多的字段
A field should not duplicate the name of its containing class
字段不应重复其包含的类的名称
Simple class names should be used
应该使用简单的类名
“switch” statements should not be nested
不应该嵌套“switch”语句
Classes and methods that rely on the default system encoding should not be used
不应该使用依赖于默认系统编码的类和方法
“indexOf” checks should use a start position
“indexOf”检查应该使用起始位置
Fields in a “Serializable” class should either be transient or serializable
“可序列化”类中的字段应该是瞬态的或可序列化的
A close curly brace should be located at the beginning of a line
右花括号应该位于一行的开头
Boolean checks should not be inverted
布尔检查不应该是反向的
“close()” calls should not be redundant
“close()”调用不应该是多余的
“equals(Object obj)” and “hashCode()” should be overridden in pairs
应该成对地重写“equals(Object obj)”和“hashCode()”
Controlling permissions is security-sensitive
控制权限是安全敏感的
Classes should not have too many methods
类不应该有太多的方法
Jump statements should not be redundant
跳转语句不应该是多余的
Classes should not be loaded dynamically
类不应该动态加载
Locale should be used in String operations
区域设置应该在字符串操作中使用
“StandardCharsets” constants should be preferred
应该首选“标准字符集”常量
Members of Spring components should be injected
应该注入Spring组件的成员
An iteration on a Collection should be performed on the type handled by the Collection
应该对集合处理的类型执行集合上的迭代
Source code should be indented consistently
源代码应该始终缩进
Collection sizes and array length comparisons should make sense
集合大小和数组长度的比较应该是有意义的
Classes should not be coupled to too many other classes (Single Responsibility Principle)
类不应该与太多的其他类耦合(单一职责原则)
Web applications should not have a “main” method
Web应用程序不应该有“主”方法
Exception should not be created without being thrown
如果不抛出,就不应该创建异常
“equals” method overrides should accept “Object” parameters
“equals”方法重写应该接受“Object”参数
“public static” fields should be constant
“公共静态”字段应该是常量
Week Year (“YYYY”) should not be used for date formatting
日期格式不应使用年(“YYYY”)
Unused “private” classes should be removed
不使用的“私有”类应该被删除
“Stream.
”流。
peek” should be used with caution
应该谨慎使用peek
Inheritance tree of classes should not be too deep
类的继承树不应该太深
Octal values should not be used
不应该使用八进制值
Track uses of “CHECKSTYLE:OFF” suppression comments
跟踪“CHECKSTYLE:OFF”抑制注释的使用
Using command line arguments is security-sensitive
使用命令行参数是安全敏感的
“StringBuilder” and “StringBuffer” should not be instantiated with a character
“StringBuilder”和“StringBuffer”不应该用字符实例化
Basic authentication should not be used
不应该使用基本身份验证
Reading the Standard Input is security-sensitive
读取标准输入是安全敏感的
Declarations should use Java collection interfaces such as “List” rather than specific implementation classes such as “LinkedList”
声明应该使用Java集合接口,如“List”,而不是特定的实现类,如“LinkedList”
Unary prefix operators should not be repeated
不应重复使用一元前缀操作符
Track uses of “NOPMD” suppression comments
跟踪“NOPMD”抑制注释的使用
A conditionally executed single line should be denoted by indentation
有条件执行的单行应该用缩进表示
Conditionals should start on new lines
条件句应该从新的行开始
Loggers should be “private static final” and should share a naming convention
日志记录器应该是“私有静态final”,并且应该共享命名约定
Getters and setters should be synchronized in pairs
getter和setter应该成对同步
Using hardcoded IP addresses is security-sensitive
使用硬编码的IP地址是安全敏感的
Non-thread-safe fields should not be static
非线程安全字段不应该是静态的
The Object.finalize() method should not be overriden
finalize()方法不应该被覆盖
“for” loop stop conditions should be invariant
for循环停止条件应该是不变的
Method parameters, caught exceptions and foreach variables’ initial values should not be ignored
方法参数、捕获的异常和foreach变量的初始值不应该被忽略
Silly bit operations should not be performed
不应该执行愚蠢的位操作
Java 8 features should be preferred to Guava
Java 8特性应该优先于Guava
Packages should have a javadoc file ‘package-info.java’
包应该有一个javadoc文件“package-info.java”
“Threads” should not be used where “Runnables” are expected
“线程”不应该用在“可运行”的地方
The default unnamed package should not be used
不应该使用默认的未命名包
Methods should not be named “tostring”, “hashcode” or “equal”
不应该将方法命名为“tostring”、“hashcode”或“equal”
“readObject” should not be “synchronized”
“readObject”不应该是“同步的”
Non-constructor methods should not have the same name as the enclosing class
非构造函数方法不应该与封闭类具有相同的名称
The value returned from a stream read should be checked
应该检查从读取的流返回的值
Methods should not return constants
方法不应该返回常量
Strings and Boxed types should be compared using “equals()”
字符串和装箱类型应该使用“equals()”进行比较
“read” and “readLine” return values should be used
应该使用“read”和“readLine”返回值
Neither “Math.
无论是“数学。
abs” nor negation should be used on numbers that could be “MIN_VALUE”
“也不应使用否定的数字可能是"MIN_VALUE”
Execution of the Garbage Collector should be triggered only by the JVM
垃圾收集器的执行应该仅由JVM触发
Constructors should only call non-overridable methods
构造函数应该只调用不可覆盖的方法
“null” should not be used with “Optional”
"null"不应与"Optional"一起使用
Spring beans should be considered by “@ComponentScan”
Spring bean应该由“@ComponentScan”来考虑
Arrays should not be created for varargs parameters
不应该为varargs参数创建数组
“Thread.run()” should not be called directly
不应该直接调用“Thread.run()”
"@Import"s should be preferred to "@ComponentScan"s
应该首选“@Import”而不是“@ComponentScan”
Methods returns should not be invariant
方法返回不应该是不变的
“@EnableAutoConfiguration” should be fine-tuned
应该对“@EnableAutoConfiguration”进行微调
“switch” statements should not contain non-case labels
“switch”语句不应该包含非大小写标签
Zero should not be a possible denominator
0不应该是一个可能的分母
Private fields only used as local variables in methods should become local variables
只在方法中用作局部变量的私有字段应该成为局部变量
Track lack of copyright and license headers
跟踪缺少版权和许可标题
“@RequestMapping” methods should be “public”
“@RequestMapping”方法应该是“公共的”
“equals(Object obj)” should be overridden along with the “compareTo(T obj)” method
“equals(Object obj)”应该和“compareTo(T obj)”方法一起被覆盖
Generic wildcard types should not be used in return parameters
不应在返回参数中使用通配符类型
An abstract class should have both abstract and concrete methods
抽象类应该同时具有抽象方法和具体方法
Spring “@Controller” classes should not use “@Scope”
Spring“@Controller”类不应该使用“@Scope”
“NullPointerException” should not be explicitly thrown
不应该显式地抛出“NullPointerException”
Public methods should not contain selector arguments
公共方法不应该包含选择器参数
“@Controller” classes that use “@SessionAttributes” must call “setComplete” on their “SessionStatus” objects
使用“@SessionAttributes”的“@Controller”类必须在其“SessionStatus”对象上调用“setComplete”
“HttpSecurity” URL patterns should be correctly ordered
“HttpSecurity”URL模式应该是正确排序的
“NullPointerException” should not be caught
不应该捕获“NullPointerException”
“Arrays.
“数组。
stream” should be used for primitive arrays
“流”应该用于基元数组
“@RequestMapping” methods should specify HTTP method
“@RequestMapping”方法应该指定HTTP方法
“@SpringBootApplication” and “@ComponentScan” should not be used in the default package
默认包中不应该使用“@SpringBootApplication”和“@ComponentScan”
“HostnameVerifier.
“HostnameVerifier。
verify” should not always return true
验证“不应该总是返回true
The members of an interface or class declaration should appear in a pre-defined order
接口或类声明的成员应该以预定义的顺序出现
Short-circuit logic should be used to prevent null pointer dereferences in conditionals
应该使用短路逻辑来防止条件语句中的空指针解引用
Constants should not be defined in interfaces
常量不应该在接口中定义
" and “!
“= =”和“!
=” should not be used when “equals” is overridden
在重写“equals”时不应使用="
Nested “enum"s should not be declared static
嵌套的“enum”不应该声明为静态的
Files should not be empty
文件不应该是空的
“super.finalize()” should be called at the end of “Object.finalize()” implementations
应该在“Object.finalize()”实现的末尾调用“super.finalize()”
“File.
”文件。
createTempFile” should not be used to create a directory
不应该使用createTempFile来创建目录
“clone” should not be overridden
“克隆”不应该被覆盖
Hibernate should not update database schemas
Hibernate不应该更新数据库模式
“Map.
“地图。
get” and value test should be replaced with single method call
应该用单个方法调用替换get和value test
“catch” clauses should do more than rethrow
“catch”子句应该做的不仅仅是重新抛出
Assertions should be complete
断言应该是完整的
Maps with keys that are enum values should be replaced with EnumMap
带有enum值键的映射应该替换为EnumMap
Inner classes should not have too many lines of code
内部类不应该有太多的代码行
Sets with elements that are enum values should be replaced with EnumSet
带有enum值元素的集合应该替换为EnumSet
Classes without “public” constructors should be “final”
没有“公共”构造函数的类应该是“final”
Strings should not be concatenated using ‘+’ in a loop
不应该在循环中使用’+‘连接字符串
Identical expressions should not be used on both sides of a binary operator
相同的表达式不应该在二进制操作符的两边都使用
Escaped Unicode characters should not be used
不应该使用转义的Unicode字符
Sections of code should not be commented out
代码的部分不应该注释掉
Files should contain only one top-level class or interface each
每个文件应该只包含一个顶级类或接口
Number patterns should be regular
数字模式应该是有规律的
Two branches in a conditional structure should not have exactly the same implementation
条件结构中的两个分支不应该具有完全相同的实现
Classes should not be compared by name
类不应该通过名称进行比较
Loops with at most one iteration should be refactored
最多一次迭代的循环应该重构
“for” loop increment clauses should modify the loops’ counters
for循环增量子句应该修改循环的计数器
Untrusted XML should be parsed with a local, static DTD
不可信的XML应该使用本地的静态DTD进行解析
“@NonNull” values should not be set to null
“@NonNull”值不应该设置为null
Java 8’s “Files.
Java 8的”文件。
exists” should not be used
不应使用exists
“=+” should not be used instead of “+=”
不能用”=+“代替”+="
Inappropriate regular expressions should not be used
不应该使用不合适的正则表达式
Using Sockets is security-sensitive
使用套接字是安全敏感的
Method overrides should not change contracts
方法重写不应更改契约
Track uses of “@SuppressWarnings” annotations
跟踪“@SuppressWarnings”注释的使用
“switch” statements should have at least 3 “case” clauses
"switch"语句应该至少有3个"case"子句
Variables should not be self-assigned
变量不应该是自分配的
“Class.forName()” should not load JDBC 4.0+ drivers
“Class.forName()”不应该加载JDBC 4.0+驱动程序
Java parser failure
Java解析器故障
Multiple variables should not be declared on the same line
多个变量不应该在同一行中声明
Consumed Stream pipelines should not be reused
消耗的流管道不应该被重用
The Object.finalize() method should not be called
不应该调用Object.finalize()方法
Intermediate Stream methods should not be left unused
中间流方法不应该闲置
“read(byte[],int,int)” should be overridden
应该重写“read(byte[],int,int)”
“serialVersionUID” should not be declared blindly
不应该盲目地声明“serialVersionUID”
“Preconditions” and logging arguments should not require evaluation
“先决条件”和日志记录参数不需要评估
Assignments should not be made from within sub-expressions
不应该从子表达式中进行赋值
The ternary operator should not be used
不应该使用三元运算符
“entrySet()” should be iterated when both the key and value are needed
当需要键和值时,应该迭代“entrySet()”
Public methods should throw at most one checked exception
公共方法最多应该抛出一个已检查的异常
Configuring loggers is security-sensitive
配置日志记录器是安全敏感的
“@Override” should be used on overriding and implementing methods
应该在重写和实现方法时使用“@Override”
A “for” loop update clause should move the counter in the right direction
“for”循环更新子句应该将计数器移动到正确的方向
Parsing should be used to convert “Strings” to primitives
解析应该用于将“字符串”转换为原语
Annotation arguments should appear in the order in which they were declared
注释参数应该按照声明它们的顺序出现
Checked exceptions should not be thrown
不应抛出已检查的异常
Collection methods with O(n) performance should be used carefully
应谨慎使用具有O(n)性能的收集方法
Hashing data is security-sensitive
哈希数据是安全敏感的
Literal suffixes should be upper case
字面后缀应该是大写
Exceptions should be either logged or rethrown but not both
应该记录或重新抛出异常,但不应该同时记录和重新抛出异常
An open curly brace should be located at the end of a line
左花括号应该位于行尾
Exceptions should not be thrown in finally blocks
不应该在finally块中抛出异常
Track uses of disallowed methods
跟踪不允许的方法的使用
AES encryption algorithm should be used with secured mode
AES加密算法应采用安全模式
Loop conditions should be true at least once
循环条件应该至少为真一次
LDAP connections should be authenticated
LDAP连接应该经过身份验证
Primitives should not be boxed just for “String” conversion
原语不应该仅仅为了“字符串”转换而装箱
Exception classes should be immutable
异常类应该是不可变的
Writing cookies is security-sensitive
编写cookie是安全敏感的
Classes extending java.lang.
类扩展. lang。
Thread should override the “run” method
线程应该覆盖“运行”方法
Enum values should be compared with "

枚举值应该与“==”进行比较
Exception handlers should preserve the original exceptions
异常处理程序应该保留原始异常
“HttpServletRequest.getRequestedSessionId()” should not be used
不应该使用“HttpServletRequest.getRequestedSessionId()”
Objects should not be created only to “getClass”
对象不应该只创建为“getClass”
Using non-standard cryptographic algorithms is security-sensitive
使用非标准密码算法是安全敏感的
Expressions used in “assert” should not produce side effects
“断言”中使用的表达式不应该产生副作用
Empty arrays and collections should be returned instead of null
应该返回空数组和集合,而不是null
LDAP deserialization should be disabled
应该禁用LDAP反序列化
Null pointers should not be dereferenced
不应该取消对空指针的引用
“javax.crypto.
“javax.crypto。
NullCipher” should not be used for anything other than testing
除了测试之外,NullCipher不能用于其他任何事情
XML transformers should be secured
应该保护XML转换程序
Functions should not be defined with a variable number of arguments
函数不应该使用可变数量的参数来定义
Class names should comply with a naming convention
类名应该符合命名约定
Method names should comply with a naming convention
方法名应该符合命名约定
Enumeration should not be implemented
不应实现枚举
“switch case” clauses should not have too many lines of code
“switch case”子句不应该有太多的代码行
Constructors should not be used to instantiate “String”, “BigInteger”, “BigDecimal” and primitive-wrapper classes
构造函数不应该用于实例化“String”、“BigInteger”、“BigDecimal”和原语包装类
Cookie domains should be as narrow as possible
Cookie域应该尽可能的窄
Using regular expressions is security-sensitive
使用正则表达式是安全敏感的
String.valueOf() should not be appended to a String
valueof()不应该附加到字符串中
“HttpOnly” should be set on cookies
cookie上应该设置“HttpOnly”
Values should not be uselessly incremented
值不应该毫无用处地递增
Labels should not be used
不应该使用标签
Collection.isEmpty() should be used to test for emptiness
应该使用iempty()来测试是否为空
“ScheduledThreadPoolExecutor” should not have 0 core threads
“ScheduledThreadPoolExecutor”不应该有0个核心线程
“Integer.
“整数。
toHexString” should not be used to build hexadecimal strings
“toHexString”不应用于构建十六进制字符串
Test classes should comply with a naming convention
测试类应该遵循命名约定
Case insensitive string comparisons should be made without intermediate upper or lower casing
不区分大小写的字符串比较应该在没有中间大小写的情况下进行
Using pseudorandom number generators (PRNGs) is security-sensitive
使用伪随机数生成器是安全敏感的
Cryptographic keys should not be too short
密码密钥不能太短
Primitive wrappers should not be instantiated only for “toString” or “compareTo” calls
不能仅为“toString”或“compareTo”调用实例化原语包装器
“Double.
“双。
longBitsToDouble” should not be used for “int”
长bitstodouble “不应用于"int”
Weak SSL protocols should not be used
不应该使用弱SSL协议
Using unsafe Jackson deserialization configuration is security-sensitive
使用不安全的Jackson反序列化配置是安全敏感的
Printf-style format strings should be used correctly
应该正确使用printf格式的字符串
TrustManagers should not blindly accept any certificates
信托经理不应该盲目地接受任何证书
Encrypting data is security-sensitive
加密数据是安全敏感的
Test methods should comply with a naming convention
测试方法应该遵循命名约定
Classes should not access their own subclasses during initialization
类在初始化期间不应该访问它们自己的子类
Throwable and Error should not be caught
可投掷和错误不应被捕获
Classes that override “clone” should be “Cloneable” and call “super.clone()”
覆盖“clone”的类应该是“Cloneable”,并调用“super.clone()”
JUnit framework methods should be declared properly
应该正确地声明JUnit框架方法
“wait”, “notify” and “notifyAll” should only be called when a lock is obviously held on an object
“wait”、“notify”和“notifyAll”只能在对象上明显持有锁时调用
“Iterator.next()” methods should throw “NoSuchElementException”
“Iterator.next()“方法应该抛出"NoSuchElementException”
“runFinalizersOnExit” should not be called
不应该调用“runFinalizersOnExit”
Static non-final field names should comply with a naming convention
静态非最终字段名应该符合命名约定
Public types, methods and fields (API) should be documented with Javadoc
公共类型、方法和字段(API)应该用Javadoc记录
Overriding methods should do more than simply call the same method in the super class
重写方法不应该只是简单地在超类中调用相同的方法
Printf-style format strings should not lead to unexpected behavior at runtime
printf样式的格式字符串在运行时不应导致意外的行为
Dissimilar primitive wrappers should not be used with the ternary operator without explicit casting
在没有显式强制转换的情况下,不应该将不同的原语包装器与三元运算符一起使用
“equals” method parameters should not be marked “@Nonnull”
“equals"方法参数不应该被标记为”@Nonnull”
Methods should not be empty
方法不应该是空的
Unused labels should be removed
未使用的标签应删除
“Object.wait(…)” and “Condition.await(…)” should be called inside a “while” loop
应该在while循环中调用“Object.wait(…)”和“Condition.await(…)”
Boxing and unboxing should not be immediately reversed
装箱和拆箱不应该立即反转
Method parameters should be declared with base types
方法参数应该用基类型声明
Collapsible “if” statements should be merged
可折叠的“if”语句应该合并
Cryptographic RSA algorithms should always incorporate OAEP (Optimal Asymmetric Encryption Padding)
加密的RSA算法应该总是包含OAEP(最佳非对称加密填充)
“final” classes should not have “protected” members
“final”类不应该有“protected”成员
“this” should not be exposed from constructors
“this”不应该从构造函数中公开
Expressions should not be too complex
表达式不应该太复杂
Lambdas and anonymous classes should not have too many lines of code
Lambdas和匿名类不应该有太多的代码行
“wait(…)” should be used instead of “Thread.sleep(…)” when a lock is held
当锁被持有时,应该使用“wait(…)”而不是“Thread.sleep(…)”
Sending emails is security-sensitive
发送电子邮件是安全敏感的
Unused “private” fields should be removed
未使用的“私有”字段应该被删除
Neither DES (Data Encryption Standard) nor DESede (3DES) should be used
不应该使用DES(数据加密标准)或DESede (3DES)
“Cloneables” should implement “clone”
“克隆”应该实现“克隆”
Member variable visibility should be specified
应该指定成员变量可见性
Silly equality checks should not be made
不应该进行愚蠢的平等检查
Using environment variables is security-sensitive
使用环境变量是安全敏感的
Security constraints should be defined
应该定义安全约束
Public constants and fields initialized at declaration should be “static final” rather than merely “final”
在声明时初始化的公共常量和字段应该是“静态final”,而不仅仅是“final”。
Only static class initializers should be used
只能使用静态类初始化器
“@CheckForNull” or “@Nullable” should not be used on primitive types
“@CheckForNull”或“@Nullable”不应用于基元类型
Unused method parameters should be removed
应该删除未使用的方法参数
Classes that don’t define “hashCode()” should not be used in hashes
不定义“hashCode()”的类不应在散列中使用
Methods of “Random” that return floating point values should not be used in random integer generation
在随机整数生成中不应该使用返回浮点值的“随机”方法
Classes should not be too complex
类不应该太复杂
Nullness of parameters should be guaranteed
应保证参数的零值
“Object.finalize()” should remain protected (versus public) when overriding
当覆盖时,“Object.finalize()”应该保持受保护(相对于public)
“java.
“java。
time” classes should be used for dates and times
“时间”类应该用于日期和时间
Null checks should not be used with “instanceof”
空检查不应该与“instanceof”一起使用
The signature of “finalize()” should match that of “Object.finalize()”
“finalize()”的签名应该与“Object.finalize()”的签名匹配。
Mutable members should not be stored or returned directly
不应该存储或直接返回可变成员
“InterruptedException” should not be ignored
不应该忽略“InterruptedException”
Child class fields should not shadow parent class fields
子类字段不应该跟随父类字段
Defined filters should be used
应该使用已定义的过滤器
Mutable fields should not be “public static”
可变字段不应该是“公共静态的”
Persistent entities should not be used as arguments of “@RequestMapping” methods
持久实体不应该用作“@RequestMapping”方法的参数
Catches should be combined
渔获量应合并
Double Brace Initialization should not be used
不应该使用双花括号初始化
Inner class calls to super class methods should be unambiguous
对超类方法的内部类调用应该是明确的
Underscores should be used to make large numbers readable
下划线应该用来使大的数字可读
Ternary operators should not be nested
三元运算符不应该嵌套
Unused local variables should be removed
应该删除未使用的局部变量
InputSteam.read() implementation should not return a signed byte
read()实现不应该返回带符号的字节
Constructor injection should be used instead of field injection
应该使用构造函数注入而不是字段注入
Factory method injection should be used in “@Configuration” classes
工厂方法注入应该在“@Configuration”类中使用
Threads should not be started in constructors
线程不应该在构造函数中启动
“indexOf” checks should not be for positive numbers
“indexOf”检查不应该针对正数
Deserializing with XMLDecoder is security-sensitive
使用XMLDecoder反序列化是安全敏感的
Types should be used in lambdas
类型应该在lambdas中使用
“PreparedStatement” and “ResultSet” methods should be called with valid indices
使用有效的索引调用“PreparedStatement”和“ResultSet”方法
Deprecated “ p o m " p r o p e r t i e s s h o u l d n o t b e u s e d 不 赞 成 使 用 “ {pom}" properties should not be used 不赞成使用“ pom"propertiesshouldnotbeused使{pom}”属性
Inner classes which do not reference their owning classes should be “static”
不引用其所属类的内部类应该是“静态的”
Artifact ids should follow a naming convention
工件id应该遵循命名约定
Floating point numbers should not be tested for equality
不应该对浮点数进行相等性测试
pom elements should be in the recommended order
pom元素应该按照推荐的顺序排列
Redundant modifiers should not be used
不应该使用多余的修饰词
Instance methods should not write to “static” fields
实例方法不应该写入“静态”字段
String offset-based methods should be preferred for finding substrings from offsets
基于字符串偏移量的方法应该是从偏移量中寻找子字符串的首选方法
Dependencies should not have “system” scope
依赖项不应该具有“系统”范围
Boolean literals should not be redundant
布尔文字不应该是多余的
Local variables should not be declared and then immediately returned or thrown
不应该声明局部变量,然后立即返回或抛出
Custom resources should be closed
应该关闭自定义资源
Tests should include assertions
测试应该包括断言
Return of boolean expressions should not be wrapped into an “if-then-else” statement
布尔表达式的返回不应该包装成“if-then-else”语句
Setting JavaBean properties is security-sensitive
设置JavaBean属性是安全敏感的
JUnit assertions should include messages
JUnit断言应该包括消息
Redundant pairs of parentheses should be removed
多余的括号对应该去掉
Unused “private” methods should be removed
应该删除未使用的“私有”方法
Unnecessary imports should be removed
应该删除不必要的导入
“switch” statements should not have too many “case” clauses
“switch”语句不应该有太多的“case”子句
Loggers should be named for their enclosing classes
应该根据它们的封闭类来命名日志记录器
Unit tests should throw exceptions
单元测试应该抛出异常
Unused type parameters should be removed
应该删除未使用的类型参数
Null should not be returned from a “Boolean” method
不应该从“布尔”方法返回Null
Delivering code in production with debug features activated is security-sensitive
使用激活的调试特性交付生产中的代码是安全敏感的
Files opened in append mode should not be used with ObjectOutputStream
在附加模式下打开的文件不应该与ObjectOutputStream一起使用
Assertion arguments should be passed in the correct order
应该按照正确的顺序传递断言参数
Utility classes should not have public constructors
实用程序类不应该有公共构造函数
Wildcard imports should not be used
不应该使用通配符导入
Track uses of disallowed dependencies
跟踪不允许的依赖项的使用
“static” members should be accessed statically
“静态”成员应该被静态访问
Group ids should follow a naming convention
组id应该遵循命名约定
Deserializing objects from an untrusted source is security-sensitive
从不可信源反序列化对象是安全敏感的
Track uses of “NOSONAR” comments
跟踪“NOSONAR”注释的使用
Classes with only “static” methods should not be instantiated
只有“静态”方法的类不应该被实例化
Multiline blocks should be enclosed in curly braces
多行块应该用花括号括起来
“compareTo” results should not be checked for specific values
“compareTo”结果不应该检查特定的值
“Lock” objects should not be “synchronized”
“锁”对象不应该被“同步”
Non-serializable objects should not be stored in “HttpSession” objects
非序列化对象不应该存储在“HttpSession”对象中
“Collections.
”集合。
EMPTY_LIST”, “EMPTY_MAP”, and “EMPTY_SET” should not be used
不应该使用“EMPTY_LIST”、“EMPTY_MAP”和“EMPTY_SET”
Lazy initialization of “static” fields should be “synchronized”
“静态”字段的延迟初始化应该“同步”
Disabling Spring Security’s CSRF protection is security-sensitive
禁用Spring Security的CSRF保护是安全敏感的
Return values from functions without side effects should not be ignored
不应该忽略没有副作用的函数的返回值
Package declaration should match source file directory
包声明应该匹配源文件目录
“.equals()” should not be used to test the values of “Atomic” classes
不应该使用”.equals()"来测试"原子"类的值
“notifyAll” should be used
应该使用“notifyAll”
“private” methods that don’t access instance data should be “static”
不访问实例数据的“私有”方法应该是“静态的”
Blocks should be synchronized on “private final” fields
块应该在“私有final”字段上同步
Cognitive Complexity of methods should not be too high
方法的认知复杂性不应过高
“collect” should be used with “Streams” instead of “list::add”
“collect”应该与“Streams”一起使用,而不是与“list::add”一起使用。
Optional value should only be accessed after calling isPresent()
可选值只能在调用isPresent()后访问
Generic exceptions should never be thrown
永远不应该抛出通用异常
Synchronized classes Vector, Hashtable, Stack and StringBuffer should not be used
不应该使用同步类向量、散列表、堆栈和StringBuffer
Non-serializable classes should not be written
不应该编写不可序列化的类
“Random” objects should be reused
应该重用“随机”对象
Cypher Block Chaining IV’s should be random and unique
Cypher块链接IV应该是随机的和唯一的
Methods should not have too many parameters
方法不应该有太多的参数
Try-catch blocks should not be nested
Try-catch块不应该嵌套
Using setters in Struts 2 ActionSupport is security-sensitive
在struts2 ActionSupport中使用setter是安全敏感的
Increment (++) and decrement (–) operators should not be used in a method call or mixed with other operators in an expression
递增(++)和递减(——)运算符不应在方法调用中使用,也不应与表达式中的其他运算符混合使用
Invalid “Date” values should not be used
不应该使用无效的“Date”值
Methods should not have too many return statements
方法不应该有太多的返回语句
Non-public methods should not be “@Transactional”
非公共方法不应该是“@Transactional”
Jump statements should not occur in “finally” blocks
跳转语句不应该出现在“finally”块中
“URL.
”URL。
hashCode” and “URL.
hashCode”和“URL。
equals” should be avoided
应该避免平等
A “while” loop should be used instead of a “for” loop
应该使用“while”循环而不是“for”循环
Nested blocks of code should not be left empty
嵌套的代码块不应该是空的
Using Struts 1 ActionForm is security-sensitive
使用struts1 ActionForm是安全敏感的
“ResultSet.isLast()” should not be used
不应该使用“ResultSet.isLast()”
“BigDecimal(double)” should not be used
不应该使用“BigDecimal(double)”
Lines should not be too long
队伍不要太长
Useless “if(true) {…
无用的“如果(真正的){…
}” and “if(false){…
}”和“如果(false) {…
}” blocks should be removed
}“块应该被移除
Collections should not be passed as arguments to their own methods
集合不应该作为参数传递给它们自己的方法
IllegalMonitorStateException should not be caught
不应该捕获非法的monitorstateexception
Parameters should be passed in the correct order
参数应该按照正确的顺序传递
Tabulation characters should not be used
不应该使用列表字符
Exit methods should not be called
不应调用退出方法
“hashCode” and “toString” should not be called on array instances
不应该在数组实例上调用“hashCode”和“toString”
Files should not have too many lines of code
文件不应该有太多的代码行
Throwable.printStackTrace(…) should not be called
printstacktrace(…)不应该被调用
Methods “wait(…)”
方法”等(…)”
, “notify()” and “notifyAll()” should not be called on Thread instances
,“notify()”和“notifyAll()”不应该在线程实例上调用
Track uses of disallowed classes
跟踪不允许的类的使用
Databases should be password-protected
数据库应该有密码保护
Control structures should use curly braces
控件结构应该使用花括号
Package names should comply with a naming convention
包的名称应该符合命名约定
Statements should be on separate lines
语句应该在单独的行上
Limited dependence should be placed on operator precedence
对运算符优先级的依赖是有限的
“SingleConnectionFactory” instances should be set to “reconnectOnException”
“SingleConnectionFactory”实例应该设置为“reconnectOnException”
Value-based objects should not be serialized
不应该序列化基于值的对象
Reflection should not be used to check non-runtime annotations
不应该使用反射来检查非运行时注释
Methods should not call same-class methods with incompatible “@Transactional” values
方法不应该调用具有不兼容的“@Transactional”值的同类方法
“DefaultMessageListenerContainer” instances should not drop messages during restarts
“DefaultMessageListenerContainer”实例在重启期间不应该删除消息
Abstract class names should comply with a naming convention
抽象类名应该遵循命名约定
Conditionally executed blocks should be reachable
应该可以访问有条件执行的块
Overrides should match their parent class methods in synchronization
重写应该同步匹配它们的父类方法
Local variable and method parameter names should comply with a naming convention
局部变量和方法参数的名称应该符合命名约定
Strings literals should be placed on the left side when checking for equality
当检查是否相等时,字符串文字应该放在左边
Locks should be released
应该释放锁
“Optional” should not be used for parameters
“可选”不应用于参数
Type parameter names should comply with a naming convention
类型参数名称应该符合命名约定
Deprecated code should be removed
应该删除不赞成的代码
“Exception” should not be caught when not required by called methods
当被调用的方法不需要时,不应该捕获“异常”
Interface names should comply with a naming convention
接口名称应该符合命名约定
Track uses of “FIXME” tags
跟踪“FIXME”标签的使用
“default” clauses should be last
“违约”条款应该排在最后
Files should contain an empty newline at the end
文件末尾应该包含一个空的换行符
Track uses of “TODO” tags
跟踪“TODO”标签的使用
Field names should comply with a naming convention
字段名应该符合命名约定
Servlets should not have mutable instance fields
servlet不应该有可变的实例字段
Value-based classes should not be used for locking
基于值的类不应该用于锁定
Boolean expressions should not be gratuitous
布尔表达式不应该是免费的
Constant names should comply with a naming convention
常量名称应该符合命名约定
“toString()” and “clone()” methods should not return null
"toString()"和"clone()"方法不应返回空值
Classes and enums with private members should have a constructor
具有私有成员的类和枚举应该有一个构造函数

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值