SonarQube Edition / Version : Developer / 2025.1 LTA
In our project, We are using the @emotion/react library for styling, which allows us to apply styles directly using the css attribute on HTML elements. However, SonarQube is flagging this as a code smell with the message: “Unknown property ‘css’ found”.
Currently, we have to mark it as a false positive every time we push code, which is not ideal.
One possible approach of handling this, is to Disable the Rule that raised this Code Smell issue. However, we are concerned that disabling it might hide other genuine issues.
Apart from completely disabling the rule, is there any other effective way to handle this case so that Emotion’s css attribute is recognised and not flagged as an issue?
If you want to exclude specific property or attribute names from this rule in SonarQube, you can add exceptions directly within your Quality Profile settings. To do this, navigate to the relevant rule in your custom Quality Profile and click “Change”
Please note, making changes like this requires you to use a custom Quality Profile rather than the default ‘Sonar way’ profile. If you’re already using a custom Quality Profile, you can update it as needed. If you’re still using the default, you’ll need to create a custom Quality Profile (probably by extending the built-in QP)