Skip to content

Commit 0a0b54e

Browse files
authored
Merge pull request #1380 from vil02/resolve_no-else-return
Resolve `no-else-return`
2 parents 034f74a + 4d116af commit 0a0b54e

3 files changed

Lines changed: 22 additions & 28 deletions

File tree

rpmlint/checks/InitScriptCheck.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ def shell_var_value(var, script):
4242
if res2 and res2.group(2) == var: # infinite loop
4343
return None
4444
return substitute_shell_vars(res.group(1), script)
45-
else:
46-
return None
45+
return None
4746

4847

4948
def substitute_shell_vars(val, script):
@@ -54,8 +53,7 @@ def substitute_shell_vars(val, script):
5453
value = ''
5554
return res.group(1) + value + \
5655
substitute_shell_vars(res.group(3), script)
57-
else:
58-
return val
56+
return val
5957

6058

6159
class InitScriptCheck(AbstractCheck):

rpmlint/config.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,9 @@ def _sort_config_files(self, config_file):
121121
"""
122122
if config_file == self.config_defaults:
123123
return 0
124-
elif not self._is_override_config(config_file):
124+
if not self._is_override_config(config_file):
125125
return 1
126-
else:
127-
return 2
126+
return 2
128127

129128
def load_config(self, config=None):
130129
"""

rpmlint/pkg.py

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,13 @@ def compression_algorithm(fname):
8989
fname = str(fname)
9090
if gzip_regex.search(fname):
9191
return gzip
92-
elif bz2_regex.search(fname):
92+
if bz2_regex.search(fname):
9393
return bz2
94-
elif xz_regex.search(fname):
94+
if xz_regex.search(fname):
9595
return lzma
96-
elif zst_regex.search(fname):
96+
if zst_regex.search(fname):
9797
return zstd
98-
else:
99-
return None
98+
return None
10099

101100

102101
def is_utf8(fname):
@@ -519,8 +518,7 @@ def grep(self, regex, filename):
519518
match = regex.search(data)
520519
if match:
521520
return data.count('\n', 0, match.start()) + 1
522-
else:
523-
return None
521+
return None
524522

525523

526524
class Pkg(AbstractPkg):
@@ -589,20 +587,19 @@ def __getitem__(self, key):
589587
val = []
590588
if val == []:
591589
return None
592-
else:
593-
# Note that text tags we want to try decoding for real in TagsCheck
594-
# such as summary, description and changelog are not here.
595-
if key in (rpm.RPMTAG_NAME, rpm.RPMTAG_VERSION, rpm.RPMTAG_RELEASE,
596-
rpm.RPMTAG_ARCH, rpm.RPMTAG_GROUP, rpm.RPMTAG_BUILDHOST,
597-
rpm.RPMTAG_LICENSE, rpm.RPMTAG_HEADERI18NTABLE,
598-
rpm.RPMTAG_PACKAGER, rpm.RPMTAG_SOURCERPM,
599-
rpm.RPMTAG_DISTRIBUTION, rpm.RPMTAG_VENDOR) \
600-
or key in (x[0] for x in SCRIPT_TAGS) \
601-
or key in (x[1] for x in SCRIPT_TAGS):
602-
val = byte_to_string(val)
603-
if key == rpm.RPMTAG_GROUP and val == 'Unspecified':
604-
val = None
605-
return val
590+
# Note that text tags we want to try decoding for real in TagsCheck
591+
# such as summary, description and changelog are not here.
592+
if key in (rpm.RPMTAG_NAME, rpm.RPMTAG_VERSION, rpm.RPMTAG_RELEASE,
593+
rpm.RPMTAG_ARCH, rpm.RPMTAG_GROUP, rpm.RPMTAG_BUILDHOST,
594+
rpm.RPMTAG_LICENSE, rpm.RPMTAG_HEADERI18NTABLE,
595+
rpm.RPMTAG_PACKAGER, rpm.RPMTAG_SOURCERPM,
596+
rpm.RPMTAG_DISTRIBUTION, rpm.RPMTAG_VENDOR) \
597+
or key in (x[0] for x in SCRIPT_TAGS) \
598+
or key in (x[1] for x in SCRIPT_TAGS):
599+
val = byte_to_string(val)
600+
if key == rpm.RPMTAG_GROUP and val == 'Unspecified':
601+
val = None
602+
return val
606603

607604
# return the name of the directory where the package is extracted
608605
def dir_name(self):

0 commit comments

Comments
 (0)