Hacker News new | ask | show | jobs
by routerl 3762 days ago
A linter doesn't prevent breaking its rules, it just notifies the writer of which rules are being broken.

I was writing some C earlier and my linter warned me about "incrementing a void pointer". However, I understood the context better than my linter, knew that I'd be compiling with gcc (which allows void pointer arithmetic), so I ignored the warning and carried on. My code compiled and ran nicely.

When it comes to static analysis, I think (creative) writers, like programmers, wouldn't care about warnings. This is already true of spell-checkers (e.g. my letter-writing character is English, but my text-editor's yelling about "colour").

1 comments

Sounds like your system is in US English rather than the variant of English you are used to?

http://grammarist.com/spelling/color-colour/

Sorry, I guess that example was too terse.

I was referring to a hypothetical American creative writer, writing a scene in which a British character writes a letter. In this hypothetical work, written in US English, there would then be a section of text that used UK English spellings. The naive spell-checker would not understand the context, and would flag these as misspellings.

This was meant to be analogous to my "incrementing a void pointer" example; the static analysis tool produces warnings which the author knows to ignore. In the C programming case, my function was passed the size of the objects comprising the array pointed to by the void pointer, so the linter was wrong to tell me I was making a mistake. Similarly, the spell-checker was wrong to say "change this instance of 'colour' to 'color'".

Similar considerations apply to prose linters.

Polonius would be a lesser character if shed of cliches, and a good writer would know to ignore the linter's opinions on the matter.