Linting » History » Version 2
osmith, 06/16/2021 02:53 PM
1 | 1 | osmith | h1. Linting |
---|---|---|---|
2 | |||
3 | Patches submitted to [[Gerrit]] are automatically linted to ensure patches follow our [[coding standards]] and to catch common spelling errors. Jenkins runs @checkpatch.pl@ from the Linux kernel (with an Osmocom specific configuration) against the diff of the current patch. |
||
4 | |||
5 | 2 | osmith | h2. Run locally |
6 | 1 | osmith | |
7 | 2 | osmith | Go to the directory above your Osmocom sources, then run the following: |
8 | |||
9 | <pre> |
||
10 | $ git clone https://git.osmocom.org/osmo-ci |
||
11 | $ cd libosmocore |
||
12 | $ ../osmo-ci/lint/lint_diff.sh |
||
13 | </pre> |
||
14 | |||
15 | h2. Pre-commit hook |
||
16 | |||
17 | 1 | osmith | The linting script is very fast, it makes sense to configure it locally as pre-commit hook. Then it will run whenever attempting to @git commit@. |
18 | |||
19 | 2 | osmith | Again, go to the directory above your Osmocom sources and run the following. Replace libosmocore with any checked out Osmocom project. |
20 | 1 | osmith | <pre> |
21 | $ git clone https://git.osmocom.org/osmo-ci |
||
22 | $ ln -sv $PWD/osmo-ci/lint/lint_diff.sh libosmocore/.git/hooks/pre-commit |
||
23 | </pre> |
||
24 | |||
25 | h2. Osmocom specific configuration |
||
26 | |||
27 | Find the Osmocom specific configuration in @osmo-ci/lint/checkpatch/checkpatch_osmo.sh@. |
||
28 | |||
29 | If you see the script generating errors with checks that don't apply for Osmocom code (see the ignores and excludes already in the script), please submit a patch against osmo-ci.git that disables this specific check. |
||
30 | |||
31 | h2. Testing |
||
32 | |||
33 | Run @osmo-ci/lint/lint_all.sh@ in a git repository to run the script against all files in that repository and to report the total amount of errors. It is also possible to run only a specific check of @checkpatch.pl@ by passing it as argument. For example: |
||
34 | |||
35 | <pre> |
||
36 | $ cd libosmocore |
||
37 | $ ../osmo-ci/lint/lint_all.sh CODE_INDENT |
||
38 | </pre> |
||
39 | |||
40 | h2. See also |
||
41 | |||
42 | * #5087 |