blob: b417ffbe4ac2aa78f1ac5adcf8b77003c2735b01 [file] [log] [blame]
Joey Armstrongbb26e932024-01-29 16:17:27 -05001.. _code--makefile-lint-targets:
Joey Armstrongfb8f3c82024-01-29 10:13:18 -05002
Joey Armstronga9a16b62023-11-01 14:31:15 -04003======================================
4Makefile Lint Targets: Syntax Checking
5======================================
Joey Armstronga8bc8e12022-12-04 07:06:59 -05006
Joey Armstrong477381e2024-02-11 12:59:59 -05007Makefile Linting: By language
8-----------------------------
Joey Armstronga8bc8e12022-12-04 07:06:59 -05009
10.. code:: bash
11
Joey Armstrong477381e2024-02-11 12:59:59 -050012 % git clone ssh://gerrit.opencord.org:29418/onf-make.git
13 % cd onf-make
14
15 % make help | grep lint
Joey Armstronga8bc8e12022-12-04 07:06:59 -050016 lint-chart chart_version_check.sh
Joey Armstrong4de98b72023-02-09 14:51:38 -050017 lint-doc8 Syntax check *.rst documentation files.
Joey Armstronga8bc8e12022-12-04 07:06:59 -050018 lint-helm Syntax check helm configs
19 lint-json Syntax check json sources
20 lint-license Verify sources contain a license block.
Joey Armstronga8bc8e12022-12-04 07:06:59 -050021 lint-robot Syntax check robot sources using rflint
22 lint-shell Syntax check bash,bourne,etc sources
23 lint-yaml Syntax check yaml source using yamllint
Joey Armstronga8bc8e12022-12-04 07:06:59 -050024
Joey Armstrong4de98b72023-02-09 14:51:38 -050025 [PYTHON]
Joey Armstronga2fa6582023-04-07 11:03:36 -040026 lint-python Syntax check using available python tools
27 lint-flake8 Syntax check using tool flake8
28 lint-pylint Syntax check using tool pylint
Joey Armstrong4de98b72023-02-09 14:51:38 -050029
Joey Armstronga8bc8e12022-12-04 07:06:59 -050030|
31
Joey Armstrong477381e2024-02-11 12:59:59 -050032Makefile Linting: By language target
33------------------------------------
34
35.. list-table:: Bulk sandbox linting
36 :widths: 20, 60
37 :header-rows: 1
38
39 * - Make Target
40 - Description
41 * - help | grpe lint
42 - Display available help for lint targets and flags.
43 * - make lint
44 - Invoke all source linters, linting is conditional by language.
45
46.. list-table:: Language and tool specific linting targets
47 :widths: 20, 60
48 :header-rows: 1
49
50 * - lint-{topic}-help
51 - Display extended help for a topic, supported targets and flags, etc.
52 * - lint-{topic}-all
53 - Lint everything available by file extension.
54 * - lint-{topic}-mod
55 - Lint locally modified files (git ls-files -m | lint)
56 * - lint-{topic}-src
57 - Lint a list of files passed in (make lint-{topic}-src VAR=list-of-files)
58
Joey Armstrong82180592024-02-10 15:34:21 -050059.. seealso::
60
61- :ref:`Makefile Target lint-chart`
62- :ref:`Makefile Target lint-helm`
Joey Armstrong477381e2024-02-11 12:59:59 -050063- :ref:`Makefile Target lint-robot`
Joey Armstrong82180592024-02-10 15:34:21 -050064
Joey Armstrong477381e2024-02-11 12:59:59 -050065|
Joey Armstronga8bc8e12022-12-04 07:06:59 -050066
67All Sources
Joey Armstronga9a16b62023-11-01 14:31:15 -040068===========
Joey Armstronga8bc8e12022-12-04 07:06:59 -050069
70The generic lint target can be used to invoke all defined lint targets.
71
72.. code:: bash
73
74 make clean
75 make lint 2>&1 | tee log
76
77|
78
Joey Armstrongb544dff2022-12-07 15:12:05 -050079Makefile help
Joey Armstronga9a16b62023-11-01 14:31:15 -040080=============
Joey Armstrongb544dff2022-12-07 15:12:05 -050081
Joey Armstrongbd6cc3d2023-01-09 19:52:12 -050082Individual Makefiles support a help target that will display a list of
Joey Armstrongb544dff2022-12-07 15:12:05 -050083targets and functionality supported.
84
85.. code:: bash
86
87 make help
Joey Armstronga9a16b62023-11-01 14:31:15 -040088 make help | grep {topic}
89
90.. list-table:: help
91 :widths: 20, 60
92 :header-rows: 1
93
94 * - Make Target
95 - Description
96 * - help
97 - Display available help for targets and flags
98 * - make help | lint-{topic}
99 - Display summary usage for lint-doc8, lint-license, lint-make
100 * - lint-{topic}-help
101 - Display extended help for a topic, supported makefile targets, etc
102
103Legacy Help Usage
104-----------------
105
106.. code:: bash
107
108 make help
Joey Armstrongb544dff2022-12-07 15:12:05 -0500109 make help-verbose
110 make help VERBOSE=1
111
112|
113
114
Joey Armstronga9a16b62023-11-01 14:31:15 -0400115doc8 / restructuredText (rst)
116=============================
Joey Armstrong4de98b72023-02-09 14:51:38 -0500117
118Command: `doc8 <https://pypi.org/project/doc8/>`_
119
Joey Armstronga9a16b62023-11-01 14:31:15 -0400120.. list-table:: Makefile Targets
121 :widths: 20, 60
122 :header-rows: 1
123
124 * - Target
125 - Description
126 * - help
127 - Display item ``lint-doc8`` as a summary help topic item.
128 * - lint-doc8-help
129 - Display extended help for ``lint-doc8`` targets
130 * -
131 -
132 * - lint-doc8
133 - Build system lint target used to syntax check restructuredText sources.
134 * - lint-doc8-all
135 - Filesystem traversal, check all ``*.rst`` sources.
136 * - lint-doc8-mod
137 - Syntax check locally modified files (~git status)
138 * - lint-doc8-src
139 - Syntax check a list of files passed in as an argument.
140 * -
141 -
142 * - lint-doc8-install
143 - Dependency driven installation of the doc8 tool.
144
Joey Armstrong4de98b72023-02-09 14:51:38 -0500145.. code:: bash
146
147 make clean
Joey Armstronga9a16b62023-11-01 14:31:15 -0400148 make lint-doc8 2>&1 | tee log
Joey Armstrong4de98b72023-02-09 14:51:38 -0500149
Joey Armstronga9a16b62023-11-01 14:31:15 -0400150 make lint # supported by repositories that define lint-doc8 as a default target.
Joey Armstrong4de98b72023-02-09 14:51:38 -0500151
Joey Armstronga9a16b62023-11-01 14:31:15 -0400152.. list-table:: Sources
153 :widths: 20, 60
154 :header-rows: 1
Joey Armstrong4de98b72023-02-09 14:51:38 -0500155
Joey Armstronga9a16b62023-11-01 14:31:15 -0400156 * - Source
157 - Description
158 * - `makefiles/lint/doc8/include.mk <http://gerrit.opencord.org/plugins/gitiles/onf-make/+/refs/heads/master/makefiles/lint/doc8/include.mk>`_
159 - Main makefile logic for syntax checking RST sources.
160 * - `makefiles/lint/doc8/install.mk <https://gerrit.opencord.org/plugins/gitiles/onf-make/+/refs/heads/master/makefiles/lint/doc8/install.mk>`_
161 - Dependency logic to install the doc8 tool when needed.
162 * - `makefiles/lint/doc8/excl.mk <https://gerrit.opencord.org/plugins/gitiles/onf-make/+/refs/heads/master/makefiles/lint/doc8/install.mk>`_
163 - Common doc8 exclusion patterns for all repositories.
164
165See Also
166--------
Joey Armstrong4de98b72023-02-09 14:51:38 -0500167
Joey Armstrong1b8fdc32023-12-20 17:22:57 -0500168- lint-doc8-all target dependency will create a `python virtual env <https://wiki.opencord.org>`_
Joey Armstrong4de98b72023-02-09 14:51:38 -0500169- python 3.10+ requires `virtual env patching <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/patches/>`_ (dynamic, applied when needed).
Joey Armstrong644fb652023-10-02 13:12:20 -0400170- `makefiles/patches/include.mk <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/makefiles-orig/patches/>`__
Joey Armstrong4de98b72023-02-09 14:51:38 -0500171
172|
173
174
175python: flake8
Joey Armstronga9a16b62023-11-01 14:31:15 -0400176==============
Joey Armstrong4de98b72023-02-09 14:51:38 -0500177
178Command: `flake8 <https://flake8.pycqa.org/en/latest>`_
179
180.. code:: bash
181
182 make clean
183 make lint 2>&1 | tee log
184 make lint-flake8-all 2>&1 | tee log
185 make lint-flake8-modified 2>&1 | tee log
186
187Sources:
188
Joey Armstrong644fb652023-10-02 13:12:20 -0400189- `makefiles/lint <https://gerrit.opencord.org/plugins/gitiles/onf-make/+/refs/heads/master/makefiles/lint/>`__
Joey Armstrong4de98b72023-02-09 14:51:38 -0500190- makefiles/lint/flake8.mk
191
192Notes:
193
Joey Armstrong1b8fdc32023-12-20 17:22:57 -0500194- lint-flake8-all target dependency will create a `python virtual env <https://wiki.opencord.org>`_
Joey Armstrong4de98b72023-02-09 14:51:38 -0500195- python 3.10+ requires `virtual env patching <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/patches/>`_ (dynamic, applied when needed).
Joey Armstrong644fb652023-10-02 13:12:20 -0400196- `makefiles/patches/include.mk <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/makefiles-orig/patches/>`__
Joey Armstrong4de98b72023-02-09 14:51:38 -0500197
198|
199
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500200Golang
Joey Armstronga9a16b62023-11-01 14:31:15 -0400201======
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500202
203Command:
204
205Sources:
206
Joey Armstrong644fb652023-10-02 13:12:20 -0400207- `makefiles/lint <https://gerrit.opencord.org/plugins/gitiles/onf-make/+/refs/heads/master/makefiles/lint/>`__
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500208
209|
210
Joey Armstrongb544dff2022-12-07 15:12:05 -0500211
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500212JSON
Joey Armstronga9a16b62023-11-01 14:31:15 -0400213====
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500214
Joey Armstrong4de98b72023-02-09 14:51:38 -0500215Command: `json.tool <https://docs.python.org/3/library/json.html>`_
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500216
217.. code:: bash
218
219 make clean
Joey Armstrong4de98b72023-02-09 14:51:38 -0500220 make lint 2>&1 | tee log
221 make lint-json-all 2>&1 | tee log
222 make lint-json-modified 2>&1 | tee log
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500223
224Sources:
225
Joey Armstrong644fb652023-10-02 13:12:20 -0400226- `makefiles/lint <https://gerrit.opencord.org/plugins/gitiles/onf-make/+/refs/heads/master/makefiles/lint/>`__
227- `makefiles/lint/json.mk <https://gerrit.opencord.org/plugins/gitiles/onf-make/+/refs/heads/master/makefiles/lint/json.mk>`_
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500228
229|
230
231
232License / Copyright notice
Joey Armstronga9a16b62023-11-01 14:31:15 -0400233==========================
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500234
235Command:
236
237.. code:: bash
238
239 make clean
240 make lint-license 2>&1 | tee log
241
242Sources:
243
244- `makefiles/lint <https://gerrit.opencord.org/plugins/gitiles/voltha-system-tests/+/refs/heads/master/makefiles/lint>`__
Joey Armstrong8b426fc2023-11-14 16:09:11 -0500245- `makefiles/lint/license.mk <http://gerrit.opencord.org/plugins/gitiles/voltha-system-tests/+/refs/heads/master/makefiles/lint/license/include.mk>`_
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500246
247|
248
249
Joey Armstrong4de98b72023-02-09 14:51:38 -0500250python: pylint
Joey Armstronga9a16b62023-11-01 14:31:15 -0400251==============
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500252
Joey Armstrong8b426fc2023-11-14 16:09:11 -0500253Command: `pylint <http://github.com/pylint-dev/pylint>`_, `pypi.org <https://pypi.org/project/pylint/>`_
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500254
255.. code:: bash
256
257 make clean
Joey Armstrong4de98b72023-02-09 14:51:38 -0500258 make lint 2>&1 | tee log
259 make lint-pylint-all 2>&1 | tee log
260 make lint-pylint-modified 2>&1 | tee log
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500261
262Sources:
263
Joey Armstrong644fb652023-10-02 13:12:20 -0400264- `makefiles/lint <https://gerrit.opencord.org/plugins/gitiles/onf-make/+/refs/heads/master/makefiles/lint/>`__
Joey Armstrong4de98b72023-02-09 14:51:38 -0500265- makefiles/lint/pylint.mk
Joey Armstrong644fb652023-10-02 13:12:20 -0400266- `makefiles/patches/include.mk <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/makefiles-orig/patches/>`__
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500267
268Notes:
269
Joey Armstrongbd6cc3d2023-01-09 19:52:12 -0500270- pylint the --py3k option is no longer supported by v3.10+
Joey Armstrong1b8fdc32023-12-20 17:22:57 -0500271- lint-pylint-all target dependency will create a `python virtual env <https://wiki.opencord.org>`_
Joey Armstrongbd6cc3d2023-01-09 19:52:12 -0500272- python 3.10+ requires `virtual env patching <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master/patches/>`_ (dynamic, applied when needed).
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500273
274|
275
276
Joey Armstronga9a16b62023-11-01 14:31:15 -0400277Shell / Command Line Scripts
278============================
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500279
280Command: `shellcheck <https://github.com/koalaman/shellcheck>`_
281
Joey Armstrong4de98b72023-02-09 14:51:38 -0500282.. code:: bash
283
284 make clean
285 make lint 2>&1 | tee log
286 make lint-shell-all 2>&1 | tee log
287 make lint-shell-modified 2>&1 | tee log
288
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500289Sources:
290
Joey Armstrong644fb652023-10-02 13:12:20 -0400291- `makefiles/lint <https://gerrit.opencord.org/plugins/gitiles/onf-make/+/refs/heads/master/makefiles/lint/>`__
Joey Armstrong8b426fc2023-11-14 16:09:11 -0500292- `makefiles/lint/shell.mk <https://gerrit.opencord.org/plugins/gitiles/onf-make/+/refs/heads/master/makefiles/lint/shell/include.mk>`_
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500293
294|
295
296
297Yaml
Joey Armstronga9a16b62023-11-01 14:31:15 -0400298====
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500299
Joey Armstrong4de98b72023-02-09 14:51:38 -0500300Command: `yamllint <https://yamllint.readthedocs.io/en/stable/>`_
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500301
302.. code:: bash
303
304 make clean
Joey Armstrong4de98b72023-02-09 14:51:38 -0500305 make lint 2>&1 | tee log
306 make lint-yaml-all 2>&1 | tee log
307 make lint--modified 2>&1 | tee log
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500308
309Sources:
310
Joey Armstrong644fb652023-10-02 13:12:20 -0400311- `makefiles/lint <https://gerrit.opencord.org/plugins/gitiles/onf-make/+/refs/heads/master/makefiles/lint/>`__
312- `makefiles/lint/yaml.mk <https://gerrit.opencord.org/plugins/gitiles/onf-make/+/refs/heads/master/makefiles/lint/yaml.mk>`_
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500313
314|
315
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500316
317Bugs
Joey Armstronga9a16b62023-11-01 14:31:15 -0400318====
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500319
320- `jira::VOLTHA <https://jira.opencord.org/projects/VOL>`-
321- Include repository URL
322- Include gerrit/github changeset if available.
323- A logfile snippet of the error and surrounding context.
324
Joey Armstrongb544dff2022-12-07 15:12:05 -0500325|
326
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500327
328Repositories
Joey Armstronga9a16b62023-11-01 14:31:15 -0400329============
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500330
331- [`master <https://gerrit.opencord.org/plugins/gitiles/bbsim/+/refs/heads/master>`__] `bbsim <https://gerrit.opencord.org/plugins/gitiles/bbsim>`_
332- [`master <https://gerrit.opencord.org/plugins/gitiles/pod-configs/+/refs/heads/master>`__] `pod-configs <https://gerrit.opencord.org/plugins/gitiles/pod-configs>`_
333- [`master <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master>`__] `voltha-docs <https://gerrit.opencord.org/plugins/gitiles/voltha-docs>`_
334- [`master <https://gerrit.opencord.org/plugins/gitiles/voltha-helm-charts/+/refs/heads/master>`__] `voltha-helm-charts <https://gerrit.opencord.org/plugins/gitiles/voltha-helm-charts>`_
Joey Armstrong4de98b72023-02-09 14:51:38 -0500335- [`master <https://gerrit.opencord.org/plugins/gitiles/voltha-docs/+/refs/heads/master>`__] `voltha-docs <https://gerrit.opencord.org/plugins/gitiles/voltha-docs>`_
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500336
Joey Armstrongb544dff2022-12-07 15:12:05 -0500337|
338
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500339
340Notes
Joey Armstronga9a16b62023-11-01 14:31:15 -0400341=====
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500342
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500343- Volume problem reports require cleanup before linting can become a default.
Joey Armstrong4de98b72023-02-09 14:51:38 -0500344
345 - After bulk linting problems for a language source have been cleaned up
346 default linting can be enabled by modifing {project-root}/config.mk.
347
Joey Armstronga8bc8e12022-12-04 07:06:59 -0500348- Lint target support is globally available across repositories, given time
349 it will be. Submit patches as needed or open a jira ticket to request
350 linting support in specific repositories.
351- Makefile refactoring: yes absolutely! Baby steps are needed in the interim...
Joey Armstrongb544dff2022-12-07 15:12:05 -0500352
353|