chiark
/
gitweb
/
~ianmdlvl
/
fdroidserver.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d07bf07
)
Added support for gradle flavor specific dependencies in usual suspects check.
author
Jan Kühle
<jkuehle90@gmail.com>
Fri, 18 Sep 2015 15:22:34 +0000
(17:22 +0200)
committer
Jan Kühle
<jkuehle90@gmail.com>
Sat, 19 Sep 2015 12:43:42 +0000
(14:43 +0200)
fdroidserver/scanner.py
patch
|
blob
|
history
diff --git
a/fdroidserver/scanner.py
b/fdroidserver/scanner.py
index f46627d38cab0539bc88e9f5e5ac951b5ac0ee0a..9ebfdb17478ac03bdbe9417c8a3c37cf476eff9d 100644
(file)
--- a/
fdroidserver/scanner.py
+++ b/
fdroidserver/scanner.py
@@
-31,6
+31,15
@@
config = None
options = None
options = None
+def get_gradle_compile_commands(thisbuild):
+ compileCommands = ['compile', 'releaseCompile']
+ if thisbuild['gradle'] != ['yes']:
+ compileCommands += [flavor + 'Compile' for flavor in thisbuild['gradle']]
+ compileCommands += [flavor + 'ReleaseCompile' for flavor in thisbuild['gradle']]
+
+ return [re.compile(r'\s*' + c, re.IGNORECASE) for c in compileCommands]
+
+
# Scan the source code in the given directory (and all subdirectories)
# and return the number of fatal problems encountered
def scan_source(build_dir, root_dir, thisbuild):
# Scan the source code in the given directory (and all subdirectories)
# and return the number of fatal problems encountered
def scan_source(build_dir, root_dir, thisbuild):
@@
-114,6
+123,11
@@
def scan_source(build_dir, root_dir, thisbuild):
d = f.read(1024)
return bool(d.translate(None, textchars))
d = f.read(1024)
return bool(d.translate(None, textchars))
+ gradle_compile_commands = get_gradle_compile_commands(thisbuild)
+
+ def is_used_by_gradle(line):
+ return any(command.match(line) for command in gradle_compile_commands)
+
# Iterate through all files in the source code
for r, d, f in os.walk(build_dir, topdown=True):
# Iterate through all files in the source code
for r, d, f in os.walk(build_dir, topdown=True):
@@
-157,8
+171,9
@@
def scan_source(build_dir, root_dir, thisbuild):
continue
for i, line in enumerate(file(fp)):
i = i + 1
continue
for i, line in enumerate(file(fp)):
i = i + 1
- for name in suspects_found(line):
- count += handleproblem('usual supect \'%s\' at line %d' % (name, i), fd, fp)
+ if is_used_by_gradle(line):
+ for name in suspects_found(line):
+ count += handleproblem('usual supect \'%s\' at line %d' % (name, i), fd, fp)
elif ext in ['', 'bin', 'out', 'exe']:
if is_binary(fp):
elif ext in ['', 'bin', 'out', 'exe']:
if is_binary(fp):