SONARJAVA-6828 Add AGENTS.md to provide guidance to agents making changes to rules - #5993
Conversation
There was a problem hiding this comment.
I found three correctness issues in the agent guidance that can directly lead to non-compiling rules or failing tests. I also left a non-blocking suggestion to point the auto-loaded guide at the existing new-rule skill, which contains required metadata-generation and test-dependency guidance absent here.
| The file general structure for a rule implementation and its tests is as follows: | ||
| - Rule class: `java-checks/src/main/java/org/sonar/java/checks/{RuleId}Check.java` | ||
| - Test class: `java-checks/src/test/java/org/sonar/java/checks/{RuleId}CheckTest.java` | ||
| - Test samples: `java-checks-test-sources/default/src/main/files/checks/{RuleId}CheckSample.java` |
There was a problem hiding this comment.
The normal-sample path is invalid. java-checks-test-sources/default/src/main/files/ contains only non-compiling; normal samples live under src/main/java/checks/ and should be loaded with TestUtils.mainCodeSourcesPath("checks/{RuleId}CheckSample.java"). This also contradicts the legacy src/test/files example below. Please update both the documented convention and the example. The same incorrect normal-sample path is duplicated in .claude/skills/new-rule/SKILL.md:75.
- Fix non-existent TreeUtils.firstAncestorOfKind to ExpressionUtils.getParentOfType - Add missing nodesToVisit() override in DependencyVersionAware example - Fix test sample path from files/checks/ to java/checks/ - Update test example to use TestUtils.mainCodeSourcesPath() - Add pointer to .claude/skills/new-rule/SKILL.md for metadata guidance Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The path used `main/files/checks/` instead of `main/java/checks/` for the normal test sample location. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Code Review ✅ Approved 1 resolved / 1 findingsAdds AGENTS.md guidelines and rules for agents modifying the repository, addressing the test sample path convention contradiction. No issues found. ✅ 1 resolved✅ Quality: Test sample path convention contradicts the example
OptionsAuto-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 |
|





This is to help being more efficient when creating new rules.