Commit 6889f5b
authored
fix(sonar): move the rule exemptions to where they take effect (#881)
Closes #880.
## What the issue asked, and what turned out to be true
#880 offered two ways out: withdraw `e1`/`e2`, or move them where they
would work. Investigating which showed a third fact that settles it —
**the project settings already carried a
`sonar.issue.ignore.multicriteria` entry**, and it had been working the
whole time:
```json
{"resourceKey": "**/Tests/**", "ruleKey": "php:S1313"}
```
So the mechanism is not unavailable. Only its location was wrong.
Withdrawing the two entries would have thrown away a decision someone
made on purpose; moving them keeps it and makes it real.
## The change
`e1` and `e2` moved verbatim into the project settings, with the
pre-existing entry carried through rather than overwritten:
```json
{"resourceKey": "**/Tests/**", "ruleKey": "php:S1313"}
{"resourceKey": "Classes/Domain/Model/**", "ruleKey": "php:S1448"}
{"resourceKey": "Tests/**", "ruleKey": "php:S5332"}
```
Read back after writing, because a `204` says the request was accepted,
not that the field landed.
The block in `.sonarcloud.properties` is replaced by a comment that says
where the exemptions live, how to read them back, and — the part that
matters for the next person — **which kind of finding belongs where**:
- a **one-off** intentional finding is marked *Won't Fix* on the issue
itself, with the reason as a comment;
- a **rule-level** exemption, which will fire again on a file nobody has
written yet, goes into settings.
What stays in the file is what the file can actually do:
`sonar.exclusions` and `sonar.cpd.exclusions`. Both are honoured —
adding `Resources/Private/Demo/**` to the second one in #879 removed a
34.8% duplication condition from that pull request's gate, which is the
measurement this whole distinction rests on.
## Why the block was worse than nothing
It read as an applied decision. `e2` exempted `php:S5332` under `Tests/`
and its comment named `Tests/Unit/Service/Skill/GitHubClientTest.php` as
the reason — and that exact file kept reporting that exact rule on
`main`. Anyone reading the file would have concluded the rule was
handled.
#879 came within one commit of adding three more entries to it, on the
same assumption. They were withdrawn only because they were tested.
_Assisted by claude-code:claude-opus-5 —
[Session](https://claude.ai/code/session_01MNg1MysJVugv1xo2husknU)_1 file changed
Lines changed: 23 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
48 | 45 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
54 | 50 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
0 commit comments