> ⚠️ **Why `/BlockStatement//`?** ForEachStatement has the iterable SOQL as a direct child alongside BlockStatement. Without scoping to `/BlockStatement//`, the XPath also matches `for (Contact c : [SELECT...])` — a valid Apex idiom that is NOT a governor limit risk.
---
## Example 3: Enforce @IsTest(testFor) Annotation
**Problem:** Test classes should specify which class they test for traceability.
(GitHub issue #2008 — real community request)
**Sample violating code:**
```apex
@IsTest
public class MyServiceTest {
// Missing testFor parameter
}
```
**AST nodes:**
```xml
<UserClassImage='MyServiceTest'>
<ModifierNodeTest='true'>
<AnnotationImage='IsTest'>
<!-- No AnnotationParameter with Name='testFor' -->
</Annotation>
</ModifierNode>
```
**XPath:**
```xpath
/ApexFile/UserClass/ModifierNode/Annotation[
@Image='IsTest'
and count(AnnotationParameter[@Name='testFor']) = 0
]
```
---
## Example 4: DML Operations Without Try-Catch
**Problem:** Unhandled DML exceptions cause runtime failures.
(GitHub issue #738 — user requested "detect missing try-catch")
**Sample violating code:**
```apex
public class AccountService {
public void createAccount(String name) {
Account acc = new Account(Name = name);
insert acc; // No try-catch!
}
}
```
**AST nodes:**
```xml
<DmlInsertStatement>
<VariableExpressionImage='acc'/>
</DmlInsertStatement>
<!-- No TryCatchFinallyBlockStatement ancestor -->
**Problem:** Classes in API versions 66.0 and below without sharing default to "without sharing" — security risk. If the API version is 67.0 or higher, the below example does not apply.