Add a (disabled) code-smell test for detecting _ variables

We are reserving the _ identifier for i18n work.  Code should use the
identifier dummy for dummy variables instead.

This test is currently skipped as someone needs to generate the list of
files which are currently out of compliance before this can be turned
on.
This commit is contained in:
Toshio Kuratomi 2017-08-04 09:14:35 -07:00
commit 44935a5db6
3 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1,28 @@
Sanity Tests » no-underscore-variable
=====================================
In the future, Ansible may use the identifier ``_`` to internationalize its
message strings. To be ready for that, we need to make sure that there are
no conflicting identifiers defined in the code base.
In common practice, ``_`` is frequently used as a dummy variable (a variable
to receive a value from a function where the value is useless and never used).
In Ansible, we're using the identifier ``dummy`` for this purpose instead.
Example of unfixed code:
.. code-block:: python
for _ in range(0, retries):
success = retry_thing()
if success:
break
Example of fixed code:
.. code-block:: python
for dummy in range(0, retries):
success = retry_thing()
if success:
break