Avoid stress with Linter! Let it analyze your code and find bugs and stylistic errors. Linter should be your best friend.
What Is a Linting
Lint, or a Linter, is a very useful tool for automated analyzing of your source code to look for bugs and stylistic errors. Linter helps to ensure that your code does not include any structural issues which can make your code harder to maintain. Linting became a verb and it is the process of flagging the functional and structural problems. The Lint tool is a basic static code analyzer. The term Linting comes from a Unix utility for C.
Linters are available for most programming languages. Here are the most common ones:
- for Java: Checkstyle
- for Python: Pylint
- for Swift: Swiftlint
- for Ruby: rubocop
- for Rust: rust-clippy
- for more information, see Hugo Martins: Awesome Linters
Why You Might Want the Linting
- Linting helps you reduce errors and improve the quality of your code.
- It is an automated check and it saves the developers’ time.
- It improves the code readability. It unifies the style within the team and therefore safes the time during the Code Review.
- It can automatically correct some mistakes (auto fix).
Problems the Linting Solves
How to Implement the Linting
- Linting should happen early in the development phase, before the Code Review and testing. It has to be integrated into the developer environment.
- Implement the Linting to the Continuous Integration.
- Ensure that your code follows standard rules. Otherwise, the Linter flags more than you need. You can override the default settings or disable rules for specific files but it can bring more trouble.
- Turn on the auto fixer for as many errors as possible. After the implementation, fix all the issues from the auto fix.
- Make a separate pull request so the other developers understand that you started using a Linter.
Common Pitfalls of the Linting
- A high number of searched errors can lead to high false positive and false negative rates. Also, automatically corrected errors have to be rewritten by hand.
- Too many rules and therefore too many notifications can get annoying. Turn on the auto fixer and get rid of as many marked errors as possible.
- Implementing the Linting without informing your colleagues can lead to misunderstandings.
- Do not Lint on demand. If you have it, use it.
Resources for the Linting
Want to write for DXKB?
Feel free to contribute. People from DXKB community will be more than happy.
Code Review is an important practice for checking each other's code. The reviewers are other developers from the team. The goal is to uncover potential mistakes that could slip through testing.Read more
Release management is the process of managing, planning, designing, scheduling, testing, controlling and deploying of a software build through different stages and environments; in preparation for software releases.Read more
Proper Bug Reporting
Proper bug reporting is a crucial practice for development. It helps to understand where the product lacks its functionality or performance. Bug reports are descriptions of bugs found by testers.Read more
A Runbook is a set of standardized documents that describe how to run a computer system. It typically contains a walkthrough how to start, stop, debug and supervise the system.Read more
Kanban is a Lean method similar to Scrum. It is focused on managing a continuous delivery of products with avoiding the "bottleneck effect". It helps teams work together and more effectively.Read more