2 ms·
i've had similar issues in java, but have come to a different conclusion. some context - i worked with java for many years, but more recently have been working
by andrewcooke 15y ago
i've had similar issues in java, but have come to a different conclusion.
some context - i worked with java for many years, but more recently have been working mainly in python (with some js, c and clojure). recently i got a chance to work with a great client (and that means so much - a good client is about the best thing you can hope for) back in java. we decided to go with, amongst other things, maven and jenkins, and, as a result, i had some checkstyle reports "for free".
checkstyle is a little like jslint for java. you can configure it on two different levels. on the most basic level, you can simply disable/enable tests globally. i disabled just one test globally (the one that objects to attributes and parameters having the same name, for code like void foo(int bar) {this.bar = bar;}, because the ide works so much better with consistent variable names (auto-gen and renaming)).
more interestingly, the second level of config allows you to define comments that disable tests locally - on, or from a particular line, or for a block of lines. this is great, because it forces me to consider exceptions and, where they are needed, document there (the disabling comment can take extra text that describes why).
i don't particularly agree with everything checkstyle does. but i don't think that affects its main advantage. that advantage is not that it makes my code better, but that it makes it conform to a standard that others are used to, and - even better - that it documents why it deviates from that standard, when necessary. that last part makes particular sense because those deviations tend to be the "interesting" parts of the code - exactly the parts that should be explained in more detail by comments.
anyway, apologies if that seems off-topic. it just struck me that maybe jslint would be improved by a "document exceptions locally" approach (does it do that? all i know of is global config).