From ef8a05be38fc0e9a5d47b53d102ba0382114110e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 27 Sep 2013 10:21:27 +0800 Subject: [PATCH 1/9] :lipstick: Fix violations against pylint. --- script/bootstrap.py | 5 ++--- script/compile-coffee.py | 3 +-- script/cpplint.py | 2 +- script/create-dist.py | 14 ++++++-------- script/lib/github.py | 4 ++-- script/update-frameworks.py | 4 ++-- script/update.py | 3 +-- script/upload.py | 3 +-- 8 files changed, 16 insertions(+), 22 deletions(-) diff --git a/script/bootstrap.py b/script/bootstrap.py index f6f9faf7fa47..6b10e9bc18c5 100755 --- a/script/bootstrap.py +++ b/script/bootstrap.py @@ -1,12 +1,11 @@ #!/usr/bin/env python import argparse -import errno import os import subprocess import sys -from lib.util import * +from lib.util import scoped_cwd SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) @@ -68,7 +67,7 @@ def update_apm(): def update_node_modules(): for dirname in ['.', 'browser/default_app', 'spec']: - update_node_modules_for_dir(dirname); + update_node_modules_for_dir(dirname) def update_node_modules_for_dir(dirname): diff --git a/script/compile-coffee.py b/script/compile-coffee.py index 92e4f107e192..5fbb95643fbd 100755 --- a/script/compile-coffee.py +++ b/script/compile-coffee.py @@ -4,8 +4,6 @@ import os import subprocess import sys -from lib.util import * - SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__)) @@ -22,5 +20,6 @@ def main(): else: subprocess.check_call(['node', coffee, '-c', '-o', output_dir, input_file]) + if __name__ == '__main__': sys.exit(main()) diff --git a/script/cpplint.py b/script/cpplint.py index f624a1185f07..0862f4f80c47 100755 --- a/script/cpplint.py +++ b/script/cpplint.py @@ -31,7 +31,7 @@ def main(): def list_files(directories, filters): matches = [] for directory in directories: - for root, dirs, filenames, in os.walk(directory): + for root, _, filenames, in os.walk(directory): for f in filters: for filename in fnmatch.filter(filenames, f): matches.append(os.path.join(root, filename)) diff --git a/script/create-dist.py b/script/create-dist.py index 7a71c01dffa3..a948def25548 100755 --- a/script/create-dist.py +++ b/script/create-dist.py @@ -1,14 +1,13 @@ #!/usr/bin/env python -import errno -import glob import os import shutil import subprocess import sys import tarfile -from lib.util import * +from lib.util import scoped_cwd, rm_rf, get_atom_shell_version, make_zip, \ + safe_mkdir ATOM_SHELL_VRESION = get_atom_shell_version() @@ -79,7 +78,7 @@ def main(): def force_build(): build = os.path.join(SOURCE_ROOT, 'script', 'build.py') - subprocess.check_call([sys.executable, build, '-c', 'Release']); + subprocess.check_call([sys.executable, build, '-c', 'Release']) def copy_binaries(): @@ -99,7 +98,7 @@ def copy_headers(): # Copy standard node headers from node. repository. for include_path in HEADERS_DIRS: abs_path = os.path.join(NODE_DIR, include_path) - for dirpath, dirnames, filenames in os.walk(abs_path): + for dirpath, _, filenames in os.walk(abs_path): for filename in filenames: extension = os.path.splitext(filename)[1] if extension not in HEADERS_SUFFIX: @@ -111,7 +110,7 @@ def copy_headers(): # Copy V8 headers from chromium's repository. src = os.path.join(SOURCE_ROOT, 'vendor', 'brightray', 'vendor', 'download', 'libchromiumcontent', 'src') - for dirpath, dirnames, filenames in os.walk(os.path.join(src, 'v8')): + for dirpath, _, filenames in os.walk(os.path.join(src, 'v8')): for filename in filenames: extension = os.path.splitext(filename)[1] if extension not in HEADERS_SUFFIX: @@ -122,8 +121,7 @@ def copy_headers(): def copy_license(): - license = os.path.join(SOURCE_ROOT, 'LICENSE') - shutil.copy2(license, DIST_DIR) + shutil.copy2(os.path.join(SOURCE_ROOT, 'LICENSE'), DIST_DIR) def create_version(): diff --git a/script/lib/github.py b/script/lib/github.py index ebb3e3f53aa3..c6ca91ae04be 100644 --- a/script/lib/github.py +++ b/script/lib/github.py @@ -17,7 +17,7 @@ class GitHub: def __getattr__(self, attr): return _Callable(self, '/%s' % attr) - def _http(self, method, path, **kw): + def send(self, method, path, **kw): if not 'headers' in kw: kw['headers'] = dict() headers = kw['headers'] @@ -47,7 +47,7 @@ class _Executable: self._path = path def __call__(self, **kw): - return self._gh._http(self._method, self._path, **kw) + return self._gh.send(self._method, self._path, **kw) class _Callable(object): diff --git a/script/update-frameworks.py b/script/update-frameworks.py index 2f4b23c5f0c3..3cb142c4b143 100755 --- a/script/update-frameworks.py +++ b/script/update-frameworks.py @@ -3,11 +3,11 @@ import sys import os -from lib.util import * +from lib.util import safe_mkdir, extract_zip, tempdir, download SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) -FRAMEWORKS_URL='https://gh-contractor-zcbenz.s3.amazonaws.com/frameworks' +FRAMEWORKS_URL = 'https://gh-contractor-zcbenz.s3.amazonaws.com/frameworks' def main(): diff --git a/script/update.py b/script/update.py index 44c01b334560..1b21b0f584b4 100755 --- a/script/update.py +++ b/script/update.py @@ -1,10 +1,9 @@ #!/usr/bin/env python +import os import subprocess import sys -from lib.util import * - SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) diff --git a/script/upload.py b/script/upload.py index 409fa05c6b42..8e8987983169 100755 --- a/script/upload.py +++ b/script/upload.py @@ -4,12 +4,11 @@ import argparse import errno import glob import os -import requests import subprocess import sys import tempfile -from lib.util import * +from lib.util import get_atom_shell_version, scoped_cwd, safe_mkdir from lib.github import GitHub From 2b923b988c1d720b78d62a1ffcb1b8149391627d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 27 Sep 2013 10:21:49 +0800 Subject: [PATCH 2/9] Add wrapper script for pylint. --- script/pylint.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 script/pylint.py diff --git a/script/pylint.py b/script/pylint.py new file mode 100755 index 000000000000..399bb372c2fd --- /dev/null +++ b/script/pylint.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +import glob +import os +import subprocess +import sys + +SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__)) + + +def main(): + os.chdir(SOURCE_ROOT) + + pylint = os.path.join(SOURCE_ROOT, 'vendor', 'depot_tools', 'pylint.py') + settings = ['--rcfile=vendor/depot_tools/pylintrc'] + pys = glob.glob('script/*.py') + [os.path.join('script', 'lib')] + subprocess.check_call([sys.executable, pylint] + settings + pys, + env=dict(PYTHONPATH='script')) + + +if __name__ == '__main__': + sys.exit(main()) From 6be716c6e85d2b683958aad1c864812543c417e0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 27 Sep 2013 10:22:13 +0800 Subject: [PATCH 3/9] Run pylint in cibuild. --- script/cibuild | 1 + 1 file changed, 1 insertion(+) diff --git a/script/cibuild b/script/cibuild index 8e42be6c039a..eb3aca82f752 100755 --- a/script/cibuild +++ b/script/cibuild @@ -11,6 +11,7 @@ SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) def main(): run_script('bootstrap.py') run_script('cpplint.py') + run_script('pylint.py') run_script('build.py') run_script('test.py', ['--ci']) run_script('create-dist.py') From 3b3585f575d748db3e15992d12e81d2b9147cfca Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 27 Sep 2013 10:43:10 +0800 Subject: [PATCH 4/9] Skip the check for lib.github. --- script/pylint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/pylint.py b/script/pylint.py index 399bb372c2fd..b805abb72b58 100755 --- a/script/pylint.py +++ b/script/pylint.py @@ -13,7 +13,7 @@ def main(): pylint = os.path.join(SOURCE_ROOT, 'vendor', 'depot_tools', 'pylint.py') settings = ['--rcfile=vendor/depot_tools/pylintrc'] - pys = glob.glob('script/*.py') + [os.path.join('script', 'lib')] + pys = glob.glob('script/*.py') subprocess.check_call([sys.executable, pylint] + settings + pys, env=dict(PYTHONPATH='script')) From 561857d640d3907afd2bee8f4049e9751e842d58 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 27 Sep 2013 10:44:16 +0800 Subject: [PATCH 5/9] Add coffeelint to dependencies. --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 35f5dcac9a6c..d2752f2383a0 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "unzip": "*", "d3": "*", "int64-native": "*" + "coffeelint": "*" }, "private": true, From 11f387743fda70c19e8fbe77508d7ad7c384c9f3 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 27 Sep 2013 10:49:55 +0800 Subject: [PATCH 6/9] Add wrapper script for coffeelint. --- script/cibuild | 1 + script/coffeelint.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 script/coffeelint.py diff --git a/script/cibuild b/script/cibuild index eb3aca82f752..7a6bbf97576a 100755 --- a/script/cibuild +++ b/script/cibuild @@ -12,6 +12,7 @@ def main(): run_script('bootstrap.py') run_script('cpplint.py') run_script('pylint.py') + run_script('coffeelint.py') run_script('build.py') run_script('test.py', ['--ci']) run_script('create-dist.py') diff --git a/script/coffeelint.py b/script/coffeelint.py new file mode 100755 index 000000000000..2e912d6a0380 --- /dev/null +++ b/script/coffeelint.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +import glob +import os +import subprocess +import sys + + +SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__)) + + +def main(): + os.chdir(SOURCE_ROOT) + + coffeelint = os.path.join(SOURCE_ROOT, 'node_modules', 'coffeelint', 'bin', + 'coffeelint') + files = glob.glob('browser/api/lib/*.coffee') + \ + glob.glob('renderer/api/lib/*.coffee') + \ + glob.glob('common/api/lib/*.coffee') + \ + glob.glob('browser/atom/*.coffee') + + if sys.platform in ['win32', 'cygwin']: + subprocess.check_call(['node', coffeelint] + files, + executable='C:/Program Files/nodejs/node.exe') + else: + subprocess.check_call(['node', coffeelint] + files) + + +if __name__ == '__main__': + sys.exit(main()) From f3eef6cc2e29d66b5c05970cf2d1ea604b73fddc Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 27 Sep 2013 11:01:40 +0800 Subject: [PATCH 7/9] Do not warn about 80 columns in coffeelint, it's not required. --- script/coffeelint.json | 6 ++++++ script/coffeelint.py | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 script/coffeelint.json diff --git a/script/coffeelint.json b/script/coffeelint.json new file mode 100644 index 000000000000..cc06d0d3c8ed --- /dev/null +++ b/script/coffeelint.json @@ -0,0 +1,6 @@ +{ + "max_line_length": { + "value": 80, + "level": "ignore" + } +} diff --git a/script/coffeelint.py b/script/coffeelint.py index 2e912d6a0380..8bfd402bc4f8 100755 --- a/script/coffeelint.py +++ b/script/coffeelint.py @@ -14,16 +14,17 @@ def main(): coffeelint = os.path.join(SOURCE_ROOT, 'node_modules', 'coffeelint', 'bin', 'coffeelint') + settings = ['--quiet', '-f', os.path.join('script', 'coffeelint.json')] files = glob.glob('browser/api/lib/*.coffee') + \ glob.glob('renderer/api/lib/*.coffee') + \ glob.glob('common/api/lib/*.coffee') + \ glob.glob('browser/atom/*.coffee') if sys.platform in ['win32', 'cygwin']: - subprocess.check_call(['node', coffeelint] + files, + subprocess.check_call(['node', coffeelint] + settings + files, executable='C:/Program Files/nodejs/node.exe') else: - subprocess.check_call(['node', coffeelint] + files) + subprocess.check_call(['node', coffeelint] + settings + files) if __name__ == '__main__': From f4f42b30eeacccf2f7495b5f403d9a87dbeb4886 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 27 Sep 2013 11:02:08 +0800 Subject: [PATCH 8/9] :lipstick: Fix warnings of coffeelint. --- browser/atom/atom.coffee | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/browser/atom/atom.coffee b/browser/atom/atom.coffee index bde64a3fc77a..6a52cac919b1 100644 --- a/browser/atom/atom.coffee +++ b/browser/atom/atom.coffee @@ -26,7 +26,7 @@ atom.browserMainParts = global.__atom = atom # Add browser/api/lib to require's search paths, -# which contains javascript part of Atom's built-in libraries. +# which contains javascript part of Atom's built-in libraries. globalPaths = require('module').globalPaths globalPaths.push path.join process.resourcesPath, 'browser', 'api', 'lib' @@ -38,11 +38,11 @@ process.on 'uncaughtException', (error) -> # Show error in GUI. message = error.stack ? "#{error.name}: #{error.message}" require('dialog').showMessageBox - type: 'warning' - title: 'An javascript error occured in the browser' - message: 'uncaughtException' - detail: message - buttons: ['OK'] + type: 'warning' + title: 'An javascript error occured in the browser' + message: 'uncaughtException' + detail: message + buttons: ['OK'] # Load the RPC server. require './rpc-server.js' From af3f07f4cc74931891b6c5d5f13e5b599c74f430 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 27 Sep 2013 11:03:38 +0800 Subject: [PATCH 9/9] :lipstick: Adding trailing comma in package.json. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d2752f2383a0..e135ddbc44de 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "walkdir": "*", "unzip": "*", "d3": "*", - "int64-native": "*" + "int64-native": "*", "coffeelint": "*" },