Does Sonar run all rules for new code?

Do SonarCloud scans for new code (Pull Request) check all rules in every scan? Or are rules checked conditionally, based on what code changes are included?

if rules are applied conditionally, can they affect other code areas?

We experience a weird behavior that could maybe be explained by this:
(this is just one example, but it happens in many different code areas, with various bug/smell types)

PR (with sonar scan) from branch A to B introduces a bug: Duplicate key ‘components’ (SonarQube (JavaScript)) to .vue file. Bug is NOT detected by Sonar scan (we identified it while investigating afterwards). PR completes without issues.
PR from branch B to C (containing changes from A and many more branches) - Sonar scan complains about Duplicate key ‘components’ bug. This bug must have been detected and fixed in first PR, why do we see it in the second one instead?

Our theory is, that if rules are applied conditionally - first PR did not trigger ruleset which contained * Duplicate key ‘components’*. changes in other PRs to B introduced more types of code and therefore more rules applied. Therefore PR from B to C now contains ‘new code’ with more rules applied. Can this be the case?

Anyone can confirm this theory or point us to the right direction to get this scenario resolved?

Hello @aba ,

The ruleset should be the same for both PR’s so this sounds really strange. Would it be possible for you to extract this into a reproducible example? That would make it easier for us to debug.