如何使代码符合:移动此变量以符合 Java 代码约定
How to make the code compliant with: Move this variable to comply with Java Code Conventions
我有以下 class:
public final class AppConst {
private AppConst() {}
public static final String READ_ERROR = "READ";
public static final String PROCESS_ERROR = "PROCESS";
public static final String WRITE_ERROR = "WRITE";
}
SonarQube 使用以下变量在所有三行上标记错误:
Move this variable to comply with Java Code Conventions.
如何让代码兼容SonarQube?
我正在使用 SonarLint for Eclipse v2.6.0。
问题是由 RSPEC-1213 The members of an interface or class declaration should appear in a pre-defined order 规则发现的。描述说:
According to the Java Code Conventions as defined by Oracle, the members of a class or interface declaration should appear in the following order in the source files:
- Class and instance variables
- Constructors
- Methods
您的代码在变量之前包含一个构造函数。有效代码:
public final class AppConst {
public static final String READ_ERROR = "READ";
public static final String PROCESS_ERROR = "PROCESS";
public static final String WRITE_ERROR = "WRITE";
private AppConst() {}
}
我有以下 class:
public final class AppConst {
private AppConst() {}
public static final String READ_ERROR = "READ";
public static final String PROCESS_ERROR = "PROCESS";
public static final String WRITE_ERROR = "WRITE";
}
SonarQube 使用以下变量在所有三行上标记错误:
Move this variable to comply with Java Code Conventions.
如何让代码兼容SonarQube?
我正在使用 SonarLint for Eclipse v2.6.0。
问题是由 RSPEC-1213 The members of an interface or class declaration should appear in a pre-defined order 规则发现的。描述说:
According to the Java Code Conventions as defined by Oracle, the members of a class or interface declaration should appear in the following order in the source files:
- Class and instance variables
- Constructors
- Methods
您的代码在变量之前包含一个构造函数。有效代码:
public final class AppConst {
public static final String READ_ERROR = "READ";
public static final String PROCESS_ERROR = "PROCESS";
public static final String WRITE_ERROR = "WRITE";
private AppConst() {}
}