We’re using SonarCloud.
A bug is reported based on the rule
Image, area and button with image tags should have an "alt" attribute. The code that causes this bug, is using Angular’s optional attribute binding, using:
This angular syntax allows to create an
alt attribute only if there’s a value available. If the content doesn’t have a value for the alt message, angular will not create the alt attribute at all. If we would use the standard attribute binding syntax (
<img [alt]="content.altMessage">), the resulting html would be
This is a false-positive to us, as the resulting html does include an alt tag. We use other business tool driven validations to ensure the business user is adding the alt tag message before going live with the content.
This looks very similar to #4433, but that case is related to the standard attribute binding (without