3 ms·
Once you get used to tools like `go fmt` or Perl::Tidy it feels barbaric not to be able to cleanly format all your code instantly. Read only linters are nice bu
by staunch 13y ago
Once you get used to tools like `go fmt` or Perl::Tidy it feels barbaric not to be able to cleanly format all your code instantly. Read only linters are nice but something that can reformat code is much nicer.
- sliverstorm 13y agoHuh? You know that a linter is not a formatter, right?
- DanHulton 13y agoPretty sure he does. His comment only makes sense in that context.
- sliverstorm 13y agoI guess I just don't see that. perltidy and lint(s) are completely nonoverlapping, to my knowledge. Something that can reformat your code doesn't even do the same job as a linter.
- mbell 13y agoI'm not really following you. It's very common for linters to flag stylistic and formatting issues.
- sliverstorm 13y agoAh well, perhaps it's just a difference in experience. I've never used a linter (there are countless linters) that fixed indentation, arranged if statements, and inserted newlines to wrap long lines. Nor has a formatter ever helped me find the sort of issues I use a linter to find.
- maw 13y agoThere is overlap. I once lost a fair amount of time because some dimwit predecessor thought putting anything other than a space after commas was acceptable. (It sounds ridiculous but it's true. I can explain if you care.) So: a formatter will, for example, make sure your lines are indented to some standard amount of indentation, a linter will bitch if they are not, and both the formatter and the linter should DTRT when they identify certain indefensible coding practices.
- he_the_great 13y agoI wouldn't want to reach for lint to handle formatting, that is what indent is for. That is to say, lint should not complain that the if should contain a space before the (.
- maw 13y agoI agree in that case, but when it comes to commas, using spaces in a certain way is objectively better.
- Scaevolus 13y agoClang-format aims to provide this for C++. http://clang.llvm.org/docs/ClangFormat.html http://clang.llvm.org/docs/ClangFormat.html http://www.irill.org/videos/euro-llvm-2013/jasper-hires.webm http://www.irill.org/videos/euro-llvm-2013/jasper-hires.webm
- jbergstroem 13y agoWhile reading the article, I also thought why they didn't at least mention it (and why they abandoned the idea). It's powerful, fast and will most likely be the base for a lot of {h,l}inting in editors/IDE's moving forward. edit: Somehow missed that they mentioned Clang not being mature enough when starting this project.
- letzjuc 13y agowell there is clang-format and clang-tidy and they are really easy to set up in CMake (I use "make format").
- eliasmacpherson 13y agohttp://astyle.sourceforge.net/ http://astyle.sourceforge.net/ linters are more important that pretty formatting to my mind. c++ has had both linters and reformatters for a long time. I suppose the distinction is that they are not built in.