You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by kl...@apache.org on 2017/11/10 14:05:19 UTC
[1/3] mesos git commit: Updated JavaScript linter rules.
Repository: mesos
Updated Branches:
refs/heads/master b08161f1f -> 5516adba3
Updated JavaScript linter rules.
The rules we added do the following:
1. They force us to use 'this_' for any alias of 'this'
that we create.
2. They allow us to have arguments to functions that go unused so long
as the variable names begin with an '_'.
Review: https://reviews.apache.org/r/63724/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f03e75c9
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f03e75c9
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f03e75c9
Branch: refs/heads/master
Commit: f03e75c98b67d2e610bbd5eae366f7b206306399
Parents: b08161f
Author: Armand Grillet <ag...@mesosphere.io>
Authored: Fri Nov 10 14:50:15 2017 +0100
Committer: Kevin Klues <kl...@gmail.com>
Committed: Fri Nov 10 15:04:21 2017 +0100
----------------------------------------------------------------------
support/.eslintrc.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/f03e75c9/support/.eslintrc.js
----------------------------------------------------------------------
diff --git a/support/.eslintrc.js b/support/.eslintrc.js
index a474944..cd23dde 100644
--- a/support/.eslintrc.js
+++ b/support/.eslintrc.js
@@ -79,7 +79,7 @@ module.exports = {
"never"
],
"consistent-return": "off",
- "consistent-this": "error",
+ "consistent-this": ["error", "this_"],
"curly": "off",
"default-case": "error",
"dot-location": "off",
@@ -218,11 +218,11 @@ module.exports = {
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-undefined": "error",
- "no-underscore-dangle": "error",
+ "no-underscore-dangle": ["error", { "allow": ["this_"]}],
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
- "no-unused-vars": "warn",
+ "no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-computed-key": "error",
[3/3] mesos git commit: Improved support/mesos-style.py structure.
Posted by kl...@apache.org.
Improved support/mesos-style.py structure.
We have updated the following three things:
1. The Python linter now also use the function
`run_command_in_virtualenv` to run.
2. The methods of LinterBase have been reordered alphabetically.
3. Some unecessary excluded files have been removed for the JS linter.
Review: https://reviews.apache.org/r/63585/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5516adba
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5516adba
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5516adba
Branch: refs/heads/master
Commit: 5516adba30324bcb1a8e9aa9ab95e489663c70a4
Parents: af8404e
Author: Armand Grillet <ag...@mesosphere.io>
Authored: Fri Nov 10 15:03:10 2017 +0100
Committer: Kevin Klues <kl...@gmail.com>
Committed: Fri Nov 10 15:04:38 2017 +0100
----------------------------------------------------------------------
support/mesos-style.py | 174 +++++++++++++++++++++-----------------------
1 file changed, 83 insertions(+), 91 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/5516adba/support/mesos-style.py
----------------------------------------------------------------------
diff --git a/support/mesos-style.py b/support/mesos-style.py
index f288819..315955e 100755
--- a/support/mesos-style.py
+++ b/support/mesos-style.py
@@ -68,46 +68,34 @@ class LinterBase(object):
# A prefix at the beginning of the line to demark comments (e.g. '//')
comment_prefix = ''
- def find_candidates(self, root_dir):
- """
- Search through the all files rooted at 'root_dir' and compare
- them against 'self.exclude_files' and 'self.source_files' to
- come up with a set of candidate files to lint.
- """
- exclude_file_regex = re.compile(self.exclude_files)
- source_criteria_regex = re.compile(self.source_files)
- for root, _, files in os.walk(root_dir):
- for name in files:
- path = os.path.join(root, name)
- if exclude_file_regex.search(path) is not None:
- continue
-
- if source_criteria_regex.search(name) is not None:
- yield path
-
- def run_lint(self, source_paths):
- """
- A custom function to provide linting for 'linter_type'.
- It takes a list of source files to lint and returns the number
- of errors found during the linting process.
-
- It should print any errors as it encounters them to provide
- feedback to the caller.
- """
- pass
-
- def run_command_in_virtualenv(self, command):
+ def check_encoding(self, source_paths):
"""
- Activate the virtual environment, run the
- given command and return its output.
+ Checks for encoding errors in the given files. Source
+ code files must contain only printable ascii characters.
+ This excludes the extended ascii characters 128-255.
+ http://www.asciitable.com/
"""
- virtualenv = os.path.join('support', '.virtualenv')
- command = '. {virtualenv_path}/bin/activate; {cmd}'.format(
- virtualenv_path=virtualenv, cmd=command)
-
- process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
+ error_count = 0
+ for path in source_paths:
+ with open(path) as source_file:
+ for line_number, line in enumerate(source_file):
+ # If we find an error, add 1 to both the character and
+ # the line offset to give them 1-based indexing
+ # instead of 0 (as is common in most editors).
+ char_errors = [offset for offset, char in enumerate(line)
+ if char not in string.printable]
+ if char_errors:
+ sys.stderr.write(
+ "{path}:{line_number}: Non-printable characters"
+ " found at [{offsets}]: \"{line}\"\n".format(
+ path=path,
+ line_number=line_number + 1,
+ offsets=', '.join([str(offset + 1) for offset
+ in char_errors]),
+ line=line.rstrip()))
+ error_count += 1
- return process
+ return error_count
def check_license_header(self, source_paths):
"""Checks the license headers of the given files."""
@@ -137,34 +125,45 @@ class LinterBase(object):
return error_count
- def check_encoding(self, source_paths):
+ def find_candidates(self, root_dir):
"""
- Checks for encoding errors in the given files. Source
- code files must contain only printable ascii characters.
- This excludes the extended ascii characters 128-255.
- http://www.asciitable.com/
+ Search through the all files rooted at 'root_dir' and compare
+ them against 'self.exclude_files' and 'self.source_files' to
+ come up with a set of candidate files to lint.
"""
- error_count = 0
- for path in source_paths:
- with open(path) as source_file:
- for line_number, line in enumerate(source_file):
- # If we find an error, add 1 to both the character and
- # the line offset to give them 1-based indexing
- # instead of 0 (as is common in most editors).
- char_errors = [offset for offset, char in enumerate(line)
- if char not in string.printable]
- if char_errors:
- sys.stderr.write(
- "{path}:{line_number}: Non-printable characters"
- " found at [{offsets}]: \"{line}\"\n".format(
- path=path,
- line_number=line_number + 1,
- offsets=', '.join([str(offset + 1) for offset
- in char_errors]),
- line=line.rstrip()))
- error_count += 1
+ exclude_file_regex = re.compile(self.exclude_files)
+ source_criteria_regex = re.compile(self.source_files)
+ for root, _, files in os.walk(root_dir):
+ for name in files:
+ path = os.path.join(root, name)
+ if exclude_file_regex.search(path) is not None:
+ continue
- return error_count
+ if source_criteria_regex.search(name) is not None:
+ yield path
+
+ def run_command_in_virtualenv(self, command):
+ """
+ Activate the virtual environment, run the
+ given command and return its output.
+ """
+ virtualenv = os.path.join('support', '.virtualenv')
+ command = '. {virtualenv_path}/bin/activate; {cmd}'.format(
+ virtualenv_path=virtualenv, cmd=command)
+ process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
+
+ return process
+
+ def run_lint(self, source_paths):
+ """
+ A custom function to provide linting for 'linter_type'.
+ It takes a list of source files to lint and returns the number
+ of errors found during the linting process.
+
+ It should print any errors as it encounters them to provide
+ feedback to the caller.
+ """
+ pass
def main(self, modified_files):
"""
@@ -305,9 +304,7 @@ class JsLinter(LinterBase):
r'relative\-date|' \
r'ui\-bootstrap\-tpls\-0\.9\.0|' \
r'angular\-route\-1\.2\.32|' \
- r'underscore\-1\.4\.3|' \
- r'\.eslintrc|' \
- r'\.virtualenv' \
+ r'underscore\-1\.4\.3' \
')'
source_files = r'\.(js)$'
@@ -329,8 +326,9 @@ class JsLinter(LinterBase):
process = self.run_command_in_virtualenv(
'eslint {files} -c {config} -f compact'.format(
files=source_files,
- config=config_path)
+ config=config_path
)
+ )
for line in process.stdout:
if "Error -" in line or "Warning -" in line:
@@ -348,6 +346,11 @@ class PyLinter(LinterBase):
"""The linter for Python files, uses pylint."""
linter_type = 'Python'
+ cli_dir = os.path.join('src', 'python', 'cli_new')
+ lib_dir = os.path.join('src', 'python', 'lib')
+ support_dir = 'support'
+ source_dirs = [cli_dir, lib_dir, support_dir]
+
exclude_files = '(' \
r'protobuf\-2\.4\.1|' \
r'googletest\-release\-1\.8\.0|' \
@@ -361,22 +364,6 @@ class PyLinter(LinterBase):
comment_prefix = '#'
- def __init__(self):
- python_dir = os.path.join('src', 'python')
- cli_dir = os.path.join(python_dir, 'cli_new')
- lib_dir = os.path.join(python_dir, 'lib')
- support_dir = 'support'
-
- self.config = {
- 'bootstrap_dir': cli_dir,
- 'virtualenv_dir': os.path.join(support_dir, '.virtualenv'),
- 'pylint_config': os.path.join(support_dir, 'pylint.config'),
- 'pylint_cmd': os.path.join(
- support_dir, '.virtualenv', 'bin', 'pylint')
- }
-
- self.source_dirs = [cli_dir, lib_dir, support_dir]
-
def run_lint(self, source_paths):
"""
Runs pylint over given files.
@@ -384,7 +371,12 @@ class PyLinter(LinterBase):
https://google.github.io/styleguide/pyguide.html
"""
+ num_errors = 0
+
+ pylint_config = os.path.join('support', 'pylint.config')
+
source_files = ''
+
for source_dir in self.source_dirs:
source_dir_files = []
for source_path in source_paths:
@@ -393,13 +385,13 @@ class PyLinter(LinterBase):
source_files = ' '.join([source_files, ' '.join(source_dir_files)])
- process = subprocess.Popen(
- [('. {virtualenv_dir}/bin/activate;'
- '{pylint_cmd} --rcfile={pylint_config} {files}').
- format(files=source_files, **self.config)],
- shell=True, stdout=subprocess.PIPE)
+ process = self.run_command_in_virtualenv(
+ 'pylint --rcfile={rcfile} {files}'.format(
+ rcfile=pylint_config,
+ files=source_files
+ )
+ )
- num_errors = 0
for line in process.stdout:
if not line.startswith('*'):
num_errors += 1
@@ -466,8 +458,8 @@ if __name__ == '__main__':
build_virtualenv()
CPP_LINTER = CppLinter()
CPP_ERRORS = CPP_LINTER.main(sys.argv[1:])
- PY_LINTER = PyLinter()
- PY_ERRORS = PY_LINTER.main(sys.argv[1:])
JS_LINTER = JsLinter()
JS_ERRORS = JS_LINTER.main(sys.argv[1:])
- sys.exit(CPP_ERRORS + PY_ERRORS + JS_ERRORS)
+ PY_LINTER = PyLinter()
+ PY_ERRORS = PY_LINTER.main(sys.argv[1:])
+ sys.exit(CPP_ERRORS + JS_ERRORS + PY_ERRORS)
[2/3] mesos git commit: Linted JavaScript files.
Posted by kl...@apache.org.
Linted JavaScript files.
Review: https://reviews.apache.org/r/63703/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/af8404e7
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/af8404e7
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/af8404e7
Branch: refs/heads/master
Commit: af8404e7bf49201d7f3a0a563f43d767539558f0
Parents: f03e75c
Author: Armand Grillet <ag...@mesosphere.io>
Authored: Fri Nov 10 14:52:43 2017 +0100
Committer: Kevin Klues <kl...@gmail.com>
Committed: Fri Nov 10 15:04:38 2017 +0100
----------------------------------------------------------------------
src/webui/master/static/js/app.js | 4 ++--
src/webui/master/static/js/controllers.js | 26 +++++++++++++-----------
src/webui/master/static/js/jquery.pailer.js | 13 +++++++++---
src/webui/master/static/js/services.js | 12 +++++------
4 files changed, 32 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/af8404e7/src/webui/master/static/js/app.js
----------------------------------------------------------------------
diff --git a/src/webui/master/static/js/app.js b/src/webui/master/static/js/app.js
index 39f66d2..463c563 100644
--- a/src/webui/master/static/js/app.js
+++ b/src/webui/master/static/js/app.js
@@ -189,7 +189,7 @@
scope: true,
template: '<i class="glyphicon glyphicon-file"></i>',
- link: function(scope, element, attrs) {
+ link: function(scope, element, _attrs) {
var clip = new Clipboard(element[0]);
element.on('mouseenter', function() {
@@ -241,7 +241,7 @@
scope: {
value: '@'
},
- link: function($scope, element, attrs) {
+ link: function($scope, _element, _attrs) {
$scope.longDate = JSON.parse(
localStorage.getItem('longDate') || false);
http://git-wip-us.apache.org/repos/asf/mesos/blob/af8404e7/src/webui/master/static/js/controllers.js
----------------------------------------------------------------------
diff --git a/src/webui/master/static/js/controllers.js b/src/webui/master/static/js/controllers.js
index e753709..5966586 100644
--- a/src/webui/master/static/js/controllers.js
+++ b/src/webui/master/static/js/controllers.js
@@ -292,10 +292,11 @@
_.each(framework.tasks, function(task) {
switch (task.state) {
- case "TASK_STAGING": framework.staging_tasks++; break;
- case "TASK_STARTING": framework.starting_tasks++; break;
- case "TASK_RUNNING": framework.running_tasks++; break;
- case "TASK_KILLING": framework.killing_tasks++; break;
+ case "TASK_STAGING": framework.staging_tasks += 1; break;
+ case "TASK_STARTING": framework.starting_tasks += 1; break;
+ case "TASK_RUNNING": framework.running_tasks += 1; break;
+ case "TASK_KILLING": framework.killing_tasks += 1; break;
+ default: break;
}
})
@@ -306,10 +307,11 @@
_.each(framework.completed_tasks, function(task) {
switch (task.state) {
- case "TASK_FINISHED": framework.finished_tasks++; break;
- case "TASK_KILLED": framework.killed_tasks++; break;
- case "TASK_FAILED": framework.failed_tasks++; break;
- case "TASK_LOST": framework.lost_tasks++; break;
+ case "TASK_FINISHED": framework.finished_tasks += 1; break;
+ case "TASK_KILLED": framework.killed_tasks += 1; break;
+ case "TASK_FAILED": framework.failed_tasks += 1; break;
+ case "TASK_LOST": framework.lost_tasks += 1; break;
+ default: break;
}
})
@@ -548,7 +550,7 @@
mesosApp.controller('HomeCtrl', function($dialog, $scope) {
- $scope.log = function($event) {
+ $scope.log = function(_$event) {
if (!$scope.state.external_log_file && !$scope.state.log_dir) {
$dialog.messageBox(
'Logging to a file is not enabled',
@@ -656,7 +658,7 @@
var agent = $scope.agents[$routeParams.agent_id];
- $scope.log = function($event) {
+ $scope.log = function(_$event) {
if (!$scope.state.external_log_file && !$scope.state.log_dir) {
$dialog.messageBox(
'Logging to a file is not enabled',
@@ -929,7 +931,7 @@
task.healthy = lastStatus.healthy;
}
})
- };
+ }
// Look for the executor; it's either active or completed.
$scope.executor =
@@ -1080,7 +1082,7 @@
.search({path: sandboxDirectory})
.replace();
})
- .error(function(response) {
+ .error(function(_response) {
$alert.danger({
bullets: [
"The agent is not accessible",
http://git-wip-us.apache.org/repos/asf/mesos/blob/af8404e7/src/webui/master/static/js/jquery.pailer.js
----------------------------------------------------------------------
diff --git a/src/webui/master/static/js/jquery.pailer.js b/src/webui/master/static/js/jquery.pailer.js
index 6c68383..93ff04b 100644
--- a/src/webui/master/static/js/jquery.pailer.js
+++ b/src/webui/master/static/js/jquery.pailer.js
@@ -52,6 +52,8 @@
// });
(function($) {
+ 'use strict';
+
// Helper for escaping html, based on _.escape from underscore.js.
function escapeHTML(string) {
if (string == null) {
@@ -85,8 +87,13 @@
this_.paging = false;
this_.tailing = true;
- page_size || $.error('Expecting page_size to be defined');
- truncate_length || $.error('Expecting truncate_length to be defined');
+ if (page_size) {
+ $.error('Expecting page_size to be defined')
+ }
+
+ if (truncate_length) {
+ $.error('Expecting truncate_length to be defined')
+ }
this_.page_size = page_size;
this_.truncate_length = truncate_length;
@@ -133,7 +140,7 @@
this_.element.html('');
setTimeout(function() { this_.tail(); }, 0);
})
- .fail(function(response, msg, code) {
+ .fail(function(response, _msg, _code) {
if ([401, 403].indexOf(response.status) > -1) {
// Unauthorized user.
this_.indicate('YOU ARE UNAUTHORIZED TO ACCESS THIS CONTENT');
http://git-wip-us.apache.org/repos/asf/mesos/blob/af8404e7/src/webui/master/static/js/services.js
----------------------------------------------------------------------
diff --git a/src/webui/master/static/js/services.js b/src/webui/master/static/js/services.js
index 12d3b4b..5e83996 100644
--- a/src/webui/master/static/js/services.js
+++ b/src/webui/master/static/js/services.js
@@ -98,7 +98,7 @@
];
}
- var ModalCtrl = function($scope, $modalInstance) {
+ var ModalCtrl = function($scope, _$modalInstance) {
$scope.title = title;
$scope.message = message;
$scope.buttons = buttons;
@@ -229,7 +229,7 @@
};
Top.prototype.parseResponse = function(response) {
- var that = this;
+ var this_ = this;
var monitor = {
frameworks: {},
statistics: new Statistics()
@@ -242,10 +242,10 @@
Statistics.parseJSON(executor.statistics);
// Compute CPU usage if possible.
- if (that.scope.monitor &&
- that.scope.monitor.frameworks[framework_id] &&
- that.scope.monitor.frameworks[framework_id].executors[executor_id]) {
- var previous = that.scope.monitor.frameworks[framework_id].executors[executor_id].statistics;
+ if (this_.scope.monitor &&
+ this_.scope.monitor.frameworks[framework_id] &&
+ this_.scope.monitor.frameworks[framework_id].executors[executor_id]) {
+ var previous = this_.scope.monitor.frameworks[framework_id].executors[executor_id].statistics;
current.diffUsage(previous);
}