RC-350 Unify ruling expectation file locations. - #7922
Conversation
This comment has been minimized.
This comment has been minimized.
Move ruling expectation files from its/ruling/src/test/expected/<project>/<language>-<ruleId>.json to its/ruling/src/test/resources/expected/<language>/<project>/<ruleId>.json This makes the layout consistent across analyzers. The Java ruling test (LITS-based) reconstructs the flat per-project directory that LITS expects at build time under target/expected/. The JS/TS ruling pipeline (lits.ts) and the CI ruling bot scripts are updated to read and write the new structure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ge>-<rule>.json Move expectation files from the language-first hierarchy (expected/<language>/<project>/<rule>.json) to a flat per-project structure (expected/<project>/<language>-<rule>.json). Simplify RulingTest.java by removing the mergeExpectedDir step, and testProject.ts by replacing compareByLanguage with a direct directory comparison. Replace syncTransposed in sync-results.mjs with a simple mirrorDirectory that copies the flat layout as-is. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
842d4d7 to
f0097bb
Compare
The mergeExpectedDir step was removed, so target/expected no longer exists. The diff command should compare against target/actual instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The earlier commit flattened expected ruling files to <project>/<language>-<rule>.json but several components still used the old nested <project>/<language>/<rule>.json layout: - lits.ts writeIssues: remove per-language subdirectory, write flat filenames - lits.test.ts: update assertions to read from flat paths - generate-report.mjs: parse 2-segment paths (<project>/<lang>-<rule>.json) instead of 3-segment (<language>/<project>/<rule>.json) - SKILL.md: update expected path documentation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
✅ All code review findings resolved.
guillemsarda
left a comment
There was a problem hiding this comment.
Approving with 2 minor concerns.
| @@ -32,7 +32,7 @@ sh tools/ruling-debug-script.sh | |||
| Results: | |||
There was a problem hiding this comment.
For file packages/ruling/lits.ts:
Could we keep creating actualPath unconditionally in writeResults()? With mkdir inside writeIssues(), a project that produces zero issues (including parsing errors) leaves no actual-results directory, so dir-compare throws ENOENT instead of comparing the results. This doesn't affect the current projects, but could affect a future zero-issue project even if its expected directory exists. Keeping the directory creation here and adding an empty-results test would cover that edge case.
| @@ -44,13 +44,13 @@ mvn verify -Dtest=RulingTest -Dmaven.test.redirectTestOutputToFile=false | |||
| Copy actual to expected: | |||
There was a problem hiding this comment.
Could we keep target/actual/ as the source in the copy command and as the comparison directory in the diff command? RulingTest.java (lines 280-282) still sets sonar.lits.dump.new to target/actual/<project>, so changing these instructions to target/expected makes them point to the wrong output directory. Only the baseline path needs to change to src/test/resources/expected/.
There was a problem hiding this comment.
That's not changed by this PR, it was already packages/ruling/actual before, and it is still what the github action use to update the ruling expectations.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prompt: "address review comment: keep creating actualPath unconditionally in writeResults() so a zero-issue project doesn't cause dir-compare ENOENT, and add a test for that edge case" Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Code Review ✅ Approved 10 closed / 10 findings🟡 Medium risk · Ruling infrastructure changes paths, report parsing, and CI synchronization behavior. Refactors ruling expectation file locations to a unified flat layout across JS/TS and Java analyzers. Resolved 10 issues including path handling in comparison logic, documentation updates, build-time directory merging, CI script synchronization, and report parsing to align with the new ✅ 10 closed✅ Bug: compareByLanguage crashes with ENOENT when one side is missing
✅ Bug: ruling-debug-script.sh diffs mismatched layouts, prints nothing
✅ Bug: Docs tell you to copy target/expected back over the expectations
✅ Bug: mergeExpectedDir keeps stale files from previous runs
✅ Quality: Stray consecutive blank lines will fail check-format
...and 5 more closed from earlier reviews Review coverage🧪 Functional validation No results 📋 Rules No rules evaluated 🤖 Auto-approval Not enabled · Set up 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 |
|





Summary
its/ruling/src/test/expected/<project>/<language>-<ruleId>.jsontoits/ruling/src/test/resources/expected/<project>/<ruleId>.jsonlits.ts,testProject.ts) to write and compare results using the new layoutsync-results.mjs,generate-report.mjs,build.yml) to use the new pathsMotivation
Normalize ruling expectation file locations so that it is consistent across all analyzers.
Test plan
npm run ruling)mvn test -Dtest=RulingTest)lits.test.tsunit tests pass🤖 Generated with Claude Code
Agent workflow
Tool link: Tool link: https://github.com/SonarSource/languages-experimental-tooling/tree/romain/my-tickets/personal/romain-brenguier
Iterated on the PR with
uv run ci_loop.pyfor 3 iterations.✔️ The PR is now ready for review.