원클릭으로
java-quality
Java code quality standards and best practices for CPS project.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Java code quality standards and best practices for CPS project.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | java-quality |
| description | Java code quality standards and best practices for CPS project. |
This skill ensures Java code follows CPS (Configuration Persistence Service) quality standards and best practices.
Simple is Good, Complex is Bad - Always prefer simple, readable code over complex patterns. When choosing between solutions, select the one that is easiest to understand and maintain.
// Bad: CmHandleState state = new CmHandleState(..);
// Good: CmHandleState cmHandleState = new CmHandleState(..);
// Good:
int orderNumber = 123;
String status = getStatus(orderNumber);
String getStatus(int orderNumber) { ... }
// Bad:
final static String HELLO = "Hello ";
String message = HELLO + name;
// Good:
String message = "Hello " + name;
// Or better:
String sayHello(final String name) {
return "Hello " + name;
}
// Bad: if (xpath.equals(ROOT_NODE_PATH) {..}
// Good: if (ROOT_NODE_PATH.equals(xpath) {..}
Avoid using ! (negation) or != ONLY when an else block is implemented - invert the condition:
// Bad (has else block):
if (x != null) {
do something;
} else {
report error;
}
// Good:
if (x == null) {
report error;
} else {
do something;
}
Note: This rule does NOT apply when there's no else block. Simple guard clauses are acceptable:
// Acceptable (no else block):
if (x != null) {
throw new Exception("error");
}
No need for else after return:
// Bad:
if (ROOT_NODE_PATH.equals(xpath) {
return something;
} else {
return somethingElse;
}
// Good:
if (x == true) {
return something;
}
return something-else;
No need to check isEmpty before iterating:
// Bad:
if (!myCollection.isEmpty()) {
collection.forEach(some action);
}
// Good:
collection.forEach(some action);
Initialize collections/arrays with known size:
// Bad:
void processNames(Collection<String> orginalNames) {
String[] processedNames = new String[0];
// Good:
void processNames(Collection<String> orginalNames) {
String[] processedNames = new String[orginalNames.size()];
// Bad: String.format("cm-handle:%s", cmHandleId);
// Good: "cm-handle:" + cmHandleId;
@Service when a class includes operations@Component when it is a data object only// Bad (complex):
Optional<String> optionalResponseBody =
Optional.ofNullable(responseEntity.getBody())
.filter(Predicate.not(String::isBlank));
return (optionalResponseBody.isPresent()) ?
convert(optionalResponseBody.get()) : Collections.emptyList();
// Good (simple):
String responseBody = responseEntity.getBody();
if (responseBody == null || responseBody.isBlank()) {
return Collections.emptyList();
}
return convert(responseBody);
Follow the ONAP commit message guidelines
When reviewing or writing Java code: