chiark / gitweb /
lint: also check for trailing spaces in names
[fdroidserver.git] / fdroidserver / lint.py
index f09ac007db563d48c4ccf91673e46f1aeab89aaf..ee4381c0f10c4a4a73adad3a71be4ebc9b6aa281 100644 (file)
 
 from argparse import ArgumentParser
 import re
-import common
-import metadata
 import sys
 from sets import Set
 
+import common
+import metadata
+import rewritemeta
+
 config = None
 options = None
 
@@ -72,6 +74,12 @@ regex_checks = {
          "Flattr donation methods belong in the FlattrID flag"),
     ],
     'Changelog': http_checks,
+    'Author Name': [
+        (re.compile(r'^\s'),
+         "Unnecessary leading space"),
+        (re.compile(r'.*\s$'),
+         "Unnecessary trailing space"),
+    ],
     'License': [
         (re.compile(r'^(|None|Unknown)$'),
          "No license specified"),
@@ -85,6 +93,10 @@ regex_checks = {
          "No need to specify that the app is for Android"),
         (re.compile(r'.*[a-z0-9][.!?]( |$)'),
          "Punctuation should be avoided"),
+        (re.compile(r'^\s'),
+         "Unnecessary leading space"),
+        (re.compile(r'.*\s$'),
+         "Unnecessary trailing space"),
     ],
     'Description': [
         (re.compile(r'^No description available$'),
@@ -306,6 +318,8 @@ def main():
     # Parse command line...
     parser = ArgumentParser(usage="%(prog)s [options] [APPID [APPID ...]]")
     common.setup_global_opts(parser)
+    parser.add_argument("-f", "--format", action="store_true", default=False,
+                        help="Also warn about formatting issues, like rewritemeta -l")
     parser.add_argument("appid", nargs='*', help="app-id in the form APPID")
     options = parser.parse_args()
 
@@ -337,10 +351,14 @@ def main():
                 ]:
             warns += check_func(app)
 
+        if options.format:
+            if not rewritemeta.proper_format(app):
+                warns.append("Run rewritemeta to fix formatting")
+
         if warns:
             anywarns = True
             for warn in warns:
-                print "%s: %s" % (appid, warn)
+                print("%s: %s" % (appid, warn))
 
     if anywarns:
         sys.exit(1)