javacommentssonarqubetodo

How to handle TODO comments when sonar error is encountered


We have a large application and we have added the TODO rule to SonarQube quality gates that throws errors when TODO comments are found.

This encourages developers to remove TODO comments, which is scary, as the whole purpose of adding the TODO comment is lost.

Is there a way to keep the TODO comments by adding some sort of override or ignore comment similar to ESLint? We would like to defer dealing with the TODOs but still be notified of the TODO tasks left by developers when they do not fit the scope of a current ticket without blocking a build.


Solution

  • Remove the TODO, stop using them for anything that's not short term (for the length of a ticket or fork) and move them into tickets on your ticket tracking system.

    TODO comments have multiple problems:-

    There's nothing more irritating than a piece of code by a developer who was too lazy to do a good job, so left it for the next guy

    enter image description here

    or one who wasn't lazy but was too scared to break something and just ended up making the problem more complex with minimal comments suggesting there's a problem

    enter image description here