Revision: 326
http://sourceforge.net/p/javascriptlint/code/326
Author: matthiasmiller
Date: 2013-10-02 23:16:54 +0000 (Wed, 02 Oct 2013)
Log Message:
-----------
pylint: start work to run pylint on jsl
Modified Paths:
--------------
trunk/test.py
Modified: trunk/test.py
===================================================================
--- trunk/test.py 2013-10-01 17:12:20 UTC (rev 325)
+++ trunk/test.py 2013-10-02 23:16:54 UTC (rev 326)
@@ -4,6 +4,9 @@
import re
import sys
+import pylint.lint
+from pylint.reporters.text import TextReporter
+
import javascriptlint.conf
import javascriptlint.lint
@@ -90,7 +93,93 @@
all_files.sort()
return all_files
+class _CustomLintReporter(TextReporter):
+ line_format = '{path}({line}): [{msg_id}({symbol}){obj}] {msg}'
+ def __init__(self):
+ TextReporter.__init__(self)
+ self.msg_count = 0
+
+ def write_message(self, msg):
+ TextReporter.write_message(self, msg)
+ self.msg_count += 1
+
+def _get_python_modules(dir_):
+ for root, dirs, files in os.walk(dir_):
+ if '.svn' in dirs:
+ dirs.remove('.svn')
+ for name in files:
+ if name.endswith('.py'):
+ yield os.path.join(root, name)
+
+def _run_pylint():
+ IGNORE = [
+ 'C0111', # Missing docstring
+ 'I0011', # Locally disabling warning
+ 'R0902', # Too many instance attributes (%s/%s)
+ 'R0903', # Too few public methods (%s/%s)
+ 'R0904', # Too many public methods (%s/%s)
+ 'R0911', # Too many return statements (%s/%s)
+ 'R0912', # Too many branches (%s/%s)
+ 'R0913', # Too many arguments (%s/%s)
+ 'R0914', # Too many local variables (%s/%s)
+ 'R0915', # Too many statements (%s/%s)
+ 'W0142', # Used * or ** magic
+ ]
+ REVIEW = [
+ 'C0103', # Invalid name "%s" (should match %s)
+ 'C0202', # Class method should have "cls" as first argument
+ 'C0301', # Line too long (%s/%s)
+ 'C0303', # Trailing whitespace
+ 'C0321', # More than one statement on a single line
+ 'C0323', # Operator not followed by a space
+ 'C0324', # Comma not followed by a space
+ 'C1001', # Old style class
+ 'E0602', # Undefined variable %r
+ 'E1101', # %s %r has no %r member
+ 'E1103', # %s %r has no %r member (but some types could not be inferred)
+ 'E1306', # Not enough arguments for format string
+ 'F0401', # Cyclic import (%s)
+ 'R0201', # Attribute %r defined outside __init__
+ 'R0924', # Badly implemented
+ 'W0109', # Duplicate key %r in dictionary
+ 'W0120', # Else clause on loop without a break statement
+ 'W0121', # old-raise-syntax
+ 'W0141', # Used builtin function %r
+ 'W0201', # Attribute %r defined outside __init__
+ 'W0212', # Access to a protected member %s of a client class
+ 'W0231', # __init__ method from base class %r is not called
+ 'W0232', # Class has no __init__ method
+ 'W0301', # Unnecessary semicolon
+ 'W0311', # Bad indentation
+ 'W0401', # Wildcard import %s
+ 'W0403', # Relative import %r
+ 'W0511', # TODO
+ 'W0611', # Unused import %s
+ 'W0612', # unused variable
+ 'W0613', # Unused argument %r
+ 'W0614', # Unused import %s from wildcard import
+ 'W0621', # Redefining name %r from outer scope (line %s)
+ 'W0622', # Redefining built-in %r
+ 'W0631', # Using possibly undefined loop variable %r
+ 'W0632', # unbalanced-tuple-unpacking
+ 'W1401', # Anomalous backslash in string
+ ]
+
+ dir_ = os.path.dirname(os.path.abspath(__file__))
+ modules = list(_get_python_modules(dir_))
+ reporter = _CustomLintReporter()
+ pylint.lint.Run([
+ '--reports=n',
+ ] + [
+ '--disable=%s' % code for code in (IGNORE + REVIEW)
+ ] + modules, reporter=reporter, exit=False)
+ if reporter.msg_count:
+ print '\nLint failed!\n'
+ sys.exit(1)
+
def main():
+ _run_pylint()
+
haderrors = False
for file in _get_test_files():
ext = os.path.splitext(file)[1]
@@ -108,5 +197,9 @@
sys.exit(haderrors)
if __name__ == '__main__':
- main()
+ try:
+ main()
+ except KeyboardInterrupt:
+ sys.stderr.write('\n\nCanceled.\n')
+ sys.exit(1)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|