This article was written by Per Tillisch, Tooling Team SW Engineer at Arduino
The Arduino team created a tool to check Arduino projects for common problems. Arduino Lint runs over 175 checks on your sketches, libraries, and boards platforms which cover specification compliance, Library Manager submission requirements, and best practices.
Arduino Lint
Arduino Lint is an easy to use, yet powerful, command line tool. Its focus is on the structure, metadata, and configuration of Arduino projects, rather than the code.
Getting started
Follow the installation instructions to get ready to use Arduino Lint: https://arduino.github.io/arduino-lint/latest/installation/
Now you only need to open a terminal at your project folder and run the command: arduino-lint
This will automatically detect the project type and check it against the relevant rules.
The default configuration of Arduino Lint provides for the most common use cases, while offering the option to change settings via command line flags.
Configuration
Compliance setting
The –compliance flag allows you to configure the strictness of the applied rules. The three compliance level values accepted by this flag are:
- permissive – failure will occur only when severe rule violations are found. Although a project that passes at the permissive setting will work with the current Arduino development software versions, it may not be fully specification-compliant, risking incompatibility or a poor experience for the users.
- specification – the default setting, enforces compliance with the official Arduino project specifications (sketch, library, platform).
- strict – enforces best practices, above and beyond the minimum requirements for specification compliance. Use this setting to ensure the best experience for the users of the project.
Library Manager setting
Arduino Library Manager is the best way to provide installation and updates of Arduino libraries. In order to be accepted for inclusion in Library Manager, a library is required to meet some requirements.
Arduino Lint provides checks for these requirements as well, controlled by the –library-manager flag.
The Library Manager submission-specific rules are enabled via –library-manager submit.
Even if your library isn’t yet ready to be added to Library Manager, it’s a good idea to use this setting to ensure no incompatibilities are introduced.
Once your library is in the Library Manager index, each release is automatically picked up and made available to the Arduino community. Releases are also subject to special rules. The command arduino-lint –library-manager update will tell you whether your library is compliant with these rules.
Integration
The –format flag configures the format of arduino-lint’s output. The default –format text setting provides human readable output. For automation or integration with other tools, the machine readable output provided by –format json may be more convenient. This setting exposes every detail of the rules that were applied.
The –report-file flag causes arduino-lint to write the JSON output to the specified file.
Continuous integration
Arduino Lint would be a great addition to your continuous integration system. Running the tool after each change to the project can allow you to identify any problems that were introduced.
This is easily done by using the arduino/arduino-lint-action GitHub Actions action: https://github.com/arduino/arduino-lint-action
Add a simple workflow file to the repository of your Arduino project and GitHub will automatically run Arduino Lint on every pull request and push.
Give it a try!
Will your project get a passing grade from Arduino Lint? There’s only one way to find out…
Support and feedback
You can discuss or get assistance with using Arduino Lint on the Arduino Forum.
Feedback is welcome! Please submit feature requests or bug reports to the issue trackers:
- Arduino Lint: https://github.com/arduino/arduino-lint/issues
- arduino/arduino-lint-action: https://github.com/arduino/arduino-lint-action/issues
No comments:
Post a Comment