2

In our Ruby on Rails projects we use a linter for our slim templates: slim-lint. It doesn't support any automatic fixes, not even the easiest ones. So I'd like to abandon it because I don't like to go line by line through the report and fix small things in the slim templates manually. After all code formatting tools should make our lifes easier.

Would you rather keep linting and correcting little details manually or abandon it? Does linting fine granular details make sense if fixes cannot be automatically applied?

4 Answers 4

7

What would be the alternative? No linter at all, and thus no style fixes at all - except for the ones found during code reviews. But obviously - the latter have to be applied manually as well.

So this ultimately depends on how much value you see in those suggested style fixes the tool provides, and if you think applying those fixes (manually) is worth the hassle in the eyes of you and your team, or not. It also depends if there exist an alternative tool which may give you more "bang for the buck" in return and can apply automatic fixes (but let us assume this is not the case).

It could also be a learning process - ideally, after using such a linter some time, you will try to avoid to break its rules first hand, without a significant loss in coding speed.

If that's not working for you, another approach could be to use only a subset of the linter's rules, and keep only the rules where you see the most value for you and the team. If that is not possible "out-of-the-box" - well, this specific linter is open source under MIT license, so it may be possible for you to extend / modify the tool to allow more finegrained configuration options, or to disable some things you don't like. If you want to, and have some time to spare, you could even try to add some "automatic fixing feature" by yourself.

1

The primary goal of a linter is to ensure that the code style is uniform. The code is written once, but read many times, and inconsistent style makes it more difficult to read.

The auto-fixing feature is just that: a feature. Some linters provide one. Many don't.

1

Would you rather keep linting and correcting little details manually or abandon it?

Linting would / does assist developers in too many ways to justify abandoning the tool.

Does linting fine granular details make sense if fixes cannot be automatically applied?

As an extension of the above answer, even in the worse case (which you may be describing), the adage “something is better than nothing” holds true.

One instance that linting helps at and may not be obvious: it helps to improve code reviews as linting acts as a pre-code review tool.

1

I set my linters to auto correct and even set it to do so on a post commit hook. I have yet to see code break from auto fixing linters. I believe trusted linters are probably set to auto correct very conservatively. Meaning if there's any ambiguity, it will say it can't auto-correct.

If you are using Ruby, I am finding rubocop quite nice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.