You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plugins/dx-aem/skills/aem-doctor/SKILL.md
+36-4Lines changed: 36 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
name: aem-doctor
3
3
description: Check health of AEM project infrastructure — verifies component definitions, OSGi configs, dispatcher rules, and content structure against expected state. Use to diagnose configuration drift or after making infrastructure changes.
@@ -115,6 +116,27 @@ If `aem.frontend-dir` is configured:
115
116
- For each brand in `aem.brands`, verify brand-specific overrides directory exists
116
117
- Check for orphaned brand files (brand override without a base component)
117
118
119
+
### 3f. Code Anti-Pattern Scan
120
+
121
+
Scan Java source files for patterns that cause issues in AEM as a Cloud Service. Each check is a targeted grep — report matches with file and line number.
122
+
123
+
**Detect via grep patterns** in project Java source (`**/core/**/src/main/**/*.java`):
124
+
125
+
| Anti-Pattern | Grep Pattern | Severity |
126
+
|---|---|---|
127
+
| Scheduler API (runs on all cluster instances) |`implements Runnable` in files with `Scheduler.PROPERTY_SCHEDULER`| ⚠ warn |
| Mutable state in OSGi service |`@Component` class with non-final `private.*Map\|List\|Set\|int\|long\|boolean` fields that aren't `@Reference`/`@Inject`/`@OSGiService`/`@ValueMapValue`| ⚠ warn |
| Hardcoded AEM paths | String literals matching `/content/dam/`, `/content/` followed by a specific site name, or `/apps/`| ⚠ warn |
135
+
| JCR Session direct access |`.adaptTo(Session.class)` outside test files | ⚠ warn |
136
+
| Absolute resource type in HTL |`resourceType='/apps/` in `*.html` files | ⚠ warn |
137
+
138
+
**How to scan:** Run greps in parallel. For each hit, report the file path and line. Skip test files (`**/test/**`) for all checks except the HTL check. Keep output concise — list up to 5 matches per pattern, then `+N more`.
139
+
118
140
## 4. Print Results
119
141
120
142
Use this exact format with status indicators:
@@ -161,6 +183,14 @@ Component coverage ✓ N/M have FE files
1.`/aem-doctor` — Runs all health checks: verifies 45 component definitions match source XML, validates OSGi configs exist, checks dispatcher rules for proper cache headers, and confirms content structure paths are accessible. Reports 2 warnings (missing dispatcher rule, stale OSGi config) and 0 errors.
219
+
1.`/aem-doctor` — Runs all health checks: verifies 45 component definitions match source XML, validates OSGi configs exist, checks dispatcher rules for proper cache headers, confirms content structure paths are accessible, and scans Java code for anti-patterns. Reports 2 warnings (missing dispatcher rule, stale OSGi config) and 0 errors.
220
+
221
+
2.`/aem-doctor code` — Runs only the code anti-pattern scan. Greps Java source for deprecated APIs, static ResourceResolvers, path-bound servlets, and other Cloud Service anti-patterns. Reports 1 warning (deprecated SCR annotation in LegacyService.java) and 0 errors.
190
222
191
-
2.`/aem-doctor` (AEM not running) — Checks local file structure (component definitions, OSGi configs, dispatcher rules) successfully. Skips AEM instance checks with warning: "AEM not reachable at http://localhost:4502. Skipping instance checks." Reports local-only results.
223
+
3.`/aem-doctor` (AEM not running) — Checks local file structure (component definitions, OSGi configs, dispatcher rules) and code anti-patterns successfully. Skips AEM instance checks with warning: "AEM not reachable at http://localhost:4502. Skipping instance checks." Reports local-only results.
192
224
193
-
3.`/aem-doctor` (after failed deployment) — Detects 3 errors: component dialog XML has invalid field type, OSGi config references non-existent PID, and content path returns 404. Each error includes the file path and suggested fix action.
225
+
4.`/aem-doctor` (after failed deployment) — Detects 3 errors: component dialog XML has invalid field type, OSGi config references non-existent PID, and content path returns 404. Each error includes the file path and suggested fix action.
0 commit comments