The Daily WTF

CodeSOD: Lint Brush Off

Follow
C# introduced primary constructors to reduce boilerplate code by allowing fields to be declared directly on the class. The required fields are then automatically used to generate a constructor. Esben B's team uses a linter that enforces the use of primary constructors. The linter flagged a traditional constructor as not adhering to primary constructor syntax. Esben initially disabled this specific warning using a pragma. However, the linter then generated a new warning stating the suppression was unnecessary. To address this, Esben attempted to disable both the original warning and the warning about unnecessary suppression. This approach failed because pragmas only affect subsequent lines of code. Consequently, Esben had to employ multiple pragma statements to disable the warnings sequentially. This resulted in three lines of code to suppress a single linter warning. The author suggests that such situations might indicate an incorrect use of the tool or that the tool itself is unsuitable for the task.
favicon
thedailywtf.com
thedailywtf.com