jhipster / prettier-java

Prettier Java Plugin
http://www.jhipster.tech/prettier-java/
Apache License 2.0
1.06k stars 103 forks source link

checkstyle RightCurly not correct when there are comments #637

Open xenoterracide opened 5 months ago

xenoterracide commented 5 months ago
/CustomerAuditServiceImpl.java:441:9: '}' at column 9 should be on the same line as the next part of a multi-block statement (one that directly contains multiple blocks: if/else-if/else, do/while or try/catch/finally). [RightCurly]

Prettier-Java 2.5.0

Input:

I apologize, this hot mess is so long, but I'm wondering if that's part of what's causing the problem. I added a violation in the code here.

        if (
            isAddNode &&
            (NODE_CARD.equalsIgnoreCase(nodeLabel) ||
                NODE_PERSON.equalsIgnoreCase(nodeLabel) ||
                NODE_ADDRESS.equalsIgnoreCase(nodeLabel) ||
                NODE_PHONE.equalsIgnoreCase(nodeLabel) ||
                NODE_HOUSEHOLD.equalsIgnoreCase(nodeLabel))
        ) {
        } else if (isNodePropChange && !StringUtils.isEmpty(getPropertiesAsString(audit))) {
            String propString = getPropertiesAsString(audit);
            String keyNumber = ignoreUuids(primaryKey);
            responseString = String.format("Change to POSID: %s - %s", keyNumber, propString);
        }
        // Attributes (which are relations)
        else if (isAddRelation && isAttributeType) { // ** VIOLATION **
            // TX Template: SetLoyaltyAttribute_A
            // Seems like this will also handle Un/Enroll Customer and NationalRewards
            String attrName = getAttributeName(audit);
            responseString = String.format("Attribute %s added with value %s", attrName, propValue);
        } else if (isChangeRelation && isAttributeType) {

Expected behavior:

...

I'm not sure this is wrong per prettier, but I don't see a way to fix per checkstyle either. Please leave open until one or the other can be resolved.

jtkiesel commented 4 months ago

Prettier JavaScript keeps the comment in this position (example), so I don't think we will change the formatting of this. We could potentially update the Checkstyle configuration that we provide.