From 756f4a23633c6d17a67c7f28c033af84e1067c31 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Mart=C3=AD?= Date: Wed, 3 Jun 2015 20:55:08 +0200 Subject: [PATCH] Simplify lint http warnings --- fdroidserver/lint.py | 66 +++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 43 deletions(-) diff --git a/fdroidserver/lint.py b/fdroidserver/lint.py index d0dedecc..12e1cc25 100644 --- a/fdroidserver/lint.py +++ b/fdroidserver/lint.py @@ -27,60 +27,40 @@ from collections import Counter config = None options = None + +def enforce_https(domain): + return (re.compile(r'.*[^sS]://[^/]*' + re.escape(domain) + r'/.*'), + domain + " URLs should always use https://") + +http_warnings = [ + (re.compile(r'.*/$'), + "HTTP links shouldn't end with a slash"), + # TODO enable in August 2015, when Google Code goes read-only + # (re.compile(r'.*://code\.google\.com/.*'), + # "code.google.com will be soon switching down, perhaps the project moved to github.com?"), +] + regex_warnings = { - 'Web Site': [ - (re.compile(r'.*[^sS]://github\.com/.*'), - "github URLs should always use https:// not http://"), - # TODO enable in August 2015, when Google Code goes read-only - # (re.compile(r'.*://code\.google\.com/.*'), - # "code.google.com will be soon switching down, perhaps it moved to github.com?"), + 'Web Site': http_warnings + [ ], - 'Source Code': [ - (re.compile(r'.*[^sS]://github\.com/.*'), - "github URLs should always use https:// (not http://, git://, or git@)"), - (re.compile(r'.*[^sS]://dl\.google\.com/.*'), - "dl.google.com URLs should always use https:// not http://"), - (re.compile(r'.*[^sS]://gitorious\.org/.*'), - "gitorious URLs should always use https:// (not http://, git://, or git@)"), - # TODO enable in August 2015, when Google Code goes read-only - # (re.compile(r'.*://code\.google\.com/.*'), - # "code.google.com will be soon switching down, perhaps it moved to github.com?"), + 'Source Code': http_warnings + [ ], 'Repo': [ - (re.compile(r'.*[^sS]://dl\.google\.com/.*'), - "dl.google.com URLs should always use https:// not http://"), - (re.compile(r'.*[^sS]://github\.com/.*'), - "github URLs should always use https:// (not http://, git://, or git@)"), - (re.compile(r'.*[^sS]://gitorious\.org/.*'), - "gitorious URLs should always use https:// (not http://, git://, or git@)"), - (re.compile(r'.*[^sS]://[^.]*\.googlecode\.com/svn/?.*'), - "Google Code SVN URLs should always use https:// (not http:// or svn://)"), - (re.compile(r'.*[^sS]://svn\.apache\.org/repos/?.*'), - "Apache SVN URLs should always use https:// (not http:// or svn://)"), - (re.compile(r'.*[^sS]://svn\.code\.sf\.net/.*'), - "Sourceforge SVN URLs should always use https:// (not http:// or svn://)"), - # TODO enable in August 2015, when Google Code goes read-only - # (re.compile(r'.*://code\.google\.com/.*'), - # "code.google.com will be soon switching down, perhaps it moved to github.com?"), + enforce_https('github.com'), + enforce_https('gitorious.org'), + enforce_https('apache.org'), + enforce_https('google.com'), + enforce_https('svn.code.sf.net'), + enforce_https('googlecode.com'), ], - 'Issue Tracker': [ + 'Issue Tracker': http_warnings + [ (re.compile(r'.*github\.com/[^/]+/[^/]+[/]*$'), "/issues is missing"), - (re.compile(r'.*[^sS]://github\.com/.*'), - "github URLs should always use https:// not http://"), - (re.compile(r'.*[^sS]://gitorious\.org/.*'), - "gitorious URLs should always use https:// not http://"), # TODO enable in August 2015, when Google Code goes read-only # (re.compile(r'.*://code\.google\.com/.*'), # "code.google.com will be soon switching down, perhaps it moved to github.com?"), ], - 'Changelog': [ - (re.compile(r'.*[^sS]://code\.google\.com/.*'), - "code.google.com URLs should always use https:// not http://"), - (re.compile(r'.*[^sS]://github\.com/.*'), - "github URLs should always use https:// not http://"), - (re.compile(r'.*[^sS]://gitorious\.org/.*'), - "gitorious URLs should always use https:// not http://"), + 'Changelog': http_warnings + [ ], 'License': [ (re.compile(r'^(|None|Unknown)$'), -- 2.30.2