chiark / gitweb /
Add Liberapay support
[fdroidserver.git] / fdroidserver / lint.py
index 492a09fc05a87b607077a10f1e063bc39516f438..a5ed3637dcf35981463a689390a0612fa72bdb51 100644 (file)
@@ -42,7 +42,15 @@ https_enforcings = [
     enforce_https('bitbucket.org'),
     enforce_https('apache.org'),
     enforce_https('google.com'),
+    enforce_https('git.code.sf.net'),
     enforce_https('svn.code.sf.net'),
+    enforce_https('anongit.kde.org'),
+    enforce_https('savannah.nongnu.org'),
+    enforce_https('git.savannah.nongnu.org'),
+    enforce_https('download.savannah.nongnu.org'),
+    enforce_https('savannah.gnu.org'),
+    enforce_https('git.savannah.gnu.org'),
+    enforce_https('download.savannah.gnu.org'),
 ]
 
 
@@ -52,13 +60,59 @@ def forbid_shortener(domain):
 
 
 http_url_shorteners = [
+    forbid_shortener('1url.com'),
+    forbid_shortener('adf.ly'),
+    forbid_shortener('bc.vc'),
+    forbid_shortener('bit.do'),
+    forbid_shortener('bit.ly'),
+    forbid_shortener('bitly.com'),
+    forbid_shortener('budurl.com'),
+    forbid_shortener('buzurl.com'),
+    forbid_shortener('cli.gs'),
+    forbid_shortener('cur.lv'),
+    forbid_shortener('cutt.us'),
+    forbid_shortener('db.tt'),
+    forbid_shortener('filoops.info'),
     forbid_shortener('goo.gl'),
-    forbid_shortener('t.co'),
-    forbid_shortener('ur1.ca'),
     forbid_shortener('is.gd'),
-    forbid_shortener('bit.ly'),
+    forbid_shortener('ity.im'),
+    forbid_shortener('j.mp'),
+    forbid_shortener('l.gg'),
+    forbid_shortener('lnkd.in'),
+    forbid_shortener('moourl.com'),
+    forbid_shortener('ow.ly'),
+    forbid_shortener('para.pt'),
+    forbid_shortener('po.st'),
+    forbid_shortener('q.gs'),
+    forbid_shortener('qr.ae'),
+    forbid_shortener('qr.net'),
+    forbid_shortener('rdlnk.com'),
+    forbid_shortener('scrnch.me'),
+    forbid_shortener('short.nr'),
+    forbid_shortener('sn.im'),
+    forbid_shortener('snipurl.com'),
+    forbid_shortener('su.pr'),
+    forbid_shortener('t.co'),
     forbid_shortener('tiny.cc'),
+    forbid_shortener('tinyarrows.com'),
     forbid_shortener('tinyurl.com'),
+    forbid_shortener('tr.im'),
+    forbid_shortener('tweez.me'),
+    forbid_shortener('twitthis.com'),
+    forbid_shortener('twurl.nl'),
+    forbid_shortener('tyn.ee'),
+    forbid_shortener('u.bb'),
+    forbid_shortener('u.to'),
+    forbid_shortener('ur1.ca'),
+    forbid_shortener('urlof.site'),
+    forbid_shortener('v.gd'),
+    forbid_shortener('vzturl.com'),
+    forbid_shortener('x.co'),
+    forbid_shortener('xrl.us'),
+    forbid_shortener('yourls.org'),
+    forbid_shortener('zip.net'),
+    forbid_shortener('✩.ws'),
+    forbid_shortener('➡.ws'),
 ]
 
 http_checks = https_enforcings + http_url_shorteners + [
@@ -81,6 +135,8 @@ regex_checks = {
     'Donate': http_checks + [
         (re.compile(r'.*flattr\.com'),
          _("Flattr donation methods belong in the FlattrID flag")),
+        (re.compile(r'.*liberapay\.com'),
+         _("Liberapay donation methods belong in the LiberapayID flag")),
     ],
     'Changelog': http_checks,
     'Author Name': [
@@ -101,17 +157,13 @@ regex_checks = {
         (re.compile(r'.*\s$'),
          _("Unnecessary trailing space")),
     ],
-    'Description': [
+    'Description': https_enforcings + http_url_shorteners + [
         (re.compile(r'\s*[*#][^ .]'),
          _("Invalid bulleted list")),
         (re.compile(r'^\s'),
          _("Unnecessary leading space")),
         (re.compile(r'.*\s$'),
          _("Unnecessary trailing space")),
-        (re.compile(r'.*([^[]|^)\[[^:[\]]+( |\]|$)'),
-         _("Invalid link - use [http://foo.bar Link title] or [http://foo.bar]")),
-        (re.compile(r'(^|.* )https?://[^ ]+'),
-         _("Unlinkified link - use [http://foo.bar Link title] or [http://foo.bar]")),
     ],
 }
 
@@ -156,20 +208,20 @@ def check_ucm_tags(app):
             and lastbuild.versionCode == app.CurrentVersionCode
             and not lastbuild.forcevercode
             and any(s in lastbuild.commit for s in '.,_-/')):
-        yield _("Last used commit '%s' looks like a tag, but Update Check Mode is '%s'") % (
-            lastbuild.commit, app.UpdateCheckMode)
+        yield _("Last used commit '{commit}' looks like a tag, but Update Check Mode is '{ucm}'")\
+            .format(commit=lastbuild.commit, ucm=app.UpdateCheckMode)
 
 
 def check_char_limits(app):
     limits = config['char_limits']
 
     if len(app.Summary) > limits['summary']:
-        yield _("Summary of length %s is over the %i char limit") % (
-            len(app.Summary), limits['summary'])
+        yield _("Summary of length {length} is over the {limit} char limit")\
+            .format(length=len(app.Summary), limit=limits['summary'])
 
     if len(app.Description) > limits['description']:
-        yield _("Description of length %s is over the %i char limit") % (
-            len(app.Description), limits['description'])
+        yield _("Description of length {length} is over the {limit} char limit")\
+            .format(length=len(app.Description), limit=limits['description'])
 
 
 def check_old_links(app):
@@ -186,7 +238,8 @@ def check_old_links(app):
         for f in ['WebSite', 'SourceCode', 'IssueTracker', 'Changelog']:
             v = app.get(f)
             if any(s in v for s in old_sites):
-                yield _("App is in '%s' but has a link to '%s'") % (app.Repo, v)
+                yield _("App is in '{repo}' but has a link to {url}")\
+                    .format(repo=app.Repo, url=v)
 
 
 def check_useless_fields(app):
@@ -246,7 +299,7 @@ def check_duplicates(app):
             continue
         v = v.lower()
         if v in links_seen:
-            yield _("Duplicate link in '%s': %s") % (f, v)
+            yield _("Duplicate link in '{field}': {url}").format(field=f, url=v)
         else:
             links_seen.add(v)
 
@@ -277,7 +330,7 @@ def check_mediawiki_links(app):
         url = um.group(1)
         for m, r in http_checks:
             if m.match(url):
-                yield _("URL '%s' in Description: %s") % (url, r)
+                yield _("URL {url} in Description: {error}").format(url=url, error=r)
 
 
 def check_bulleted_lists(app):
@@ -309,11 +362,13 @@ def check_builds(app):
             continue
         for s in ['master', 'origin', 'HEAD', 'default', 'trunk']:
             if build.commit and build.commit.startswith(s):
-                yield _("Branch '%s' used as commit in build '%s'") % (s, build.versionName)
+                yield _("Branch '{branch}' used as commit in build '{versionName}'")\
+                    .format(branch=s, versionName=build.versionName)
             for srclib in build.srclibs:
                 ref = srclib.split('@')[1].split('/')[0]
                 if ref.startswith(s):
-                    yield _("Branch '%s' used as commit in srclib '%s'") % (s, srclib)
+                    yield _("Branch '{branch}' used as commit in srclib '{srclib}'")\
+                        .format(branch=s, srclib=srclib)
         for key in build.keys():
             if key not in supported_flags:
                 yield _('%s is not an accepted build field') % key
@@ -335,7 +390,8 @@ def check_files_dir(app):
     for build in app.builds:
         for fname in build.patch:
             if fname not in files:
-                yield _("Unknown file %s in build '%s'") % (fname, build.versionName)
+                yield _("Unknown file '{filename}' in build '{versionName}'")\
+                    .format(filename=fname, versionName=build.versionName)
             else:
                 used.add(fname)
 
@@ -369,7 +425,8 @@ def check_extlib_dir(apps):
         for build in app.builds:
             for path in build.extlibs:
                 if path not in unused_extlib_files:
-                    yield _("%s: Unknown extlib %s in build '%s'") % (app.id, path, build.versionName)
+                    yield _("{appid}: Unknown extlib {path} in build '{versionName}'")\
+                        .format(appid=app.id, path=path, versionName=build.versionName)
                 else:
                     used.add(path)