بنقرة واحدة
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: