mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-19 21:30:10 +01:00
Separate lint messages into warnings and pedantic warnings
This commit is contained in:
parent
945d8b126f
commit
d5c62d3bbd
@ -194,8 +194,8 @@ __complete_rewritemeta() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__complete_lint() {
|
__complete_lint() {
|
||||||
opts="-h -v"
|
opts="-h -v -p"
|
||||||
lopts="--help --verbose"
|
lopts="--help --verbose --pedantic"
|
||||||
case "${cur}" in
|
case "${cur}" in
|
||||||
-*)
|
-*)
|
||||||
__complete_options
|
__complete_options
|
||||||
|
@ -25,49 +25,16 @@ import common, metadata
|
|||||||
config = None
|
config = None
|
||||||
options = None
|
options = None
|
||||||
|
|
||||||
appid = None
|
regex_warnings = {
|
||||||
|
|
||||||
def warn(message):
|
|
||||||
global appid
|
|
||||||
if appid:
|
|
||||||
print "%s:" % appid
|
|
||||||
appid = None
|
|
||||||
print ' %s' % message
|
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
global config, options, appid
|
|
||||||
|
|
||||||
# Parse command line...
|
|
||||||
parser = OptionParser(usage="Usage: %prog [options] [APPID [APPID ...]]")
|
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
|
||||||
help="Spew out even more information than normal")
|
|
||||||
(options, args) = parser.parse_args()
|
|
||||||
|
|
||||||
config = common.read_config(options)
|
|
||||||
|
|
||||||
# Get all apps...
|
|
||||||
allapps = metadata.read_metadata(xref=False)
|
|
||||||
apps = common.read_app_args(args, allapps, False)
|
|
||||||
|
|
||||||
regex_warnings = {
|
|
||||||
'Web Site': [
|
'Web Site': [
|
||||||
(re.compile(r'.*github\.com/[^/]+/[^/]+\.git'),
|
|
||||||
"Appending .git is not necessary"),
|
|
||||||
(re.compile(r'.*[^sS]://github\.com/.*'),
|
(re.compile(r'.*[^sS]://github\.com/.*'),
|
||||||
"github URLs should always use https:// not http://"),
|
"github URLs should always use https:// not http://"),
|
||||||
(re.compile(r'.*code\.google\.com/p/[^/]+/[^w]'),
|
|
||||||
"Possible incorrect path appended to google code project site"),
|
|
||||||
(re.compile(r'.*[^sS]://code\.google\.com/.*'),
|
(re.compile(r'.*[^sS]://code\.google\.com/.*'),
|
||||||
"code.google.com URLs should always use https:// not http://"),
|
"code.google.com URLs should always use https:// not http://"),
|
||||||
],
|
],
|
||||||
'Source Code': [
|
'Source Code': [
|
||||||
(re.compile(r'.*github\.com/[^/]+/[^/]+\.git'),
|
|
||||||
"Appending .git is not necessary"),
|
|
||||||
(re.compile(r'.*[^sS]://github\.com/.*'),
|
(re.compile(r'.*[^sS]://github\.com/.*'),
|
||||||
"github URLs should always use https:// (not http://, git://, or git@)"),
|
"github URLs should always use https:// (not http://, git://, or git@)"),
|
||||||
(re.compile(r'.*code\.google\.com/p/[^/]+/source/.*'),
|
|
||||||
"/source is often enough on its own"),
|
|
||||||
(re.compile(r'.*code\.google\.com/p/[^/]+[/]*$'),
|
(re.compile(r'.*code\.google\.com/p/[^/]+[/]*$'),
|
||||||
"/source is missing"),
|
"/source is missing"),
|
||||||
(re.compile(r'.*[^sS]://code\.google\.com/.*'),
|
(re.compile(r'.*[^sS]://code\.google\.com/.*'),
|
||||||
@ -92,6 +59,35 @@ def main():
|
|||||||
"Apache SVN URLs should always use https:// (not http:// or svn://)"),
|
"Apache SVN URLs should always use https:// (not http:// or svn://)"),
|
||||||
(re.compile(r'.*[^sS]://svn\.code\.sf\.net/.*'),
|
(re.compile(r'.*[^sS]://svn\.code\.sf\.net/.*'),
|
||||||
"Sourceforge SVN URLs should always use https:// (not http:// or svn://)"),
|
"Sourceforge SVN URLs should always use https:// (not http:// or svn://)"),
|
||||||
|
],
|
||||||
|
'Issue Tracker': [
|
||||||
|
(re.compile(r'.*code\.google\.com/p/[^/]+[/]*$'),
|
||||||
|
"/issues is missing"),
|
||||||
|
(re.compile(r'.*[^sS]://code\.google\.com/.*'),
|
||||||
|
"code.google.com URLs should always use https:// not http://"),
|
||||||
|
(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://"),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
regex_pedantic = {
|
||||||
|
'Web Site': [
|
||||||
|
(re.compile(r'.*github\.com/[^/]+/[^/]+\.git'),
|
||||||
|
"Appending .git is not necessary"),
|
||||||
|
(re.compile(r'.*code\.google\.com/p/[^/]+/[^w]'),
|
||||||
|
"Possible incorrect path appended to google code project site"),
|
||||||
|
],
|
||||||
|
'Source Code': [
|
||||||
|
(re.compile(r'.*github\.com/[^/]+/[^/]+\.git'),
|
||||||
|
"Appending .git is not necessary"),
|
||||||
|
(re.compile(r'.*code\.google\.com/p/[^/]+/source/.*'),
|
||||||
|
"/source is often enough on its own"),
|
||||||
|
],
|
||||||
|
'Repo': [
|
||||||
(re.compile(r'^http://.*'),
|
(re.compile(r'^http://.*'),
|
||||||
"if https:// is available, use it instead of http://"),
|
"if https:// is available, use it instead of http://"),
|
||||||
(re.compile(r'^svn://.*'),
|
(re.compile(r'^svn://.*'),
|
||||||
@ -100,20 +96,50 @@ def main():
|
|||||||
'Issue Tracker': [
|
'Issue Tracker': [
|
||||||
(re.compile(r'.*code\.google\.com/p/[^/]+/issues/.*'),
|
(re.compile(r'.*code\.google\.com/p/[^/]+/issues/.*'),
|
||||||
"/issues is often enough on its own"),
|
"/issues is often enough on its own"),
|
||||||
(re.compile(r'.*code\.google\.com/p/[^/]+[/]*$'),
|
|
||||||
"/issues is missing"),
|
|
||||||
(re.compile(r'.*[^sS]://code\.google\.com/.*'),
|
|
||||||
"code.google.com URLs should always use https:// not http://"),
|
|
||||||
(re.compile(r'.*github\.com/[^/]+/[^/]+/issues/.*'),
|
(re.compile(r'.*github\.com/[^/]+/[^/]+/issues/.*'),
|
||||||
"/issues is often enough on its own"),
|
"/issues is often enough on its own"),
|
||||||
(re.compile(r'.*github\.com/[^/]+/[^/]+[/]*$'),
|
],
|
||||||
"/issues is missing"),
|
'Summary': [
|
||||||
(re.compile(r'.*[^sS]://github\.com/.*'),
|
(re.compile(r'.*\bandroid\b.*', re.IGNORECASE),
|
||||||
"github URLs should always use https:// not http://"),
|
"No need to specify that the app is for Android"),
|
||||||
(re.compile(r'.*[^sS]://gitorious\.org/.*'),
|
(re.compile(r'.*\b(app|application)\b.*', re.IGNORECASE),
|
||||||
"gitorious URLs should always use https:// not http://"),
|
"No need to specify that the app is... an app"),
|
||||||
]
|
(re.compile(r'.*\b(free software|open source)\b.*', re.IGNORECASE),
|
||||||
}
|
"No need to specify that the app is Free Software"),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
appid = None
|
||||||
|
|
||||||
|
def main():
|
||||||
|
|
||||||
|
global config, options, appid
|
||||||
|
|
||||||
|
def warn(message):
|
||||||
|
global appid
|
||||||
|
if appid:
|
||||||
|
print "%s:" % appid
|
||||||
|
appid = None
|
||||||
|
print ' %s' % message
|
||||||
|
|
||||||
|
def pwarn(message):
|
||||||
|
if options.pedantic:
|
||||||
|
warn(message)
|
||||||
|
|
||||||
|
|
||||||
|
# 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")
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
config = common.read_config(options)
|
||||||
|
|
||||||
|
# Get all apps...
|
||||||
|
allapps = metadata.read_metadata(xref=False)
|
||||||
|
apps = common.read_app_args(args, allapps, False)
|
||||||
|
|
||||||
for app in apps:
|
for app in apps:
|
||||||
appid = app['id']
|
appid = app['id']
|
||||||
@ -128,8 +154,8 @@ def main():
|
|||||||
|
|
||||||
# Potentially incorrect UCM
|
# Potentially incorrect UCM
|
||||||
if (app['Update Check Mode'] == 'RepoManifest' and
|
if (app['Update Check Mode'] == 'RepoManifest' and
|
||||||
any(s in lastcommit for s in ('.', ',', '_', '-', '/'))):
|
any(s in lastcommit for s in '.,_-/')):
|
||||||
warn("Last used commit '%s' looks like a tag, but Update Check Mode is '%s'" % (
|
pwarn("Last used commit '%s' looks like a tag, but Update Check Mode is '%s'" % (
|
||||||
lastcommit, app['Update Check Mode']))
|
lastcommit, app['Update Check Mode']))
|
||||||
|
|
||||||
# No license
|
# No license
|
||||||
@ -157,20 +183,26 @@ def main():
|
|||||||
# No punctuation in summary
|
# No punctuation in summary
|
||||||
if app['Summary']:
|
if app['Summary']:
|
||||||
lastchar = app['Summary'][-1]
|
lastchar = app['Summary'][-1]
|
||||||
if any(lastchar==c for c in ['.', ',', '!', '?']):
|
if any(lastchar==c for c in '.,!?'):
|
||||||
warn("Summary should not end with a %s" % lastchar)
|
warn("Summary should not end with a %s" % lastchar)
|
||||||
|
|
||||||
# Common mistakes in urls
|
# Regex checks in all kinds of fields
|
||||||
for f in regex_warnings:
|
for f in regex_warnings:
|
||||||
for m, r in regex_warnings[f]:
|
for m, r in regex_warnings[f]:
|
||||||
if m.match(app[f]):
|
if m.match(app[f]):
|
||||||
warn("%s url '%s': %s" % (f, app[f], r))
|
warn("%s '%s': %s" % (f, app[f], r))
|
||||||
|
|
||||||
|
# Regex pedantic checks in all kinds of fields
|
||||||
|
if options.pedantic:
|
||||||
|
for f in regex_pedantic:
|
||||||
|
for m, r in regex_pedantic[f]:
|
||||||
|
if m.match(app[f]):
|
||||||
|
warn("%s '%s': %s" % (f, app[f], r))
|
||||||
|
|
||||||
# Build warnings
|
# Build warnings
|
||||||
for build in app['builds']:
|
for build in app['builds']:
|
||||||
for n in ['master', 'origin/', 'default', 'trunk']:
|
for n in ['master', 'origin/', 'default', 'trunk']:
|
||||||
if 'commit' not in build:
|
if 'commit' in build:
|
||||||
continue
|
|
||||||
if build['commit'].startswith(n):
|
if build['commit'].startswith(n):
|
||||||
warn("Branch '%s' used as commit" % n)
|
warn("Branch '%s' used as commit" % n)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user