A Few Words About Code Quality¶
Code quality has a practical impact on both your agility and the cost of development. You can’t change buggy code fast enough to be truly agile. Existing bugs can easily increase dev costs (and time) by 10x. You can't afford not to fix them.
— Allen Holub
Premature optimization is the root of all evil.
— Donald Knuth
Don't abstract when you don't have to. Often causes pain, results in bloated code and fewer developers understand what is going on. Write tests instead so that you can safely refactor when really needed.
Remember: Duplication is far cheaper than the wrong abstraction.
While we expect this to be difficult when working with a distributed team and pull requests, we encourage all contributors to refactor whenever they see a specific issue and they are working on related code anyways (so that you can validate if your changes are helpful). This way, there is no need for extra refactoring tickets or epics. Let's experiment and see how far we get with this.
Remember: Ugly code is not a problem as long as there are tests, there are no security issues and you can easily refactor later. Nobody needs beautiful code that doesn't work.
Feel free to think ahead, just don't code ahead. But also, don't feel the need to decide so many details ahead. Learn enough to get started and build only what you need.
— J. B. Rainsberger
Remember: You have to go slow before you can go fast. Keep it simple. Done is better than perfect. Be pragmatic. Stay focused.
Test Coverage ¶
Test coverage is a useful tool for finding untested parts of our codebase. Test coverage is of little use as a numeric statement of how good our tests are.
Remember: We strive for complete test coverage. Code that cannot be tested is flawed.
A coverage log file created by the Go test runner is automatically sent to Codecov every time our
develop branch was successfully built and tested on Travis CI. Codecov provides a beautiful UI for displaying coverage reports and renders a badge showing the current test coverage. Custom settings for our report are located in codecov.yml. For example,
range: 50..90 means the badge will be green if coverage is >= 90% and red if it is <= 50%.
Quality Reports ¶
Remember: Not every issue reported by a tool really is important and needs to be fixed instantly. Use reports for inspiration when you need some.