From 12c80f9062e3fa8e3dcb827af60a7f7c5056d9c4 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 13 Apr 2017 11:57:02 +0200 Subject: [PATCH 1/3] update outdated pylint setup The logilab-astng lib is dead, replaced by python-astroid. The crazy astng plugin is no longer needed also. #281 --- .pylint-plugins/astng_hashlib.py | 39 --------------------------- .pylint-rcfile | 45 ++++++++++++++++++++++++++++++++ tests/complete-ci-tests | 27 ++++++++----------- 3 files changed, 56 insertions(+), 55 deletions(-) delete mode 100644 .pylint-plugins/astng_hashlib.py create mode 100644 .pylint-rcfile diff --git a/.pylint-plugins/astng_hashlib.py b/.pylint-plugins/astng_hashlib.py deleted file mode 100644 index f4b7871c..00000000 --- a/.pylint-plugins/astng_hashlib.py +++ /dev/null @@ -1,39 +0,0 @@ -# -# started from http://www.logilab.org/blogentry/78354 -# - -from logilab.astng import MANAGER -from logilab.astng.builder import ASTNGBuilder - -def hashlib_transform(module): - if module.name == 'hashlib': - fake = ASTNGBuilder(MANAGER).string_build(''' - -class fakehash(object): - digest_size = -1 - def __init__(self, value): pass - def digest(self): - return u'' - def hexdigest(self): - return u'' - def update(self, value): pass - -class md5(fakehash): - pass - -class sha1(fakehash): - pass - -class sha256(fakehash): - pass - -''') - for hashfunc in ('sha256', 'sha1', 'md5'): - module.locals[hashfunc] = fake.locals[hashfunc] - -def register(linter): - """called when loaded by pylint --load-plugins, register our tranformation - function here - """ - MANAGER.register_transformer(hashlib_transform) - diff --git a/.pylint-rcfile b/.pylint-rcfile new file mode 100644 index 00000000..4685d7f4 --- /dev/null +++ b/.pylint-rcfile @@ -0,0 +1,45 @@ +[MASTER] + +# Use multiple processes to speed up Pylint. +jobs=4 + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED +confidence=HIGH,INFERENCE + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once).You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use"--disable=all --enable=classes +# --disable=W" +disable=invalid-name,missing-docstring,no-member + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME,XXX,TODO + + +[BASIC] + +# Good variable names which should always be accepted, separated by a comma +good-names=i,j,k,ex,Run,_,e,f,fp + + +[ELIF] + +# Maximum number of nested blocks for function / method body +max-nested-blocks=5 + diff --git a/tests/complete-ci-tests b/tests/complete-ci-tests index 558427e3..b09e111d 100755 --- a/tests/complete-ci-tests +++ b/tests/complete-ci-tests @@ -87,19 +87,14 @@ sh hooks/pre-commit #------------------------------------------------------------------------------# # run pylint -cd $WORKSPACE -set +e -# use the pyvenv so pylint checks against its installed libs - PYTHONPATH=$WORKSPACE/.pylint-plugins python3 /usr/bin/pylint \ - --output-format=parseable --reports=n \ - --load-plugins astng_hashlib \ - fdroidserver/*.py fdroid makebuildserver setup.py > $WORKSPACE/pylint.parseable - -# to only tell jenkins there was an error if we got ERROR or FATAL, uncomment these: -# running pylint in the pyvenv/virtualenv is causing this FATAL error, which is a bug: -# https://bitbucket.org/logilab/pylint/issue/73/pylint-is-unable-to-import -[ $(($? & 1)) = "1" ] && echo "FATALs found" -[ $(($? & 2)) = "2" ] && exit 2 -[ $(($? & 4)) = "4" ] && exit 4 -set -e - +# only run it where it will work, for example, the pyvenvs above don't have pylint +if which pylint3 && python3 -c "import pylint" 2> /dev/null; then + cd $WORKSPACE + pylint3 --rcfile=.pylint-rcfile --output-format=colorized --reports=n \ + fdroid \ + makebuildserver \ + setup.py \ + fdroidserver/*.py \ + tests/*.py \ + tests/*.TestCase +fi From 17cd07f1a704f5e19a81a1515fd9e27e918cec28 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 13 Apr 2017 12:30:04 +0200 Subject: [PATCH 2/3] fix pylint unused-argument --- fdroidserver/build.py | 2 +- fdroidserver/checkupdates.py | 4 ++-- fdroidserver/common.py | 4 ++-- fdroidserver/scanner.py | 19 ++++++++++--------- fdroidserver/update.py | 2 +- tests/common.TestCase | 4 ++-- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/fdroidserver/build.py b/fdroidserver/build.py index 89131360..fbf9c549 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -735,7 +735,7 @@ def build_local(app, build, vcs, build_dir, output_dir, log_dir, srclib_dir, ext src = os.path.normpath(apks[0]) # Make sure it's not debuggable... - if common.isApkAndDebuggable(src, config): + if common.isApkAndDebuggable(src): raise BuildException("APK is debuggable") # By way of a sanity check, make sure the version and version diff --git a/fdroidserver/checkupdates.py b/fdroidserver/checkupdates.py index cc884505..098280b2 100644 --- a/fdroidserver/checkupdates.py +++ b/fdroidserver/checkupdates.py @@ -241,7 +241,7 @@ def check_repomanifest(app, branch=None): return (None, msg) -def check_repotrunk(app, branch=None): +def check_repotrunk(app): try: if app.RepoType == 'srclib': @@ -370,7 +370,7 @@ def fetch_autoname(app, tag): return commitmsg -def checkupdates_app(app, first=True): +def checkupdates_app(app): # If a change is made, commitmsg should be set to a description of it. # Only if this is set will changes be written back to the metadata. diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 0ede37a6..ca02219f 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -655,7 +655,7 @@ class vcs: # Derived classes need to implement this. It's called once basic checking # has been performend. - def gotorevisionx(self, rev): + def gotorevisionx(self, rev): # pylint: disable=unused-argument raise VCSException("This VCS type doesn't define gotorevisionx") # Initialise and update submodules @@ -1683,7 +1683,7 @@ def get_apk_debuggable_androguard(apkfile): return False -def isApkAndDebuggable(apkfile, config): +def isApkAndDebuggable(apkfile): """Returns True if the given file is an APK and is debuggable :param apkfile: full path to the apk to check""" diff --git a/fdroidserver/scanner.py b/fdroidserver/scanner.py index 363f8c8a..2449ae07 100644 --- a/fdroidserver/scanner.py +++ b/fdroidserver/scanner.py @@ -39,9 +39,10 @@ def get_gradle_compile_commands(build): 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, build): +def scan_source(build_dir, build): + """Scan the source code in the given directory (and all subdirectories) + and return the number of fatal problems encountered + """ count = 0 @@ -111,7 +112,7 @@ def scan_source(build_dir, root_dir, build): return True return False - def ignoreproblem(what, fd, fp): + def ignoreproblem(what, fd): logging.info('Ignoring %s at %s' % (what, fd)) return 0 @@ -127,7 +128,7 @@ def scan_source(build_dir, root_dir, build): def handleproblem(what, fd, fp): if toignore(fd): - return ignoreproblem(what, fd, fp) + return ignoreproblem(what, fd) if todelete(fd): return removeproblem(what, fd, fp) logging.error('Found %s at %s' % (what, fd)) @@ -301,12 +302,12 @@ def main(): logging.info("...scanning version " + build.versionName) # Prepare the source code... - root_dir, _ = common.prepare_source(vcs, app, build, - build_dir, srclib_dir, - extlib_dir, False) + common.prepare_source(vcs, app, build, + build_dir, srclib_dir, + extlib_dir, False) # Do the scan... - count = scan_source(build_dir, root_dir, build) + count = scan_source(build_dir, build) if count > 0: logging.warn('Scanner found %d problems in %s (%s)' % ( count, appid, build.versionCode)) diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 273b5f0d..2e79ea29 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -1137,7 +1137,7 @@ def scan_apk(apkcache, apkfilename, repodir, knownapks, use_date_from_apk): apk['minSdkVersion'] = 1 # Check for debuggable apks... - if common.isApkAndDebuggable(apkfile, config): + if common.isApkAndDebuggable(apkfile): logging.warning('{0} is set to android:debuggable="true"'.format(apkfile)) # Get the signature (or md5 of, to be precise)... diff --git a/tests/common.TestCase b/tests/common.TestCase index d5978405..74364098 100755 --- a/tests/common.TestCase +++ b/tests/common.TestCase @@ -78,7 +78,7 @@ class CommonTest(unittest.TestCase): testfiles.append(os.path.join(os.path.dirname(__file__), 'urzip-badsig.apk')) testfiles.append(os.path.join(os.path.dirname(__file__), 'urzip-badcert.apk')) for apkfile in testfiles: - debuggable = fdroidserver.common.isApkAndDebuggable(apkfile, config) + debuggable = fdroidserver.common.isApkAndDebuggable(apkfile) self.assertTrue(debuggable, "debuggable APK state was not properly parsed!") # these are set NOT debuggable @@ -86,7 +86,7 @@ class CommonTest(unittest.TestCase): testfiles.append(os.path.join(os.path.dirname(__file__), 'urzip-release.apk')) testfiles.append(os.path.join(os.path.dirname(__file__), 'urzip-release-unsigned.apk')) for apkfile in testfiles: - debuggable = fdroidserver.common.isApkAndDebuggable(apkfile, config) + debuggable = fdroidserver.common.isApkAndDebuggable(apkfile) self.assertFalse(debuggable, "debuggable APK state was not properly parsed!") From 9ad457c16fca3de118327ecd1a263552b01c5827 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 13 Apr 2017 11:58:56 +0200 Subject: [PATCH 3/3] fix pylink 'dict' has no member 'keystore' --- fdroidserver/update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 2e79ea29..b0ff8d0a 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -1538,7 +1538,7 @@ def main(): config['keydname'] = 'CN=' + config['repo_keyalias'] + ', OU=F-Droid' common.write_to_config(config, 'keydname', config['keydname']) if 'keystore' not in config: - config['keystore'] = common.default_config.keystore + config['keystore'] = common.default_config['keystore'] common.write_to_config(config, 'keystore', config['keystore']) password = common.genpassword()