2 # Setup the Python paths needed for our tests. This is a bit tricky due to the
3 # fact that we want to be able to run pylint with and without the --rcfile
4 # option. Pylint offers pylint.config.PYLINTRC to get the path to the
5 # automatically found config file, but this doesn't take --rcfile into account.
6 # So we have to fall back to a slightly hacky method discussed in the post
7 # https://mail.python.org/pipermail/code-quality/2016-June/000781.html,
8 # accessing pylint's innards. Not nice, but there is not much we can do about
9 # this until pylint offers the API requested in the post above. Furthermore,
10 # note that layout/indentation doesn't work too well in the hook below.
12 import inspect, os, sys
13 config_file = inspect.stack()[2][0].f_locals["linter"].config_file
14 tests_dir = os.path.join(os.path.dirname(config_file), "tests")
15 sys.path.insert(0, os.environ.get("TEST_PATH", tests_dir))
17 load-plugins=testlib.pylint_cmk,testlib.pylint_checker_localization
19 # TODO: Why do we need persistence?
21 extension-pkg-whitelist=rrdtool,_ldap,netifaces,pymssql
25 #---------------------------------------------------------------------------
26 # We should really enable this, there could be some real exceptions waiting
27 # to be thrown. But some work is needed first to sprinkle abc annotations
28 # through our code and fix a few obscure places.
30 #---------------------------------------------------------------------------
31 # Enabling this would be very desirable, it vastly improves readability and
32 # it might even be necessary for tools like mypy. Fixing this involves some
33 # amount of relatively easy work, especially if we want to avoid code
34 # duplication (introduce new classes, combine methods, etc.)
35 attribute-defined-outside-init,
36 #---------------------------------------------------------------------------
37 # Enabling these warnings would be nice, they are mostly a sign of sloppy
38 # programming practice. In some cases, they can even hide bugs.
41 #---------------------------------------------------------------------------
42 # Enabling this would enhance readability quite a bit and it might even
43 # uncover bugs. Fixing this is not rocket science, just some work.
44 inconsistent-return-statements,
45 #---------------------------------------------------------------------------
46 # Enabling this would enhance readability quite a bit and it might even
47 # uncover bugs. Fixing this is not rocket science, just some work: Roughly
48 # 400 warnings in about 60 modules, but this can be fixed step by step.
50 #---------------------------------------------------------------------------
51 # Enabling this would be nice, but not crucial. Nevertheless, this would
52 # improve readability and involve some cleanups in our class hierarchy, so
53 # we should do this some day.
55 #---------------------------------------------------------------------------
56 # Enabling this would be nice, but not crucial. At the moment, we have quite
57 # a few violations, so we postpone fixing this.
59 #---------------------------------------------------------------------------
60 # Enabling this would be nice, but not crucial. At the moment, we have quite
61 # a few violations (about 220 in roughly 40 modules), so we postpone fixing
62 # this. Note that due to our arcane use of types, we need to be very careful
63 # when fixing these warnings!
65 #---------------------------------------------------------------------------
66 # Enabling this would be nice, but not crucial. At the moment, we have quite
67 # a few violations, so we postpone fixing this. When we do it eventually, we
68 # probably want to use "include-naming-hint=yes" in the BASIC section.
70 #---------------------------------------------------------------------------
71 # Enable these would improve readability, but currently there are quite a
73 wrong-import-position,
74 #---------------------------------------------------------------------------
75 # Enabling this would be nice, but not crucial. At the moment, we have quite
76 # a few violations, so we postpone fixing this.
78 #---------------------------------------------------------------------------
79 # Alas, these maintenance/security nightmares are still part of our base
80 # "technology"... :-/ Nevertheless, reducing their usage is a very worthy
85 #---------------------------------------------------------------------------
86 # Enabling these would be nice, but given the current state of affairs
87 # (gigantic modules with deeply nested humungous functions/methods), this
88 # will be a non-trivial amount of work.
89 too-few-public-methods,
91 too-many-boolean-expressions,
92 too-many-instance-attributes,
95 too-many-nested-blocks,
96 too-many-public-methods,
97 too-many-return-statements,
99 #---------------------------------------------------------------------------
100 # Enabling these would be nice, but at the moment pylint is a bit too dumb,
101 # so it stumbles over e.g. initialization with None. It ignores control
102 # flow, so even adding e.g. isinstance() guards wouldn't help, see:
103 # https://github.com/PyCQA/pylint/issues/1498.
104 unsubscriptable-object,
105 unsupported-membership-test,
106 #---------------------------------------------------------------------------
107 # Our code is still full of FIXMEs/XXXs/TODOs, perhaps fixing or removing
108 # them might be a good idea some day...
110 #---------------------------------------------------------------------------
111 # The warnigns below will probably fixed by YAPF.
115 #---------------------------------------------------------------------------
116 # We are light years away from enabling this...
118 #---------------------------------------------------------------------------
119 # Enabling the two spelling-related checks increases pylints runtime from
120 # 11 min to 40 min, so we better keep those disabled for normal runs.
121 wrong-spelling-in-comment,
122 wrong-spelling-in-docstring,
125 output-format=cmk_colorized
126 msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}