Procházet zdrojové kódy

Disable the remaining pylint warnings locally and enable pylint warnings in PRESUBMIT.

This causes some code clutter.

TEST=Increased pylint warning level
BUG=none

Review URL: http://codereview.chromium.org/4321006

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@64913 0039d316-1c4b-4281-b951-d872f2087c98
maruel@chromium.org před 15 roky
rodič
revize
b17b55beca
8 změnil soubory, kde provedl 41 přidání a 9 odebrání
  1. 6 6
      PRESUBMIT.py
  2. 2 0
      breakpad.py
  3. 2 0
      gcl.py
  4. 4 0
      gclient.py
  5. 6 0
      gclient_utils.py
  6. 2 0
      presubmit_canned_checks.py
  7. 14 2
      presubmit_support.py
  8. 5 1
      pylintrc

+ 6 - 6
PRESUBMIT.py

@@ -57,17 +57,17 @@ def RunPylint(input_api, output_api):
   # It uses non-standard pylint exceptions that makes pylint always fail.
   files.remove('cpplint.py')
   try:
-    proc = input_api.subprocess.Popen(['pylint', '-E'] + sorted(files))
+    proc = input_api.subprocess.Popen(['pylint'] + sorted(files))
     proc.communicate()
     if proc.returncode:
       return [output_api.PresubmitError('Fix pylint errors first.')]
     return []
-  except OSError, e:
+  except OSError:
     if input_api.platform == 'win32':
-        return [output_api.PresubmitNotifyResult(
-          'Warning: Can\'t run pylint because it is not installed. Please '
-          'install manually\n'
-          'Cannot do static analysis of python files.')]
+      return [output_api.PresubmitNotifyResult(
+        'Warning: Can\'t run pylint because it is not installed. Please '
+        'install manually\n'
+        'Cannot do static analysis of python files.')]
     return [output_api.PresubmitError(
         'Please install pylint with "sudo apt-get install python-setuptools; '
         'sudo easy_install pylint"\n'

+ 2 - 0
breakpad.py

@@ -41,6 +41,8 @@ def SendStack(last_tb, stack, url=None):
         'host': socket.getfqdn(),
         'cwd': os.getcwd(),
     }
+    # No exception type(s) specified
+    # pylint: disable=W0702
     try:
       # That may not always work.
       params['exception'] = str(last_tb)

+ 2 - 0
gcl.py

@@ -1129,6 +1129,8 @@ def CMDlint(change_info, args):
   if not black_list:
     black_list = DEFAULT_LINT_IGNORE_REGEX
   black_regex = re.compile(black_list)
+  # Access to a protected member _XX of a client class
+  # pylint: disable=W0212
   for filename in filenames:
     if white_regex.match(filename):
       if black_regex.match(filename):

+ 4 - 0
gclient.py

@@ -332,6 +332,8 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem):
           None, should_process))
     logging.debug('Loaded: %s' % str(self))
 
+  # Arguments number differs from overridden method
+  # pylint: disable=W0221
   def run(self, revision_overrides, command, args, work_queue, options):
     """Runs 'command' before parsing the DEPS in case it's a initial checkout
     or a revert."""
@@ -1190,6 +1192,8 @@ def Main(argv):
     # Make stdout annotated with the thread ids.
     sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout)
     # Do it late so all commands are listed.
+    # Unused variable 'usage'
+    # pylint: disable=W0612
     CMDhelp.usage = ('\n\nCommands are:\n' + '\n'.join([
         '  %-10s %s' % (fn[3:], Command(fn[3:]).__doc__.split('\n')[0].strip())
         for fn in dir(sys.modules[__name__]) if fn.startswith('CMD')]))

+ 6 - 0
gclient_utils.py

@@ -316,6 +316,8 @@ def MakeFileAutoFlush(fileobj, delay=10):
     fileobj.delay = delay
     return fileobj
 
+  # Attribute 'XXX' defined outside __init__
+  # pylint: disable=W0201
   new_fileobj = SoftClone(fileobj)
   if not hasattr(new_fileobj, 'lock'):
     new_fileobj.lock = threading.Lock()
@@ -350,6 +352,8 @@ def MakeFileAnnotated(fileobj):
     # Already patched.
     return fileobj
 
+  # Attribute 'XXX' defined outside __init__
+  # pylint: disable=W0201
   new_fileobj = SoftClone(fileobj)
   if not hasattr(new_fileobj, 'lock'):
     new_fileobj.lock = threading.Lock()
@@ -698,6 +702,8 @@ class ExecutionQueue(object):
       """Runs in its own thread."""
       logging.debug('running(%s)' % self.item.name)
       work_queue = self.kwargs['work_queue']
+      # It's necessary to catch all exceptions.
+      # pylint: disable=W0703
       try:
         self.item.run(*self.args, **self.kwargs)
       except Exception:

+ 2 - 0
presubmit_canned_checks.py

@@ -81,6 +81,8 @@ def CheckChangeLintsClean(input_api, output_api, source_file_filter=None):
 
   # Initialize cpplint.
   import cpplint
+  # Access to a protected member _XX of a client class
+  # pylint: disable=W0212
   cpplint._cpplint_state.ResetErrorCounts()
 
   # Justifications for each filter:

+ 14 - 2
presubmit_support.py

@@ -41,6 +41,8 @@ except ImportError:
     import json
     # Some versions of python2.5 have an incomplete json module.  Check to make
     # sure loads exists.
+    # Statement seems to have no effect
+    # pylint: disable=W0104
     json.loads
   except (ImportError, AttributeError):
     # Import the one included in depot_tools.
@@ -95,7 +97,8 @@ class OutputApi(object):
   """This class (more like a module) gets passed to presubmit scripts so that
   they can specify various types of results.
   """
-
+  # Method could be a function
+  # pylint: disable=R0201
   class PresubmitResult(object):
     """Base class for result objects."""
 
@@ -177,6 +180,8 @@ class InputApi(object):
   """An instance of this object is passed to presubmit scripts so they can
   know stuff about the change they're looking at.
   """
+  # Method could be a function
+  # pylint: disable=R0201
 
   # File extensions that are considered source files from a style guide
   # perspective. Don't modify this list from a presubmit script!
@@ -392,7 +397,8 @@ class InputApi(object):
 
 class AffectedFile(object):
   """Representation of a file in a change."""
-
+  # Method could be a function
+  # pylint: disable=R0201
   def __init__(self, path, action, repository_root=''):
     self._path = path
     self._action = action
@@ -480,6 +486,8 @@ class AffectedFile(object):
 
 class SvnAffectedFile(AffectedFile):
   """Representation of a file in a change out of a Subversion checkout."""
+  # Method 'NNN' is abstract in class 'NNN' but is not overridden
+  # pylint: disable=W0223
 
   def __init__(self, *args, **kwargs):
     AffectedFile.__init__(self, *args, **kwargs)
@@ -526,6 +534,8 @@ class SvnAffectedFile(AffectedFile):
 
 class GitAffectedFile(AffectedFile):
   """Representation of a file in a change out of a git checkout."""
+  # Method 'NNN' is abstract in class 'NNN' but is not overridden
+  # pylint: disable=W0223
 
   def __init__(self, *args, **kwargs):
     AffectedFile.__init__(self, *args, **kwargs)
@@ -996,6 +1006,8 @@ def DoPresubmitChecks(change,
     if items:
       output_stream.write('** Presubmit %s **\n' % name)
       for item in items:
+        # Access to a protected member XXX of a client class
+        # pylint: disable=W0212
         if not item._Handle(output_stream, input_stream,
                             may_prompt=False):
           error_count += 1

+ 5 - 1
pylintrc

@@ -36,6 +36,10 @@ load-plugins=
 # C0111: Missing docstring
 # C0302: Too many lines in module (N)
 # I0011: Locally disabling WNNNN
+#
+# It's a problem but not something we can fix right now.
+# R0401: Cyclic import
+#
 # R0801: Similar lines in N files
 # R0901: Too many ancestors (8/7)
 # R0902: Too many instance attributes (N/7)
@@ -53,7 +57,7 @@ load-plugins=
 # W0603: Using the global statement
 # W0613: Unused argument ''
 # W6501: Specify string format arguments as logging function parameters
-disable=C0103,C0111,C0302,I0011,R0801,R0901,R0902,R0903,R0911,R0912,R0913,R0914,R0915,W0122,W0141,W0142,W0402,W0511,W0603,W0613,W6501
+disable=C0103,C0111,C0302,I0011,R0401,R0801,R0901,R0902,R0903,R0911,R0912,R0913,R0914,R0915,W0122,W0141,W0142,W0402,W0511,W0603,W0613,W6501
 
 
 [REPORTS]