From 0c6269bb67b2c9556877fc68b2ed7f2ac0f6c02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 5 May 2016 12:40:16 +0100 Subject: [PATCH] lint: error on unused files For now, this is just patch files. --- fdroidserver/lint.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/fdroidserver/lint.py b/fdroidserver/lint.py index 05721567..06f3998b 100644 --- a/fdroidserver/lint.py +++ b/fdroidserver/lint.py @@ -17,6 +17,7 @@ # along with this program. If not, see . from argparse import ArgumentParser +import os import re import sys @@ -309,6 +310,30 @@ def check_builds(app): yield "Branch '%s' used as commit in srclib '%s'" % (s, srclib) +def check_files_dir(app): + dir_path = os.path.join('metadata', app.id) + if not os.path.isdir(dir_path): + return + files = set() + for name in os.listdir(dir_path): + path = os.path.join(dir_path, name) + if not os.path.isfile(path): + yield "Found non-file at %s" % path + continue + files.add(name) + + used = set() + for build in app.builds: + for fname in build.patch: + if fname not in files: + yield "Unknown file %s in build '%s'" % (fname, build.version) + else: + used.add(fname) + + for name in files.difference(used): + yield "Unused file at %s" % os.path.join(dir_path, name) + + def main(): global config, options @@ -348,6 +373,7 @@ def main(): check_mediawiki_links, check_bulleted_lists, check_builds, + check_files_dir, ]: warns += check_func(app)