adobe / aem-core-wcm-components

Standardized components to build websites with AEM.
https://docs.adobe.com/content/help/en/experience-manager-core-components/using/introduction.html
Apache License 2.0
723 stars 737 forks source link

[Issue #2776] Don't ever initialize a com.adobe.cq.wcm.core.components.models.Component instance to retrieve an ID #2777

Open paulochang opened 3 weeks ago

paulochang commented 3 weeks ago
Q                       A
Fixed Issues? Fixes #2776
Patch: Bug Fix? 👍
Minor: New Feature? No
Major: Breaking Change? No
Tests Added + Pass? No (Existing tests are enough)
Documentation Provided No (Existing docs are enough)
Any Dependency Changes? No
License Apache License, Version 2.0

I have replaced all the initialization and calls to the general Component model with a call to the specific component model for each model.

Example:

Given the existing Button HTL code

<button data-sly-use.button="com.adobe.cq.wcm.core.components.models.Button"
        data-sly-use.component="com.adobe.cq.wcm.core.components.models.Component"
        ....
        id="${component.id}"

I have done a replacement with the following code instead

<button data-sly-use.button="com.adobe.cq.wcm.core.components.models.Button"
        ...
        id="${button.id}"
sonarcloud[bot] commented 3 weeks ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud