AEMaaCS Code Scanning Issues - Open Issues - Use Interface com.day.cq.wcm.api.NameConstant - Use predefined constant instead of hardcoded value. | Community
Skip to main content
Rohan_Garg
New Participant
November 14, 2022
Solved

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

  • November 14, 2022
  • 1 reply
  • 754 views

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 -

 

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).

 

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

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

arunpatidar
arunpatidarAccepted solution
New Participant
November 14, 2022
Rohan_Garg
New Participant
November 14, 2022

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!