chiark / gitweb /
Use shorter and non-redundant 'or' clauses for 'if True else' assignments
[fdroidserver.git] / fdroidserver / lint.py
index c73bb459009c8d620d20cb55200c0280e28d5007..123a6441edba45f0b8a45e01531aa987b638b425 100644 (file)
@@ -150,10 +150,12 @@ def main():
 
     # Parse command line...
     parser = OptionParser(usage="Usage: %prog [options] [APPID [APPID ...]]")
-    parser.add_option("-p", "--pedantic", action="store_true", default=False,
-                      help="Show pedantic warnings that might give false positives")
     parser.add_option("-v", "--verbose", action="store_true", default=False,
                       help="Spew out even more information than normal")
+    parser.add_option("-q", "--quiet", action="store_true", default=False,
+                      help="Restrict output to warnings and errors")
+    parser.add_option("-p", "--pedantic", action="store_true", default=False,
+                      help="Show pedantic warnings that might give false positives")
     (options, args) = parser.parse_args()
 
     config = common.read_config(options)
@@ -187,7 +189,7 @@ def main():
 
         # Redundant summaries
         summary = app['Summary']
-        name = str(app['Name'] if app['Name'] else app['Auto Name'])
+        name = app['Name'] or app['Auto Name']
         if summary and name:
             summary_l = summary.lower()
             name_l = name.lower()
@@ -224,15 +226,22 @@ def main():
 
         # Build warnings
         for build in app['builds']:
-            for n in ['master', 'origin/', 'default', 'trunk']:
-                if build['commit'] and build['commit'].startswith(n):
+            for s in ['master', 'origin/', 'default', 'trunk']:
+                if build['commit'] and build['commit'].startswith(s):
                     warn("Branch '%s' used as commit in build '%s'" % (
-                        n, build['version']))
+                        s, build['version']))
                 for srclib in build['srclibs']:
                     ref = srclib.split('@')[1].split('/')[0]
-                    if ref.startswith(n):
+                    if ref.startswith(s):
                         warn("Branch '%s' used as commit in srclib '%s'" % (
-                            n, srclib))
+                            s, srclib))
+            for s in ['git clone', 'svn checkout', 'svn co', 'hg clone']:
+                for flag in ['init', 'prebuild', 'build']:
+                    if not build[flag]:
+                        continue
+                    if s in build[flag]:
+                        # TODO: This should not be pedantic!
+                        pwarn("'%s' used in %s '%s'" % (s, flag, build[flag]))
 
         if not appid:
             print