File: lint-sub-command.rst

package info (click to toggle)
modules 5.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,036 kB
  • sloc: exp: 79,659; sh: 6,142; tcl: 5,900; makefile: 1,492; ansic: 474; python: 265; csh: 202; perl: 47; ruby: 44; lisp: 13
file content (129 lines) | stat: -rw-r--r-- 4,413 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
.. _lint-sub-command:

lint sub-command
================

Goal is to provide a :subcmd:`lint` sub-command to check syntax of
modulefiles.


Configuration
-------------

* :mconfig:`tcl_linter` configuration option defines linter program to use and
  its options

  * ``nagelfar.tcl`` is the default
  * :instopt:`--with-tcl-linter` and :instopt:`--with-tcl-linter-opts`
    installation options help to change this default at installation time
  * When changed with :subcmd:`config` sub-command, :envvar:`MODULES_LINTER`
    environment variable is set

* Tcl linter program defined is checked for existence by ``configure`` script

  * Use fully qualified path resolved if found
  * Print a warning message if not found
  * No error if not found as :subcmd:`lint` is not the central use case

    * Could be configured or installed after Modules installation

* :instopt:`--enable-nagelfar-addons` installation option defines if
  Nagelfar-specific syntax databases and plugins to lint modulefiles have to
  be installed.

  * Specific syntax databases and plugins to lint modulefiles, modulerc,
    modulecache and global/user rc are not enabled if this option is disabled

* :instopt:`--nagelfardatadir` installation option defines where to install
  Nagelfar-specific files to lint modulefiles.


Sub-command properties
----------------------

General properties:

* Shortcut name: none
* Accepted option: ``--all``, ``--icase``
* Expected number of argument: 0 to N
* Accept boolean variant specification: no
* Parse module version specification: yes
* Fully read modulefile when checking validity: no
* Sub-command only called from top level: yes

Sub-command acts similarly than :subcmd:`edit` sub-command:

* Resolves each specification passed as argument to a single modulefile
* Modulefile could be specified with icase, extended_default and
  advanced_version_spec features

  * But no boolean specification, as we are looking for modulefiles, not a
    module variant

* Call an external command over the resolved modulefiles

In case no argument is provided, it means to select everything:

* Every global and user rc file
* Every .modulecache in enabled modulepaths
* Every .modulerc and .version files in enabled modulepaths
* Every available modulefiles in enabled modulepaths
* Include modules declared forbidden
* If ``--all`` option set also select all hidden modulefiles in enabled
  modulepaths

Arguments could also be a file path:

* need to distinguish if it is a global/user rc file, a modulerc or a
  modulefile to accurately lint designated file
* file is considered a global/user rc file if file path corresponds to user or
  global rc file location
* file is considered a modulerc if filename equals ``.version`` or
  ``.modulerc``
* file is considered a modulecache if filename equals ``.modulecache``
* otherwise file is considered a modulefile

Processing is aborted as soon as one lint command execution fails


Nagelfar linting
----------------

* Analyze full content of designated files
* It does not evaluate files sourced by designated files
* If :instopt:`--enable-nagelfar-addons` is enabled (default) a specific
  syntax database and plugin is added to the Nagelfar command line to lint
  specified file depending on its type (global/user rc, modulerc, modulecache
  or modulefile)

  * Modulefile command, their options and syntaxes are checked based on this
    file type
  * Since not the same command set can be used in global/user rc file, in
    modulerc, modulecache and modulefile


Report output
-------------

* New message block: ``Linting <modulefile>``
* All messages produced by Nagelfar reported under modulefile message block
* Parse Nagelfar messages to report in a structured way:

  * ``<SEVERITY> line <line_number>: message``
  * Message is output as a block in case it consists of several lines
  * All message prefix (prior ``:``) is highlighted based on severity
  * Nagelfar severities mapped to Modules severities:

    * W = WARNING (sgrkey: wa)
    * E = ERROR (sgrkey: er)
    * N = NOTICE (sgrkey: in)

* Output and verbosity levels:

  * By default, do not output message block if no message to report for
    modulefile
  * If verbose mode set, report empty block if no linting message
  * If silent mode set, report nothing, exit code helps to know if linter has
    reported error

.. vim:set tabstop=2 shiftwidth=2 expandtab autoindent: