4 ms·
Usually i disagree with these types of lists, but this one seems pretty spot on. My only quible would be that only code quality static analysis is useful. Secu
by bawolff 6y ago
Usually i disagree with these types of lists, but this one seems pretty spot on.
My only quible would be that only code quality static analysis is useful. Security static analysis on the other hand (e.g. taint analysis to find security bugs like XSS) is pretty overrated most of the time unless you work really hard to make it fit in your context.
I also think linting rules are important, not for what they actually do, but just to get everyone to stfu about variations in code style that dont matter and arguing about more important things.
- d3nj4l 6y agoAlso, having consistent formatting makes it very easy to read through large amounts of code. If you know how the code is laid out, you don’t need to focus on everything and can “squint” through it to get a good idea of what’s going on.
- Rapzid 6y agoI believe though that you should just have some system in place to automatically check/fix these issues(for the most part). I've been in far too many environments though where PR reviews are just surface-level formatting nits and don't address functionality or architecture at all..
- gpanders 6y agoAgreed with you and the GP. In one project I’m on, I pushed for linting and formatting checks in our CI not because I’m an “insane weirdo” who cares too much about formatting, but precisely because I don’t care, I just want it to be consistent. I don’t really have an opinion about which style or format or whatever is better, I just don’t want to have to read through 6 different coding styles when I scan through my colleagues’ code.
- SAI_Peregrinus 6y agoHaving a consistent style enforced by an automatic tool set (linter/autoformatter/etc) means no time needs to be wasted in any given PR arguing about style, or waiting for someone to fix a style mistake. You might still waste time arguing about what the rules should be, but that's often less than the cumulative waste of fixing avoidable crap.
- RcouF1uZ4gsC 6y agoThe solution to this is to use an automated formatting tool for the entire team and have it automatically run prior to review and be done with it.
- rmk 6y agoThis is done in many teams. Go has made it really easy via its gofmt tool. The trouble is that it's hard to do on a large existing codebase that's not consistently formatted: doing a mass format messes with the line-by-line commit history, and on occasion introduces bugs.
- lazulicurio 6y ago> I also think linting rules are important, not for what they actually do, but just to get everyone to stfu about variations in code style that dont matter and arguing about more important things. Agree. I don't think that there's one "best" style, but I've worked with people who don't care about consistency at all, and their code is so much harder to read. There's bunch of value in just picking a style and sticking to it.
- ncann 6y agoReminds me of this: "Gofmt's style is no one's favorite, yet gofmt is everyone's favorite."
- rmk 6y agoPeople with less experience consistently undervalue linting and code formatting and style. Code linting forces one to deal with code smells and innocuous errors that can cost a lot to fix once they escape into the field. Consistent code formatting and style are invaluable in (a) reducing cognitive load in picking names, which is a hard problem in computer science, (b) clarifying the structure of the code (you begin to see the forest for the trees, because the trees are mostly uniform) and (c) onboarding or familiarising with new codebases, including new areas of large codebases.
- bawolff 6y agoI like consistent code style (i dont care what as long as its consistent) but it has never helped me come up with good variable names.
- kenhwang 6y agoI value a consistent enough default style. I'm not going to waste time arguing why this specific consistent style is better that some other consistent style and I'm certainly not going to police the codebase manually and force it into that style. Either the linter catches it and fixes it automatically with little to no configuration, or its not important enough to be worth the time.
- nielsbot 6y agoOpinion: but I think "invaluable" is overstating it. I agree with OP: not that important. Again, opinion. (20 years experience here) Edit: I suppose I should clarify why. I think there are more important issues to focus on when building software with others.
- pindab0ter 6y agoI think there might be more agreement here than we think. OP is talking about “people who stress over […]”. I think a linter can be (in?)valuable without stressing over it. Just get everybody on board, don't stress over which style “is better” (as if there's such a thing) and make it your own.
- 6y ago
- Falkon1313 6y agoI generally agree. But static analysis tools are still pretty dumb and sometimes cause extra work to no benefit. Flagging a method for cyclomatic complexity when it uses a case statement that is blatantly obvious and simple to any human seeing it, for example. Or just happening to notice a bunch of issues in file B when you commit file A but didn't even touch file B. Overall it's good, I like it, but with the caveat that it can take some work to tweak and adjust to avoid waste like that. And that usually seems to come right on the deadline or the day before. Worthwhile, but you have to take that cost into account.
- jmiserez 6y agoCyclomatic complexity IMHO isn't a good metric for code complexity as understood by humans, but sometimes it can be insightful especially when it's unexpected. My favorite static analysis issues are the ones that flip-flop between two issues, I love doing "merge this if statement with the enclosing one" only to get "expressions should not be too complex" after I've merged them. As long as you have the power as the developer to override the tool and mark issues as won't fix (with rationale) I think it's fine. If not, the ruleset needs to be really good and as minimal as possible. Otherwise you'll just get crappy but compliant code which isn't helping anyone. Also, it sometimes makes sense to leave suboptimal but old and correct code as-is to preserve the Git history or because the suggested change doesn't actually make the code any better. And finally, these tools do still generate false positives. While it makes sense to thoroughly review each of these with a coworker, you should still be able to mark them as false positives.
- muldvarp 6y ago> And finally, these tools do still generate false positives. And as long as we talk about tools that do some kind of semantic analysis (not just syntactic) on a turing-complete language they will always either have false positives, false negatives or both. Rice's theorem guarantees that. They still can be useful though. I programmed a static analysis tool for PHP a long time ago and it worked surprisingly well.
- ric2b 6y ago
- iovrthoughtthis 6y agoAdherence to (imo) bad linting rules have forced the early crystallisation of architecture as arbitrary abstractions simply to please the static analysis gods. Code style is fine to keep consistent but sometimes concepts just aren’t battle tested enough to warrant their own abstractions yet and committing to one to please a cyclomatic complexity / line count score is actually just creating more work for some future engineer who is tasked with the job of re-engineering the solution.
- archi42 6y agoWe build static code analysis tools, used by companies building safety critical stuff (planes, cars,...). If you're failure mode is "there might be fatalities" over "the app crashes", this becomes really valuable. Code quality is already quite nice, and metrics like e.g. MISRA are supported by many analyzers; but proving(!) the absence if various error classes can be handy as well. (Disclaimer: I work on the binary analyses, not on the source code analyses; so my detail knowledge on that front is not too deep). +1 for linting. If the code looks "the same" I find reviews much easier since I can focus in what it actually does (or fails to do), not on "decoding" it. Though nobody should freak out on minor variations.
- jmiserez 6y ago>Security static analysis on the other hand is pretty overrated most of the time unless you work really hard to make it fit in your context. I think the "unless" part is key here. If used correctly, it's crazy what these tools can find, and they give you a baseline of issues to analyze/fix before digging deeper. But yes, running them blindly just to tick a box isn't very helpful.
- GordonS 6y agoFor the project I'm currently working on, the customer mandates that we must use SonarQube, Fortify and Nexus IQ. Not once has any of them found any kind of security issue. In fact every single thing they have raised has been a false positive, or just plain time wasting (e.g. forcing some arbitrary level of branch coverage). Also, they can be so slow - more time is spent in the build pipeline on these tools than is spent in actual build, test and deployment combined (even including integration tests)! Fortify is particularly slow (up to 10 minutes!), and provides no value whatsoever. I've used SonarQube on several other projects too; it seems to be very popular in enterprise circles in particular. Never once have I seen it raise a security issue. On occasion it points out the odd accessibility issue, but that's it.
- organsnyder 6y agoI spent months at my previous employer (large enterprise) "remediating" findings from a security scanner. The majority of them were IM conversations with the security analyst discussing why they should be ignored.
- rstuart4133 6y ago> My only quible would be that only code quality static analysis is useful. It didn't occur to me he meant anything else. I just read it as not using -Wall -Wextra -Werror makes life more painful. > just to get everyone to stfu about variations in code style It makes reading code easier from different programmers easier. But the exact format doesn't matter - just so long it's all similar. Standardising on a formatting tool / linter from the language like pep8 does the stfu job. The bit I was surprised by is: > Code coverage has absolutely nothing to do with code quality It might be true depending now how you measure code quality I guess, but that's a very fuzzy metric. Choose a concrete metric like the ratio of man hours to get code out the door over bugs in that code, and what is absolutely true is automated tests is one of the few dramatic ways we have of forcing the metric up. Either you automate the tests, you spend enormous amounts of time manually doing tests, or you don't test. I suspect he's arguing the difference between 95% and 100% coverage isn't great. I'd quibble, but that's defensible. But the difference between 50% and 95% on the other hand is dramatic.