From: Daniel Martí Date: Thu, 5 May 2016 11:40:16 +0000 (+0100) Subject: lint: error on unused files X-Git-Tag: 0.7.0~60^2~2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=0c6269bb67b2c9556877fc68b2ed7f2ac0f6c02f;p=fdroidserver.git lint: error on unused files For now, this is just patch files. --- 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)