I’m heading a new team of developers working on a software project that makes use of continuous integration (circleci) w/ a pretty fleshed out suite of busterjs unit/integration/acceptance tests. Our project is primarily written w/ coffeescript, and I try to make use of coffeescript-linter to ensure everyone working our code base keeps code consistent and as organized as possible.
My question is, does anyone have any thoughts on when/if/how to enforce linting? Should I integrate linting into my tests that are executed by circleci before deployment?
Another thought I had was writing a simple shell script that combines git-push and the linting utility into one step and then including it in the project & having everyone use it.
I’m pretty new to managing teams of programmers so anyone else’s feedback is much appreciated.
EDIT:
In the last 3 seconds it just occurred to me that git-hooks is probably perfect for this. Specifically a git-hook on commit.
2
When you a) have a coding standard and b) have configured the linter to be consistent with the coding standard, that’s when you start enforcing linting.
Put the linter on the CI server.
1
The question is, how important is it to you that issues found by coffeescript-linter are addressed immediately.
If it is unacceptable to have code in the repository that gets flagged by the linter, then you should have the linter run as a commit hook so it can block the commit if there are issues.
If it is undesirable but not unacceptable, then I would run the linter as part of the test suite (and it it complains, regard that as a test failure)
If it is not practical to run the linter as a test case, then I would run it on the CI server on a separate schedule (for example, once a day or once a week) and encourage developers to use the linter when they have a particularly large commit.
2
The team I work with is very strict with linting – the helpfulness of that is something I can’t understate.
Unfortunately, git has no way to enforce linting. Even if it did, enforcing the correct version of the linting tool, enforcing the same configuration etc would still be a problem.
So this was our solution:
- Our lint configurations are committed – and changes heavily scrutinised in code review. This keeps them in sync.
- The lint runs on the CI server. This CI plan should never fail – and when it does, the culprit’s name (ie, the last to commit) comes up in big red letters in our group chat.
- In light of the above, it is in the interest of our programmers to prevent it from happening by making sure their git hooks are working correctly.
It works very well for us, Once programmers get into the habit even the linters don’t really hold them up, as they’ll just eventually write in the enforced style. Until then, expect them to be cursing at the computer and whining about how long it takes them to do things. It doesn’t actually affect them that much, but it can feel like it when running down a long list of things that are “wrong”.
As you commented already on your own, I think it is most important that the team carries the decision that successful linting should be required.
I’m a big fan of static code analysis. I once managed to enforce a similar thing in the backend (“Treat Warnings As Errors” in C#) in an organization across several teams. At least some aspects of this were questioned over and over again (mostly because of technical shortcomings).
If some team members are really uncomfortable with the overhead incurred by continuous linting, the better solution can be to deactivate (parts of) it. Sometimes having all team members on the same page is more important than a cleaner code base.