Expand my Community achievements bar.

SOLVED

AEMaaCS Code Scanning Issues - Open Issues - Use Interface com.day.cq.wcm.api.NameConstant - Use predefined constant instead of hardcoded value.

Avatar

Community Advisor

Hi AEM Community,

 

When running a cloud deployment, We are getting the number of open issues to be numbered 5 as shown below -

 

Issue
Use constant NN_TEMPLATE from interface com.day.cq.wcm.api.NameConstants instead of hardcoded value.

 

Rule
AEM Rules:AEM-2

 

As per documentation link - https://github.com/wttech/AEM-Rules-for-SonarQube#good-practices

  • AEM-2 Use predefined constant instead of hardcoded value.

    • Use constants available in AEM instead of repeating inline literals.

The issue is reported because of the below - We are declaring cq:template as a constant in our Constants file separately while it is available out of the box in the above mentioned interface.

public static final String CQ_TEMPLATE = "cq:template";

 

However, when using the interface NameConstants as suggested, The IDE reports the below -

Rohan_Garg_1-1668411556705.png

Rohan_Garg_3-1668412143971.png

 

The below interface is thus suggested.

import com.day.cq.wcm.api.constants.NameConstants;

However, this interface is not being resolved by the IDE (IntelliJ).

Rohan_Garg_2-1668411875473.png

 

How can we resolve this minor code smell issue when the suggested interface is deprecated ?

@arunpatidar, @Mohit_KBansal, @kautuk_sahni, @B_Sravan, @Theo_Pendle 

 

Thanks,

Rohan Garg

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
2 Replies

Avatar

Correct answer by
Community Advisor

Avatar

Community Advisor

Hey @arunpatidar - Thanks for your response, it's weird though - even with the AEM extension enabled in IntelliJ it highlights as an issue.

But as you suggested with the build and deployment the original interface is working correctly.
Should have given a build first I guess but anyways thanks a lot for confirming!