Repository navigation
SONARJAVA-7180 Tighten new-rule skill on samples, tests and implementation - #6337
Conversation
Code Review ✅ Approved 4 closed / 4 findings🟡 Medium risk · The new-rule skill mandates stateless checks and stricter matcher/test patterns, which could shape future rule implementations; impact is confined to rule-authoring guidance. Tightens ✅ 4 closed✅ Bug: Arrays.fill caret example is misaligned; markers miss their tokens
✅ Quality: Stateless-check rule contradicts AGENTS.md per-file state guidance
✅ Edge Case: Stateless rule forbids @RuleProperty parameter fields
✅ Quality: PR description promises createCheckVerifier() factory; doc uses constants
VerificationFunctional validation No results Rules No rules evaluated Auto-approval Not enabledOptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|





Follow-up to #6315, additions to
.agents/skills/new-rule/SKILL.md.Test sample location markers — every primary and secondary location must now be asserted with caret markers, not a bare
// Noncompliant. Documents the caret syntax, the</>direction markers for secondaries, multiple locations on one caret line, and limits[[sc=…;ec=…]]to the cases where carets cannot work.Test class structure — requires extracting the sample path and the check instance into constants so neither is repeated across test methods. The verifier chain stays inline in each test.
Method and type matching — makes
MethodMatchersand the type API mandatory, forbids raw string comparisons on FQNs or method names, and prefers explicitaddParametersMatcheroverwithAnyParameters.Stateless checks — a check class may only declare
private static finalfields. Sets, maps, counters and lookup tables must be local and passed through the call graph. Carve-outs for the fields the API imposes:@RulePropertyparameters, theJavaFileScannerContextof aBaseTreeVisitorrule, andDependencyVersionAwareflags.AGENTS.mdis updated so itsclearState()section is scoped to existing stateful checks.