Skip to content

Commit

Permalink
docs: add linter reference page (#5032)
Browse files Browse the repository at this point in the history
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
Co-authored-by: Michael DuBelko <michael.dubelko@canonical.com>
Co-authored-by: Alex Lowe <alex.lowe@canonical.com>
  • Loading branch information
3 people committed Sep 17, 2024
1 parent 8faa6d5 commit 055fb36
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Reference
changelog
commands
components
linters
plugins
/common/craft-parts/reference/part_properties
parts_steps
Expand Down
61 changes: 61 additions & 0 deletions docs/reference/linters.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Linters
=======

A *linter* is an analysis tool that checks for common errors or compatibility
issues, usually automatically, or as part of some other process.

Snapcraft 7.2 and higher provides built-in linter functionality when the snap
uses core22 or higher as its :doc:`base </reference/bases>`.

By default, these built-in linters run automatically when a snap is built. If
they're unneeded, you can disable them in the snap's ``snapcraft.yaml``.

Built-in linters
-----------------

Snapcraft runs the following linters:

- `classic`_. Verifies binary file parameters for snaps using
`classic confinement`_.

- `library`_. Verifies that no ELF file dependencies, such as libraries, are
missing, and that no extra libraries are included in the snap package.

Disable a linter
----------------

You can disable a linter by adding it to the ``lint.ignore`` key in
``snapcraft.yaml``. For example:

.. code-block:: yaml
lint:
ignore:
- classic
- library
Ignore specific files
~~~~~~~~~~~~~~~~~~~~~

To disable a linter for a specific file, you can list it under a linter's entry
in the ``lint.ignore`` key. The path is relative to the snap directory tree,
and supports wildcard characters (**\***).

In the following example, the ``classic`` linter is disabled entirely, and the
``library`` linter won't run for the files in ``usr/lib`` that match the
specified pattern:

.. code-block:: yaml
lint:
ignore:
- classic
- library:
- usr/lib/**/libfoo.so*
.. _classic: https://snapcraft.io/docs/linters-classic
.. _classic confinement: https://snapcraft.io/docs/snap-confinement
.. _library: https://snapcraft.io/docs/linters-library

0 comments on commit 055fb36

Please sign in to comment.