diff options
| author | carl <devnull@localhost> | 2014-08-21 16:02:41 +0200 |
|---|---|---|
| committer | carl <devnull@localhost> | 2014-08-21 16:02:41 +0200 |
| commit | c025fc4b8c8561e09c864e2473741dedefed0877 (patch) | |
| tree | 057f80e802da8c130f89890499d73a5d9589bbea | |
| parent | 89aeb11ab83422f28ab2f894599bffb28a33ae51 (diff) | |
| download | pylint-c025fc4b8c8561e09c864e2473741dedefed0877.tar.gz | |
Notes (TODO, XXX etc) are now searched for using a simple `in` before resorting to the regular expression, in order to avoid using the regexp on every line and to prevent a pathological problem for extremely long lines (50k+ characters)
| -rw-r--r-- | checkers/misc.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/checkers/misc.py b/checkers/misc.py index b53f882..b27b86a 100644 --- a/checkers/misc.py +++ b/checkers/misc.py @@ -54,6 +54,17 @@ class EncodingChecker(BaseChecker): 'separated by a comma.')}),) def _check_note(self, notes, lineno, line): + # First, simply check if the notes are in the line at all. This is an + # optimisation to prevent using the regular expression on every line, + # but rather only on lines which may actually contain one of the notes. + # This prevents a pathological problem with lines that are hundreds + # of thousands of characters long. + for note in self.config.notes: + if note in line: + break + else: + return + match = notes.search(line) if not match: return |
