Skip to content

Commit

Permalink
Change: file_extension main to use early returns
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasHargarter authored and mbrinkhoff committed Sep 11, 2024
1 parent 2393cfa commit 789f4f6
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions troubadix/standalone_plugins/file_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,22 @@ def check_extensions(args: Namespace) -> List[Path]:

def main() -> int:
args = parse_args()
if unwanted_files := check_extensions(args):
if args.gen_ignore_entries:
for file in unwanted_files:
print(file.relative_to(args.dir))
return 0
else:
print(
f"{len(unwanted_files)} "
"Files with unwanted file extension were found:"
)
for file in unwanted_files:
print(file)
return 1

return 0
unwanted_files = check_extensions(args)
if not unwanted_files:
return 0

if args.gen_ignore_entries:
for file in unwanted_files:
print(file.relative_to(args.dir))
return 0

print(
f"{len(unwanted_files)} "
"Files with unwanted file extension were found:"
)
for file in unwanted_files:
print(file)
return 1


if __name__ == "__main__":
Expand Down

0 comments on commit 789f4f6

Please sign in to comment.