mirror of https://github.com/ceph/ceph-ansible.git
core: refactor code quality issues
The following commit fixes a few code quality issues detected by DeepSource: - Use literals instead of function calls to create data structure. - Refactor unnecessary list comprehension. - Simplify if statement. - Refactor useless else block in the loop. Signed-off-by: Aksh Gupta <akshgpt7@gmail.com>pull/6306/head
parent
b01f16e835
commit
a0bc5afe26
|
@ -0,0 +1,18 @@
|
|||
version = 1
|
||||
|
||||
test_patterns = ["tests/**"]
|
||||
|
||||
exclude_patterns = [
|
||||
"roles/**",
|
||||
"profiles/**",
|
||||
"infrastructure-playbooks/**",
|
||||
"group_vars/**",
|
||||
"contrib/**"
|
||||
]
|
||||
|
||||
[[analyzers]]
|
||||
name = "python"
|
||||
enabled = true
|
||||
|
||||
[analyzers.meta]
|
||||
runtime_version = "3.x.x"
|
|
@ -179,7 +179,7 @@ class ConfigTemplateParser(ConfigParser.RawConfigParser):
|
|||
_write_comments(section_name, optname=key)
|
||||
self._write_check(fp, key=key, value=value,
|
||||
section=section_bool)
|
||||
else:
|
||||
|
||||
fp.write("\n")
|
||||
|
||||
def _write_comments(section, optname=None):
|
||||
|
@ -453,7 +453,7 @@ class ActionModule(ActionBase):
|
|||
'data. Sections are case sensitive.'
|
||||
)
|
||||
raise errors.AnsibleModuleError(error_msg)
|
||||
else:
|
||||
|
||||
config_object.close()
|
||||
|
||||
config_dict_new = {}
|
||||
|
@ -665,7 +665,7 @@ class ActionModule(ActionBase):
|
|||
return True, dict(
|
||||
source=source,
|
||||
dest=user_dest,
|
||||
config_overrides=self._task.args.get('config_overrides', dict()),
|
||||
config_overrides=self._task.args.get('config_overrides', {}),
|
||||
config_type=config_type,
|
||||
searchpath=searchpath,
|
||||
list_extend=list_extend,
|
||||
|
|
|
@ -14,7 +14,7 @@ class FilterModule(object):
|
|||
''' IP addresses within IP ranges '''
|
||||
|
||||
def ips_in_ranges(self, ip_addresses, ip_ranges):
|
||||
ips_in_ranges = list()
|
||||
ips_in_ranges = []
|
||||
for ip_addr in ip_addresses:
|
||||
for ip_range in ip_ranges:
|
||||
if netaddr.IPAddress(ip_addr) in netaddr.IPNetwork(ip_range):
|
||||
|
|
|
@ -38,8 +38,8 @@ class TestNFSs(object):
|
|||
cluster=cluster
|
||||
)
|
||||
output = host.check_output(cmd)
|
||||
keys = [i for i in json.loads(
|
||||
output)["servicemap"]["services"]["rgw-nfs"]["daemons"].keys()]
|
||||
keys = list(json.loads(
|
||||
output)["servicemap"]["services"]["rgw-nfs"]["daemons"].keys())
|
||||
keys.remove('summary')
|
||||
daemons = json.loads(output)["servicemap"]["services"]["rgw-nfs"]["daemons"]
|
||||
hostnames = []
|
||||
|
|
|
@ -36,8 +36,8 @@ class TestRGWs(object):
|
|||
cluster=cluster
|
||||
)
|
||||
output = host.check_output(cmd)
|
||||
keys = [i for i in json.loads(
|
||||
output)["servicemap"]["services"]["rgw"]["daemons"].keys()]
|
||||
keys = list(json.loads(
|
||||
output)["servicemap"]["services"]["rgw"]["daemons"].keys())
|
||||
keys.remove('summary')
|
||||
daemons = json.loads(output)["servicemap"]["services"]["rgw"]["daemons"]
|
||||
hostnames = []
|
||||
|
|
Loading…
Reference in New Issue