Browse Source

Enable pylint zuul check for configutilities

The pylint checks that fail are being suppressed.
Those checks will be fixed and un-suppressed in later commits.

Story: 2004515
Task: 29298
Change-Id: Iacc18da64ed5e2d82ff2f3e64368c9b4a94bb1d5
Signed-off-by: Al Bailey <Al.Bailey@windriver.com>
Al Bailey 2 months ago
parent
commit
a3c261a3aa

+ 14
- 0
.zuul.yaml View File

@@ -15,6 +15,7 @@
15 15
         - controllerconfig-tox-py27
16 16
         - controllerconfig-tox-pylint
17 17
         - configutilities-tox-flake8
18
+        - configutilities-tox-pylint
18 19
         - stx-devstack-config:
19 20
             voting: false
20 21
         - cgtsclient-tox-py27
@@ -35,6 +36,7 @@
35 36
         - controllerconfig-tox-py27
36 37
         - controllerconfig-tox-pylint
37 38
         - configutilities-tox-flake8
39
+        - configutilities-tox-pylint
38 40
         - cgtsclient-tox-py27
39 41
         - cgtsclient-tox-pep8
40 42
         - cgtsclient-tox-pylint
@@ -148,6 +150,18 @@
148 150
       tox_envlist: flake8
149 151
       tox_extra_args: -c configutilities/configutilities/tox.ini
150 152
 
153
+- job:
154
+    name: configutilities-tox-pylint
155
+    parent: tox
156
+    description: Run pylint tests for configutilities
157
+    required-projects:
158
+      - openstack/stx-update
159
+    files:
160
+      - configutilities/*
161
+    vars:
162
+      tox_envlist: pylint
163
+      tox_extra_args: -c configutilities/configutilities/tox.ini
164
+
151 165
 - job:
152 166
     name: stx-devstack-config
153 167
     parent: stx-devstack-base

+ 1
- 1
configutilities/configutilities/configutilities/common/utils.py View File

@@ -331,7 +331,7 @@ def extract_openstack_password_rules_from_file(
331 331
         config = configparser.RawConfigParser()
332 332
         parsed_config = config.read(rules_file)
333 333
         if not parsed_config:
334
-            msg = ("Cannot parse rules file: %" % rules_file)
334
+            msg = ("Cannot parse rules file: %s" % rules_file)
335 335
             raise Exception(msg)
336 336
         if not config.has_section(section):
337 337
             msg = ("Required section '%s' not found in rules file" % section)

+ 233
- 0
configutilities/configutilities/pylint.rc View File

@@ -0,0 +1,233 @@
1
+[MASTER]
2
+# Specify a configuration file.
3
+rcfile=pylint.rc
4
+
5
+# Python code to execute, usually for sys.path manipulation such as pygtk.require().
6
+#init-hook=
7
+
8
+# Add files or directories to the blacklist. They should be base names, not paths.
9
+ignore=tests
10
+
11
+# Pickle collected data for later comparisons.
12
+persistent=yes
13
+
14
+# List of plugins (as comma separated values of python modules names) to load,
15
+# usually to register additional checkers.
16
+load-plugins=
17
+
18
+
19
+[MESSAGES CONTROL]
20
+# Enable the message, report, category or checker with the given id(s). You can
21
+# either give multiple identifier separated by comma (,) or put this option
22
+# multiple time.
23
+#enable=
24
+
25
+# Disable the message, report, category or checker with the given id(s). You
26
+# can either give multiple identifier separated by comma (,) or put this option
27
+# multiple time (only on the command line, not in the configuration file where
28
+# it should appear only once).
29
+# https://pylint.readthedocs.io/en/latest/user_guide/output.html#source-code-analysis-section
30
+# We are disabling (C)onvention
31
+# We are disabling (R)efactor
32
+# The following warnings should be fixed:
33
+# fixme (todo, xxx, fixme)
34
+# W0102: dangerous-default-value
35
+# W0106: expression-not-assigned
36
+# W0107: unnecessary-pass
37
+# W0201: attribute-defined-outside-init
38
+# W0231: super-init-not-called
39
+# W0235: useless-super-delegation
40
+# W0311: bad-indentation
41
+# W0603: global-statement
42
+# W0611: unused-import
43
+# W0612: unused-variable
44
+# W0613: unused-argument
45
+# W0622: redefined-builtin
46
+# W0703: broad-except
47
+# W1401: anomalous-backslash-in-string
48
+# E0401: import-error
49
+# E1101: no-member
50
+disable=C, R, fixme, W0102, W0106, W0107, W0201, W0231, W0235, W0311,
51
+        W0603, W0611, W0612, W0613, W0622, W0703, W1401, E0401, E1101
52
+
53
+[REPORTS]
54
+# Set the output format. Available formats are text, parseable, colorized, msvs
55
+# (visual studio) and html
56
+output-format=text
57
+
58
+# Put messages in a separate file for each module / package specified on the
59
+# command line instead of printing them on stdout. Reports (if any) will be
60
+# written in a file name "pylint_global.[txt|html]".
61
+files-output=no
62
+
63
+# Tells whether to display a full report or only the messages
64
+reports=no
65
+
66
+# Python expression which should return a note less than 10 (10 is the highest
67
+# note). You have access to the variables errors warning, statement which
68
+# respectively contain the number of errors / warnings messages and the total
69
+# number of statements analyzed. This is used by the global evaluation report
70
+# (RP0004).
71
+evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
72
+
73
+
74
+[SIMILARITIES]
75
+# Minimum lines number of a similarity.
76
+min-similarity-lines=4
77
+
78
+# Ignore comments when computing similarities.
79
+ignore-comments=yes
80
+
81
+# Ignore docstrings when computing similarities.
82
+ignore-docstrings=yes
83
+
84
+
85
+[FORMAT]
86
+# Maximum number of characters on a single line.
87
+max-line-length=85
88
+
89
+# Maximum number of lines in a module
90
+max-module-lines=1000
91
+
92
+# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 tab).
93
+indent-string='    '
94
+
95
+
96
+[TYPECHECK]
97
+# Tells whether missing members accessed in mixin class should be ignored. A
98
+# mixin class is detected if its name ends with "mixin" (case insensitive).
99
+ignore-mixin-members=yes
100
+
101
+# List of classes names for which member attributes should not be checked
102
+# (useful for classes with attributes dynamically set).
103
+ignored-classes=SQLObject
104
+
105
+# List of members which are set dynamically and missed by pylint inference
106
+# system, and so shouldn't trigger E0201 when accessed. Python regular
107
+# expressions are accepted.
108
+generated-members=REQUEST,acl_users,aq_parent
109
+
110
+
111
+[BASIC]
112
+# List of builtins function names that should not be used, separated by a comma
113
+bad-functions=map,filter,apply,input
114
+
115
+# Regular expression which should only match correct module names
116
+module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
117
+
118
+# Regular expression which should only match correct module level names
119
+const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
120
+
121
+# Regular expression which should only match correct class names
122
+class-rgx=[A-Z_][a-zA-Z0-9]+$
123
+
124
+# Regular expression which should only match correct function names
125
+function-rgx=[a-z_][a-z0-9_]{2,30}$
126
+
127
+# Regular expression which should only match correct method names
128
+method-rgx=[a-z_][a-z0-9_]{2,30}$
129
+
130
+# Regular expression which should only match correct instance attribute names
131
+attr-rgx=[a-z_][a-z0-9_]{2,30}$
132
+
133
+# Regular expression which should only match correct argument names
134
+argument-rgx=[a-z_][a-z0-9_]{2,30}$
135
+
136
+# Regular expression which should only match correct variable names
137
+variable-rgx=[a-z_][a-z0-9_]{2,30}$
138
+
139
+# Regular expression which should only match correct list comprehension /
140
+# generator expression variable names
141
+inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
142
+
143
+# Good variable names which should always be accepted, separated by a comma
144
+good-names=i,j,k,ex,Run,_
145
+
146
+# Bad variable names which should always be refused, separated by a comma
147
+bad-names=foo,bar,baz,toto,tutu,tata
148
+
149
+# Regular expression which should only match functions or classes name which do
150
+# not require a docstring
151
+no-docstring-rgx=__.*__
152
+
153
+
154
+[MISCELLANEOUS]
155
+# List of note tags to take in consideration, separated by a comma.
156
+notes=FIXME,XXX,TODO
157
+
158
+
159
+[VARIABLES]
160
+# Tells whether we should check for unused import in __init__ files.
161
+init-import=no
162
+
163
+# A regular expression matching the beginning of the name of dummy variables
164
+# (i.e. not used).
165
+dummy-variables-rgx=_|dummy
166
+
167
+# List of additional names supposed to be defined in builtins. Remember that
168
+# you should avoid to define new builtins when possible.
169
+additional-builtins=
170
+
171
+
172
+[IMPORTS]
173
+# Deprecated modules which should not be used, separated by a comma
174
+deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
175
+
176
+# Create a graph of every (i.e. internal and external) dependencies in the
177
+# given file (report RP0402 must not be disabled)
178
+import-graph=
179
+
180
+# Create a graph of external dependencies in the given file (report RP0402 must
181
+# not be disabled)
182
+ext-import-graph=
183
+
184
+# Create a graph of internal dependencies in the given file (report RP0402 must
185
+# not be disabled)
186
+int-import-graph=
187
+
188
+
189
+[DESIGN]
190
+# Maximum number of arguments for function / method
191
+max-args=5
192
+
193
+# Argument names that match this expression will be ignored. Default to name
194
+# with leading underscore
195
+ignored-argument-names=_.*
196
+
197
+# Maximum number of locals for function / method body
198
+max-locals=15
199
+
200
+# Maximum number of return / yield for function / method body
201
+max-returns=6
202
+
203
+# Maximum number of branch for function / method body
204
+max-branchs=12
205
+
206
+# Maximum number of statements in function / method body
207
+max-statements=50
208
+
209
+# Maximum number of parents for a class (see R0901).
210
+max-parents=7
211
+
212
+# Maximum number of attributes for a class (see R0902).
213
+max-attributes=7
214
+
215
+# Minimum number of public methods for a class (see R0903).
216
+min-public-methods=2
217
+
218
+# Maximum number of public methods for a class (see R0904).
219
+max-public-methods=20
220
+
221
+
222
+[CLASSES]
223
+# List of method names used to declare (i.e. assign) instance attributes.
224
+defining-attr-methods=__init__,__new__,setUp
225
+
226
+# List of valid names for the first argument in a class method.
227
+valid-classmethod-first-arg=cls
228
+
229
+
230
+[EXCEPTIONS]
231
+# Exceptions that will emit a warning when being caught. Defaults to
232
+# "Exception"
233
+overgeneral-exceptions=Exception

+ 13
- 1
configutilities/configutilities/tox.ini View File

@@ -4,9 +4,11 @@
4 4
 # and then run "tox" from this directory.
5 5
 
6 6
 [tox]
7
-envlist = flake8
7
+envlist = flake8,pylint
8 8
 # Tox does not work if the path to the workdir is too long, so move it to /tmp
9 9
 toxworkdir = /tmp/{env:USER}_ccutiltox
10
+stxdir = {toxinidir}/../../..
11
+
10 12
 
11 13
 [testenv]
12 14
 whitelist_externals = find
@@ -32,3 +34,13 @@ commands = flake8 {posargs}
32 34
 [flake8]
33 35
 ignore = H102,H104,H306,H401,H403,H404,H405
34 36
 exclude = dist,build
37
+
38
+[testenv:pylint]
39
+basepython = python3
40
+sitepackages = False
41
+
42
+deps = -r{toxinidir}/test-requirements.txt
43
+       -e{[tox]stxdir}/stx-update/tsconfig/tsconfig
44
+       pylint
45
+commands =
46
+     pylint {posargs} configutilities --rcfile=./pylint.rc

Loading…
Cancel
Save