mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Replace no-underscore-variable test with pylint. (#54140)
* Replace no-underscore-variable test with pylint. * Update orphan handling for sanity test docs. * Update command for listing tests.
This commit is contained in:
parent
98fdbf6a13
commit
39bbadb2fd
8 changed files with 142 additions and 149 deletions
|
@ -9,14 +9,14 @@ Sanity Tests
|
|||
============
|
||||
|
||||
The following sanity tests are available as \`\`--test\`\` options for \`\`ansible-test sanity\`\`.
|
||||
This list is also available using \`\`ansible-test sanity --list-tests\`\`.
|
||||
This list is also available using \`\`ansible-test sanity --list-tests --allow-disabled\`\`.
|
||||
|
||||
For information on how to run these tests, see :ref:\`sanity testing guide <testing_sanity>\`.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
$(for test in $(../../test/runner/ansible-test sanity --list-tests); do echo " ${test}"; done)
|
||||
$(for test in $(../../test/runner/ansible-test sanity --list-tests --allow-disabled); do echo " ${test}"; done)
|
||||
|
||||
EOF
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
:orphan:
|
||||
|
||||
Sanity Tests » docs-build
|
||||
=========================
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
:orphan:
|
||||
|
||||
Sanity Tests » no-underscore-variable
|
||||
=====================================
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"extensions": [
|
||||
".py"
|
||||
],
|
||||
"output": "path-line-column-message"
|
||||
}
|
|
@ -1,138 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Only needed until we can enable a pylint test for this. We may have to write
|
||||
# one or add it to another existing test (like the one to warn on inappropriate
|
||||
# variable names). Adding to an existing test may be hard as we may have many
|
||||
# other things that are not compliant with that test.
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
skip = set([
|
||||
'test/sanity/code-smell/%s' % os.path.basename(__file__),
|
||||
# These files currently use _ as a variable. Fix them and then remove them
|
||||
# from this list. Note that we're not sure if we'll translate module return
|
||||
# values. If we decide never to do that, then we can stop checking for those.
|
||||
'contrib/inventory/gce.py',
|
||||
'lib/ansible/cli/console.py',
|
||||
'lib/ansible/compat/selectors/_selectors2.py',
|
||||
'lib/ansible/executor/playbook_executor.py',
|
||||
'lib/ansible/executor/task_queue_manager.py',
|
||||
'lib/ansible/module_utils/facts/network/linux.py',
|
||||
'lib/ansible/module_utils/urls.py',
|
||||
'lib/ansible/modules/cloud/amazon/data_pipeline.py',
|
||||
'lib/ansible/modules/cloud/amazon/ec2_group_facts.py',
|
||||
'lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway.py',
|
||||
'lib/ansible/modules/cloud/amazon/ec2_vpc_vpn.py',
|
||||
'lib/ansible/modules/cloud/amazon/efs.py',
|
||||
'lib/ansible/modules/cloud/amazon/efs_facts.py',
|
||||
'lib/ansible/modules/cloud/amazon/kinesis_stream.py',
|
||||
'lib/ansible/modules/cloud/amazon/route53_zone.py',
|
||||
'lib/ansible/modules/cloud/amazon/s3_sync.py',
|
||||
'lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py',
|
||||
'lib/ansible/modules/cloud/google/_gce.py',
|
||||
'lib/ansible/modules/cloud/google/gce_eip.py',
|
||||
'lib/ansible/modules/cloud/google/gce_img.py',
|
||||
'lib/ansible/modules/cloud/google/gce_instance_template.py',
|
||||
'lib/ansible/modules/cloud/google/gce_lb.py',
|
||||
'lib/ansible/modules/cloud/google/gce_mig.py',
|
||||
'lib/ansible/modules/cloud/google/gce_net.py',
|
||||
'lib/ansible/modules/cloud/google/gce_pd.py',
|
||||
'lib/ansible/modules/cloud/google/gce_snapshot.py',
|
||||
'lib/ansible/modules/cloud/google/gce_tag.py',
|
||||
'lib/ansible/modules/cloud/google/gcp_backend_service.py',
|
||||
'lib/ansible/modules/cloud/google/gcp_healthcheck.py',
|
||||
'lib/ansible/modules/cloud/lxc/lxc_container.py',
|
||||
'lib/ansible/modules/files/copy.py',
|
||||
'lib/ansible/modules/files/patch.py',
|
||||
'lib/ansible/modules/files/synchronize.py',
|
||||
'lib/ansible/modules/monitoring/statusio_maintenance.py',
|
||||
'lib/ansible/modules/monitoring/zabbix/zabbix_maintenance.py',
|
||||
'lib/ansible/modules/net_tools/basics/uri.py',
|
||||
'lib/ansible/modules/network/cloudengine/ce_acl.py',
|
||||
'lib/ansible/modules/network/cloudengine/ce_command.py',
|
||||
'lib/ansible/modules/network/cloudengine/ce_dldp_interface.py',
|
||||
'lib/ansible/modules/network/cloudengine/ce_mlag_interface.py',
|
||||
'lib/ansible/modules/network/cloudvision/cv_server_provision.py',
|
||||
'lib/ansible/modules/network/f5/bigip_remote_syslog.py',
|
||||
'lib/ansible/modules/network/illumos/dladm_etherstub.py',
|
||||
'lib/ansible/modules/network/illumos/dladm_iptun.py',
|
||||
'lib/ansible/modules/network/illumos/dladm_linkprop.py',
|
||||
'lib/ansible/modules/network/illumos/dladm_vlan.py',
|
||||
'lib/ansible/modules/network/illumos/dladm_vnic.py',
|
||||
'lib/ansible/modules/network/illumos/flowadm.py',
|
||||
'lib/ansible/modules/network/illumos/ipadm_addr.py',
|
||||
'lib/ansible/modules/network/illumos/ipadm_addrprop.py',
|
||||
'lib/ansible/modules/network/illumos/ipadm_if.py',
|
||||
'lib/ansible/modules/network/illumos/ipadm_ifprop.py',
|
||||
'lib/ansible/modules/network/illumos/ipadm_prop.py',
|
||||
'lib/ansible/modules/network/vyos/vyos_command.py',
|
||||
'lib/ansible/modules/packaging/language/pip.py',
|
||||
'lib/ansible/modules/packaging/os/yum.py',
|
||||
'lib/ansible/modules/source_control/git.py',
|
||||
'lib/ansible/modules/system/alternatives.py',
|
||||
'lib/ansible/modules/system/beadm.py',
|
||||
'lib/ansible/modules/system/cronvar.py',
|
||||
'lib/ansible/modules/system/dconf.py',
|
||||
'lib/ansible/modules/system/filesystem.py',
|
||||
'lib/ansible/modules/system/gconftool2.py',
|
||||
'lib/ansible/modules/system/interfaces_file.py',
|
||||
'lib/ansible/modules/system/iptables.py',
|
||||
'lib/ansible/modules/system/java_cert.py',
|
||||
'lib/ansible/modules/system/lvg.py',
|
||||
'lib/ansible/modules/system/lvol.py',
|
||||
'lib/ansible/modules/system/parted.py',
|
||||
'lib/ansible/modules/system/timezone.py',
|
||||
'lib/ansible/modules/system/ufw.py',
|
||||
'lib/ansible/modules/utilities/logic/wait_for.py',
|
||||
'lib/ansible/modules/web_infrastructure/rundeck_acl_policy.py',
|
||||
'lib/ansible/parsing/vault/__init__.py',
|
||||
'lib/ansible/playbook/base.py',
|
||||
'lib/ansible/playbook/helpers.py',
|
||||
'lib/ansible/playbook/role/__init__.py',
|
||||
'lib/ansible/playbook/taggable.py',
|
||||
'lib/ansible/plugins/callback/hipchat.py',
|
||||
'lib/ansible/plugins/connection/lxc.py',
|
||||
'lib/ansible/plugins/filter/core.py',
|
||||
'lib/ansible/plugins/lookup/sequence.py',
|
||||
'lib/ansible/plugins/strategy/__init__.py',
|
||||
'lib/ansible/plugins/strategy/linear.py',
|
||||
'test/legacy/cleanup_gce.py',
|
||||
'test/legacy/gce_credentials.py',
|
||||
'test/runner/lib/cloud/cs.py',
|
||||
'test/runner/lib/core_ci.py',
|
||||
'test/runner/lib/delegation.py',
|
||||
'test/runner/lib/docker_util.py',
|
||||
'test/runner/lib/executor.py',
|
||||
'test/runner/lib/http.py',
|
||||
'test/runner/lib/import_analysis.py',
|
||||
'test/runner/lib/manage_ci.py',
|
||||
'test/runner/lib/target.py',
|
||||
'test/runner/lib/util.py',
|
||||
'test/sanity/import/importer.py',
|
||||
'test/sanity/validate-modules/main.py',
|
||||
'test/units/executor/test_play_iterator.py',
|
||||
'test/units/module_utils/basic/test_run_command.py',
|
||||
'test/units/modules/cloud/amazon/test_ec2_vpc_nat_gateway.py',
|
||||
'test/units/modules/cloud/amazon/test_ec2_vpc_vpn.py',
|
||||
'test/units/modules/system/interfaces_file/test_interfaces_file.py',
|
||||
])
|
||||
|
||||
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||
if path in skip:
|
||||
continue
|
||||
|
||||
with open(path, 'r') as path_fd:
|
||||
for line, text in enumerate(path_fd.readlines()):
|
||||
match = re.search(r'^[^#]*(?:^| |[^C]\()(_)(?:[ ,)])', text)
|
||||
|
||||
if match:
|
||||
print('%s:%d:%d: use `dummy` instead of `_` for a variable name' % (
|
||||
path, line + 1, match.start(1) + 1))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -18,5 +18,19 @@ disable=
|
|||
|
||||
[BASIC]
|
||||
|
||||
bad-names=foo,
|
||||
bar,
|
||||
baz,
|
||||
toto,
|
||||
tutu,
|
||||
tata,
|
||||
_,
|
||||
|
||||
good-names=i,
|
||||
j,
|
||||
k,
|
||||
ex,
|
||||
Run,
|
||||
|
||||
method-rgx=[a-z_][a-z0-9_]{2,40}$
|
||||
function-rgx=[a-z_][a-z0-9_]{2,40}$
|
||||
|
|
|
@ -11,7 +11,6 @@ disable=
|
|||
bad-continuation,
|
||||
bad-indentation,
|
||||
bad-mcs-classmethod-argument,
|
||||
blacklisted-name,
|
||||
broad-except,
|
||||
c-extension-no-member,
|
||||
cell-var-from-loop,
|
||||
|
@ -113,6 +112,22 @@ disable=
|
|||
wrong-import-order,
|
||||
wrong-import-position,
|
||||
|
||||
[BASIC]
|
||||
|
||||
bad-names=foo,
|
||||
bar,
|
||||
baz,
|
||||
toto,
|
||||
tutu,
|
||||
tata,
|
||||
_,
|
||||
|
||||
good-names=i,
|
||||
j,
|
||||
k,
|
||||
ex,
|
||||
Run,
|
||||
|
||||
[TYPECHECK]
|
||||
|
||||
ignored-modules=
|
||||
|
|
|
@ -1,2 +1,110 @@
|
|||
contrib/inventory/gce.py blacklisted-name
|
||||
lib/ansible/cli/console.py blacklisted-name
|
||||
lib/ansible/compat/selectors/_selectors2.py blacklisted-name
|
||||
lib/ansible/executor/playbook_executor.py blacklisted-name
|
||||
lib/ansible/executor/task_queue_manager.py blacklisted-name
|
||||
lib/ansible/module_utils/acme.py blacklisted-name
|
||||
lib/ansible/module_utils/facts/network/linux.py blacklisted-name
|
||||
lib/ansible/module_utils/network/edgeswitch/edgeswitch_interface.py duplicate-string-formatting-argument
|
||||
lib/ansible/module_utils/urls.py blacklisted-name
|
||||
lib/ansible/modules/cloud/amazon/data_pipeline.py blacklisted-name
|
||||
lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway.py blacklisted-name
|
||||
lib/ansible/modules/cloud/amazon/ec2_vpc_vpn.py blacklisted-name
|
||||
lib/ansible/modules/cloud/amazon/efs.py blacklisted-name
|
||||
lib/ansible/modules/cloud/amazon/efs_facts.py blacklisted-name
|
||||
lib/ansible/modules/cloud/amazon/kinesis_stream.py blacklisted-name
|
||||
lib/ansible/modules/cloud/amazon/s3_sync.py blacklisted-name
|
||||
lib/ansible/modules/cloud/google/_gce.py blacklisted-name
|
||||
lib/ansible/modules/cloud/google/gce_eip.py blacklisted-name
|
||||
lib/ansible/modules/cloud/google/gce_img.py blacklisted-name
|
||||
lib/ansible/modules/cloud/google/gce_instance_template.py blacklisted-name
|
||||
lib/ansible/modules/cloud/google/gce_lb.py blacklisted-name
|
||||
lib/ansible/modules/cloud/google/gce_mig.py blacklisted-name
|
||||
lib/ansible/modules/cloud/google/gce_net.py blacklisted-name
|
||||
lib/ansible/modules/cloud/google/gce_pd.py blacklisted-name
|
||||
lib/ansible/modules/cloud/google/gce_snapshot.py blacklisted-name
|
||||
lib/ansible/modules/cloud/google/gce_tag.py blacklisted-name
|
||||
lib/ansible/modules/cloud/google/gcp_backend_service.py blacklisted-name
|
||||
lib/ansible/modules/cloud/google/gcp_healthcheck.py blacklisted-name
|
||||
lib/ansible/modules/cloud/lxc/lxc_container.py blacklisted-name
|
||||
lib/ansible/modules/files/copy.py blacklisted-name
|
||||
lib/ansible/modules/files/patch.py blacklisted-name
|
||||
lib/ansible/modules/files/synchronize.py blacklisted-name
|
||||
lib/ansible/modules/monitoring/statusio_maintenance.py blacklisted-name
|
||||
lib/ansible/modules/monitoring/zabbix/zabbix_maintenance.py blacklisted-name
|
||||
lib/ansible/modules/net_tools/basics/uri.py blacklisted-name
|
||||
lib/ansible/modules/network/cloudengine/ce_command.py blacklisted-name
|
||||
lib/ansible/modules/network/cloudengine/ce_dldp_interface.py blacklisted-name
|
||||
lib/ansible/modules/network/cloudengine/ce_mlag_interface.py blacklisted-name
|
||||
lib/ansible/modules/network/cloudvision/cv_server_provision.py blacklisted-name
|
||||
lib/ansible/modules/network/illumos/dladm_etherstub.py blacklisted-name
|
||||
lib/ansible/modules/network/illumos/dladm_iptun.py blacklisted-name
|
||||
lib/ansible/modules/network/illumos/dladm_linkprop.py blacklisted-name
|
||||
lib/ansible/modules/network/illumos/dladm_vlan.py blacklisted-name
|
||||
lib/ansible/modules/network/illumos/dladm_vnic.py blacklisted-name
|
||||
lib/ansible/modules/network/illumos/flowadm.py blacklisted-name
|
||||
lib/ansible/modules/network/illumos/ipadm_addr.py blacklisted-name
|
||||
lib/ansible/modules/network/illumos/ipadm_addrprop.py blacklisted-name
|
||||
lib/ansible/modules/network/illumos/ipadm_if.py blacklisted-name
|
||||
lib/ansible/modules/network/illumos/ipadm_ifprop.py blacklisted-name
|
||||
lib/ansible/modules/network/illumos/ipadm_prop.py blacklisted-name
|
||||
lib/ansible/modules/network/vyos/vyos_command.py blacklisted-name
|
||||
lib/ansible/modules/packaging/language/pip.py blacklisted-name
|
||||
lib/ansible/modules/packaging/os/yum.py blacklisted-name
|
||||
lib/ansible/modules/source_control/git.py blacklisted-name
|
||||
lib/ansible/modules/system/alternatives.py blacklisted-name
|
||||
lib/ansible/modules/system/beadm.py blacklisted-name
|
||||
lib/ansible/modules/system/cronvar.py blacklisted-name
|
||||
lib/ansible/modules/system/dconf.py blacklisted-name
|
||||
lib/ansible/modules/system/filesystem.py blacklisted-name
|
||||
lib/ansible/modules/system/gconftool2.py blacklisted-name
|
||||
lib/ansible/modules/system/interfaces_file.py blacklisted-name
|
||||
lib/ansible/modules/system/iptables.py blacklisted-name
|
||||
lib/ansible/modules/system/java_cert.py blacklisted-name
|
||||
lib/ansible/modules/system/lvg.py blacklisted-name
|
||||
lib/ansible/modules/system/lvol.py blacklisted-name
|
||||
lib/ansible/modules/system/parted.py blacklisted-name
|
||||
lib/ansible/modules/system/timezone.py blacklisted-name
|
||||
lib/ansible/modules/system/ufw.py blacklisted-name
|
||||
lib/ansible/modules/utilities/logic/wait_for.py blacklisted-name
|
||||
lib/ansible/modules/web_infrastructure/rundeck_acl_policy.py blacklisted-name
|
||||
lib/ansible/parsing/vault/__init__.py blacklisted-name
|
||||
lib/ansible/playbook/base.py blacklisted-name
|
||||
lib/ansible/playbook/helpers.py blacklisted-name
|
||||
lib/ansible/playbook/role/__init__.py blacklisted-name
|
||||
lib/ansible/plugins/callback/hipchat.py blacklisted-name
|
||||
lib/ansible/plugins/connection/lxc.py blacklisted-name
|
||||
lib/ansible/plugins/lookup/sequence.py blacklisted-name
|
||||
lib/ansible/plugins/strategy/__init__.py blacklisted-name
|
||||
lib/ansible/plugins/strategy/linear.py blacklisted-name
|
||||
lib/ansible/vars/hostvars.py blacklisted-name
|
||||
test/integration/targets/module_utils/module_utils/bar0/foo.py blacklisted-name
|
||||
test/integration/targets/module_utils/module_utils/foo.py blacklisted-name
|
||||
test/integration/targets/module_utils/module_utils/sub/bar/__init__.py blacklisted-name
|
||||
test/integration/targets/module_utils/module_utils/sub/bar/bar.py blacklisted-name
|
||||
test/integration/targets/module_utils/module_utils/yak/zebra/foo.py blacklisted-name
|
||||
test/legacy/cleanup_gce.py blacklisted-name
|
||||
test/legacy/gce_credentials.py blacklisted-name
|
||||
test/runner/lib/cloud/cs.py blacklisted-name
|
||||
test/runner/lib/core_ci.py blacklisted-name
|
||||
test/runner/lib/delegation.py blacklisted-name
|
||||
test/runner/lib/docker_util.py blacklisted-name
|
||||
test/runner/lib/executor.py blacklisted-name
|
||||
test/runner/lib/http.py blacklisted-name
|
||||
test/runner/lib/import_analysis.py blacklisted-name
|
||||
test/runner/lib/target.py blacklisted-name
|
||||
test/runner/lib/util.py blacklisted-name
|
||||
test/sanity/import/importer.py blacklisted-name
|
||||
test/sanity/validate-modules/main.py blacklisted-name
|
||||
test/units/contrib/inventory/test_vmware_inventory.py blacklisted-name
|
||||
test/units/executor/test_play_iterator.py blacklisted-name
|
||||
test/units/module_utils/basic/test_run_command.py blacklisted-name
|
||||
test/units/modules/cloud/amazon/test_ec2_vpc_nat_gateway.py blacklisted-name
|
||||
test/units/modules/cloud/amazon/test_ec2_vpc_vpn.py blacklisted-name
|
||||
test/units/modules/packaging/os/test_apt.py blacklisted-name
|
||||
test/units/modules/system/interfaces_file/test_interfaces_file.py blacklisted-name
|
||||
test/units/modules/system/test_known_hosts.py ansible-bad-function
|
||||
test/units/parsing/vault/test_vault.py blacklisted-name
|
||||
test/units/playbook/role/test_role.py blacklisted-name
|
||||
test/units/plugins/test_plugins.py blacklisted-name
|
||||
test/units/template/test_templar.py blacklisted-name
|
||||
|
|
Loading…
Reference in a new issue