I also think this would make a lot of sense when all you want is ignore a specific issue on a specific line:
- We shouldn’t ignore all rules on the same line (with NOSONAR comments), just the problematic one.
- We shouldn’t ignore a specific rule in all lines of a file (with module-level ignores using a pattern).
And it would align with other tools, for example:
- ESLint has
// eslint-disable-line no-alert. - TypeScript has
@ts-expect-error, which works differently, but just as good.
References:
And this is a little off topic, but we should also support putting standalone # NOSONAR comments on previous lines in (not just)Dockerfile files, because otherwise:
- Lines can get too long sometimes.
- You might encounter syntax errors, e.g., in a Dockerfile, there is no such thing as a comment at the end of the line, see this StackOverflow answer and docker:S6504 not working correctly - #9 by rkrisztian (my recent issue).