4 ms·
Walkmod: Open-source tool to automatically apply code conventions
- srgpqt 11y agoWeird name. See also: http://astyle.sourceforge.net/ http://astyle.sourceforge.net/
- walkmod 11y agoWalkmod also allows (for Java) to work with the syntanctic and semantic information. So, for example it can remove unused elements (e.g variables).
- sancha_ 11y agoWhat happens with the private method and the sysout in your example?
- deleted 11y ago[deleted]
- lowmagnet 11y agoNot called so delete I guess. What that has to do with style or conventions I don't know.
- walkmod 11y agoYes, what I wanted to show in this example is that those elements that are "dead" can be removed (there is a plugin for it)
- tobik 11y agoOk, so the commented out for loop in the example is also considered "dead". Walkmod detects that it is in fact commented out code and only then removes it. Correct?
- walkmod 11y agoYes, but in contrast with removing unused private methods, currently there is no walkmod plugin that do this yet. We are working on adding more plugins.
- michaelmior 11y agoI find it frustrating that it's not made clear upfront that Walkmod is only for Java. In fact, it's not really made clear anywhere I can see so I'm not 100% sure that's correct but it seems to be the case.
- smoyer 11y agoFrom their GitHub README [1] (I'm not affiliated): "Walkmod can support with any programing language if a set of interfaces are implemented as a third party plugin. The first (and current) supported language is Java." [1] https://github.com/rpau/walkmod-core https://github.com/rpau/walkmod-core
- walkmod 11y agoExactly, Walkmod acts as a framework for language transformations, but we have started with Java
- speps 11y agoIt would be nice to write another plugin for something else like Python or C++. For example in the UML diagram I saw something called "JavadocComment" which immediately puts me off writing a plugin because it looks like I would have to follow this even for a non-Java language.
- michaelmior 11y agoThanks for that! I didn't see a note anywhere on the website. It's nice to have some clarification :)
- hadeharian 11y agoEvery problem in computer science can be solved by another level of indirection. Genius! Genius! Genius!
- _ZeD_ 11y agoumm... but eclipse already do this...
- daskills225 11y agoI like tools like this, but why not just write good code in the first place and make people fix code they write poorly?
- Quequau 11y agoIf that actually worked it would already be happening... but honestly it isn't.
- untog 11y agoI think we're long overdue a tool like this (maybe it already exists?) that will reformat code. I have been so bored beyond tedium about endless debates over tabs or spaces, 2 spaces or 4 spaces, semi-colons or no semi-colons, etc. etc. ad nauseum. Let users check out a repo formatted using whatever indentation they like, then commit back in a standardised format. Then we can all stop talking about this utter nonsense and do some real work.
- evolve2k 11y agoThoughtbot offer a tool called HoundCI that does this for JS, ruby, coffeescript and SASS (SCSS). They charge $12/month for private repos and it's free for open source. It's designed to check your github pull requests. Haven't used it but looks pretty nice. They provide style guides for each language that your free to customize. https://houndci.com https://houndci.com
- kyled 11y agoPhp-cs-fixer is another example. It does some ridiculous changes though, such as change $i++ to ++$i.
- Joky 11y agoFor C/C++/ObjC developers, `clang-format` is already a must. I have `git clang-format` as a pre-commit hook.
- bunderbunder 11y agoI'm a bit skittish about tools like this. We started using one for C# a while back, and discovered a couple key problems with it. First and foremost, sometimes its edits were not safe to do in the context - either that commented code really was important to keep around for some specific reason (e.g., it serves an explanatory purpose), or sometimes the changes were not truly behavior-neutral and would therefore introduce subtle bugs. In light of that, I'm moving away from thinking that using tools like this as a sort of spray-on tan for cleaning up code is wise. I've started leaning toward the following approach: First, let sleeping dogs lie. Old messy code is like asbestos; it's most dangerous when you disturb it. Second, if you're going to have to work on the code anyway then that's an appropriate time to clean it up. Even so, proceed with caution: Make sure you understand the code and it's got good test coverage so you can visually and empirically verify that the cleanup isn't doing any damage.
- markbnj 11y ago>> In light of that, I'm moving away from thinking that using tools like this as a sort of spray-on tan for cleaning up code is unwise. Great metaphor, and I agree.
- walkmod 11y agoIt is a respectable point of view, but I think that automatize some boring tasks to correct inside the code is a good idea because let you work on other more interesting tasks. In fact, most of us use some automatic ways to correct and enrich code with IDEs. Is it also incorrect? In fact, what we are trying to solve are the following situations: a) In a context where there are a lot of developers and you have worked hard into improve the code style and someone else pushed code that again violates your "implicit" code style. Do you need to correct these bad practices over and over again? b) There are some boring tasks that punctually appear like "refactoring" when deprecated methods appear or developers need to upgrade one external library version (eg. one critical bug appears). Anyway, thank you for your opinion :-)
- jellekralt 11y agoI prefer to use a tool that gives you feedback on your code, rather than to correct your code. When you get feedback, you learn and (hopefully), you'll improve your style while you write your code. When it is automatically corrected for you, you don't necessarily learn anything from it.