diff options
| author | Torsten Marek <tmarek@google.com> | 2013-06-19 10:59:37 +0200 |
|---|---|---|
| committer | Torsten Marek <tmarek@google.com> | 2013-06-19 10:59:37 +0200 |
| commit | 0353142ac9bd8f860ffb20937de9f1b35dc87a20 (patch) | |
| tree | 9b81e719a2ae1170a49ad62e5de34a8ca4a87841 /checkers/misc.py | |
| parent | 7bcb96848e634e1d6db55995e5286168a5ca02a6 (diff) | |
| download | pylint-git-0353142ac9bd8f860ffb20937de9f1b35dc87a20.tar.gz | |
Clean up misc checker, use single regex instead of several ones.
Diffstat (limited to 'checkers/misc.py')
| -rw-r--r-- | checkers/misc.py | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/checkers/misc.py b/checkers/misc.py index 9ecdde971..b134c7e62 100644 --- a/checkers/misc.py +++ b/checkers/misc.py @@ -48,29 +48,20 @@ separated by a comma.' }), ) - def __init__(self, linter=None): - BaseChecker.__init__(self, linter) - + def _check_note(self, notes, lineno, line): + match = notes.search(line) + if match: + self.add_message('W0511', args=line[match.start():-1], line=lineno) + def process_module(self, node): """inspect the source file to found encoding problem or fixmes like notes """ stream = node.file_stream stream.seek(0) # XXX may be removed with astroid > 0.23 - # warning notes in the code - notes = [] - for note in self.config.notes: - notes.append(re.compile(note)) - linenum = 1 - for line in stream.readlines(): - for note in notes: - match = note.search(line) - if match: - self.add_message('W0511', args=line[match.start():-1], - line=linenum) - break - linenum += 1 - + notes = re.compile('|'.join(self.config.notes)) + for lineno, line in enumerate(stream): + self._check_note(notes, lineno+1, line) def register(linter): |
