chiark / gitweb /
Also pre-compile list regex warnings
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 6 May 2014 14:08:15 +0000 (16:08 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 6 May 2014 14:08:53 +0000 (16:08 +0200)
fdroidserver/lint.py

index bd7a43ccd4ce5d594ea678f2a1a2f2579302856c..5c76cd044f2f99c8a7da84771dba6af3265330b3 100644 (file)
@@ -72,6 +72,13 @@ regex_warnings = {
             (re.compile(r'.*[^sS]://gitorious\.org/.*'),
                 "gitorious URLs should always use https:// not http://"),
         ],
+        'Description': [
+            (re.compile(r'[ ]*[*#][^ .]'),
+                "Invalid bulleted list"),
+            (re.compile(r'^ '),
+                "Unnecessary leading space"),
+        ],
+
 }
 
 regex_pedantic = {
@@ -185,16 +192,9 @@ def main():
                 pwarn("Summary '%s' probably contains redundant info already in app name '%s'" % (
                     summary, name))
 
-        # Invalid lists
-        desc_chars = 0
-        for line in app['Description']:
-            if re.match(r'[ ]*[*#][^ .]', line):
-                warn("Invalid bulleted list: '%s'" % line)
-            if re.match(r'^ ', line):
-                warn("Unnecessary leading space: '%s'" % line)
-            desc_chars += len(line)
 
         # Description size limit
+        desc_chars = sum(len(l) for l in app['Description'])
         if desc_chars > config['char_limits']['Description']:
             warn("Description of length %s is over the %i char limit" % (
                 desc_chars, config['char_limits']['Description']))
@@ -202,8 +202,15 @@ def main():
         # Regex checks in all kinds of fields
         for f in regex_warnings:
             for m, r in regex_warnings[f]:
-                if m.match(app[f]):
-                    warn("%s '%s': %s" % (f, app[f], r))
+                t = metadata.metafieldtype(f)
+                if t == 'string':
+                    if m.match(app[f]):
+                        warn("%s '%s': %s" % (f, app[f], r))
+                elif t == 'multiline':
+                    for l in app[f]:
+                        if m.match(l):
+                            warn("%s at line '%s': %s" % (f, l, r))
+
 
         # Regex pedantic checks in all kinds of fields
         if options.pedantic: