mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 15:00:30 +03:00
lint: check fields for proper type, e.g. list vs. string
fdroid/fdroidserver#578
This commit is contained in:
parent
2113e29082
commit
85993eb2f8
2 changed files with 77 additions and 0 deletions
|
|
@ -473,6 +473,29 @@ def check_extlib_dir(apps):
|
|||
yield _("Unused extlib at %s") % os.path.join(dir_path, path)
|
||||
|
||||
|
||||
def check_app_field_types(app):
|
||||
"""Check the fields have valid data types"""
|
||||
|
||||
for field in app.keys():
|
||||
v = app.get(field)
|
||||
t = metadata.fieldtype(field)
|
||||
if v is None:
|
||||
continue
|
||||
elif field == 'builds':
|
||||
if not isinstance(v, list):
|
||||
yield(_("{appid}: {field} must be a '{type}', but it is a '{fieldtype}'!")
|
||||
.format(appid=app.id, field=field,
|
||||
type='list', fieldtype=v.__class__.__name__))
|
||||
elif t == metadata.TYPE_LIST and not isinstance(v, list):
|
||||
yield(_("{appid}: {field} must be a '{type}', but it is a '{fieldtype}!'")
|
||||
.format(appid=app.id, field=field,
|
||||
type='list', fieldtype=v.__class__.__name__))
|
||||
elif t == metadata.TYPE_STRING and not type(v) in (str, bool, dict):
|
||||
yield(_("{appid}: {field} must be a '{type}', but it is a '{fieldtype}'!")
|
||||
.format(appid=app.id, field=field,
|
||||
type='str', fieldtype=v.__class__.__name__))
|
||||
|
||||
|
||||
def check_for_unsupported_metadata_files(basedir=""):
|
||||
"""Checks whether any non-metadata files are in metadata/"""
|
||||
|
||||
|
|
@ -538,6 +561,7 @@ def main():
|
|||
continue
|
||||
|
||||
app_check_funcs = [
|
||||
check_app_field_types,
|
||||
check_regexes,
|
||||
check_update_check_data_url,
|
||||
check_vercode_operation,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue