Cloud Manager code quality · Java code rules (SonarQube) · updated

CQRules:CQBP-71: Avoid hardcoded apps and libs paths

CQBP-71 fires when Java code uses an absolute /apps/... or /libs/... path, such as isResourceType("/libs/foundation/components/text"). Use the relative form (foundation/components/text) so Sling resolves it through its search path and overlays keep working.

Rule keyCQRules:CQBP-71
Adobe's rule nameAvoid hardcoded apps and libs paths
TypeCode Smell
SeverityMinor
Since2018.4.0
Checked bySonarQube analysis of your Java code

Why Cloud Manager flags it

Sling's resource resolver searches /apps first and /libs second. A relative resource type therefore picks up your overlay in /apps when one exists and the product version otherwise. An absolute /libs path skips the overlay; an absolute /apps path breaks when the component lives in /libs. On AEM as a Cloud Service, Adobe updates /libs continuously, so code that pins exact /libs paths is more likely to break after an automatic update.

The rule also catches comparisons of sling:resourceType values. Stored resource types are normally relative already, so comparing them against an absolute string silently returns false, which is a real bug, not just style.

Common cases and fixes

FoundReplace with
"/apps/myco/components/teaser""myco/components/teaser"
"/libs/foundation/components/text""foundation/components/text" (and plan the Core Components move)
"/libs/wcm/foundation/components/page""wcm/foundation/components/page"
String building "/apps/" + typeUse the type as stored; call ResourceResolver.isResourceType()

Example

Non-compliant (as in Adobe's example)

if (resource.isResourceType("/libs/foundation/components/text")) { ... }

Compliant

if (resource.isResourceType("foundation/components/text")) { ... }

How to fix it

  1. Search Java and HTL for string literals starting with /apps/ or /libs/.
  2. Strip the prefix for resource types; for real repository paths (for example a configuration node) read them from an OSGi configuration or a context-aware configuration.
  3. Prefer ResourceResolver.isResourceType(), which also follows sling:resourceSuperType inheritance.
  4. If the type is a Foundation component, note it for the Core Components migration (see LegacyFoundationComponentUsage).

Does it stop the pipeline?

Code smells feed the Maintainability Rating, which is based on the total estimated fix time as a share of development time, not on any single finding. One finding rarely moves it, but hundreds can push the rating below A, which is an important failure: the pipeline pauses until someone overrides or fixes it.

If a finding is a genuine false positive, Adobe's code quality page lets you annotate the code with @SuppressWarnings and the rule ID. In a full-stack pipeline, important failures can be overridden by a deployment manager, project manager or business lead; in a code-quality-only pipeline they cannot.

Questions

Does this rule apply to HTL files?

Adobe's rule is a SonarQube Java rule, so it reports Java. Absolute paths in HTL data-sly-resource attributes cause the same overlay problem and are worth fixing at the same time.

Is /conf also flagged?

No, the rule is about /apps and /libs. /conf paths are better read through context-aware configuration anyway.

Is it safe to bulk-replace?

For resource-type strings, yes. For paths used to read nodes directly, check each one: some really are repository locations and should move to configuration.

See the Cloud Service blockers in your code before Cloud Manager shows them. The free Surge Migrate readiness scan reads a repository zip or a Best Practices Analyzer CSV in your browser and lists them with file, fix and effort. Nothing is uploaded.

Sources

Rule key, type, severity and version are as listed on Adobe's page, checked 10 Nov 2026. Explanations and examples are ours unless marked as Adobe's.

Scan, Convert, Verify, Install

How Surge Migrate helps with a move to AEM as a Cloud Service

Surge Migrate moves a website from any CMS to any CMS, and AEM as a Cloud Service is one of the systems it writes. Pages are converted automatically, and you check the result before you install anything.

  1. 1

    Scan

    Names the system behind your site, counts pages and templates, lists the blocks to build and the work no tool does, and gives an effort range with its working.

    Scan a site →
  2. 2

    Convert

    Each page becomes an Edge Delivery document, an AEM Core Component page and import files for 7 other systems. 10 pages free; 500 or 2,000 pages in one paid run.

    Convert your pages →
  3. 3

    Verify

    A download is offered only when its own format check passes. The report lists every field not found and every component kept as plain content. Compare old and new pages side by side.

    Parity check →
  4. 4

    Install

    You import with the target system's own tool, on your own environment. Each download's README gives the command. Your system changes only when you run it.

    How each import was tested →

Content packages installed on a local AEM as a Cloud Service SDK. See the worked examples.

On AEM 6.5 code: Scan AEM 6.5 code free. The scan reads a repository zip or a Best Practices Analyzer CSV in your browser and lists Cloud Service blockers with file, fix and effort. Nothing is uploaded.