zulip/tools/linter_lib
Greg Price f632692188 lint: Fix use of re.match in judging long lines.
The `re.match` function in the Python stdlib is a trap for the unwary,
with surprising and asymmetrical semantics; we should probably add a
lint rule to ban it entirely.  The docstring says:

> Try to apply the pattern at the start of the string, [...]

In other words, it effectively adds a `^` at the start (or `\A`, where
the distinction matters.)  It's bad enough that this differs from what
grep, sed, perl, less, and every other tool I can think of do when
looking for matches to a regex; on top of that, it treats the
beginning of the string differently from the end, for no obvious
reason.  The function that does what the rest of the world understands
by "match against this regex" is `re.search`.

In this case, it's unlikely that anyone intended for comments with
URLs, or `api_url` references, to miss out on their respective
exceptions to the long-line rule if they happen to start after the
first column.  So fix those rules by just switching to `re.search`
with the same pattern.

I think Markdown URL references may have to start at the beginning of
the line, so I've left a `^` there to preserve -- but now make
explicit -- the `re.match` behavior.
2017-11-28 16:23:10 -08:00
..
__init__.py Extract tools/linter_lib/custom_check.py. 2017-06-05 09:20:21 -07:00
custom_check.py lint: Fix use of re.match in judging long lines. 2017-11-28 16:23:10 -08:00
exclude.py api: Update lint and analysis code to forget about now-gone files. 2017-07-31 21:24:52 -07:00
pep8.py lint: Disable a buggy `pep8` rule on line breaks and operators. 2017-10-26 10:29:17 -07:00
printer.py Remove `from __future__ import absolute_import`. 2017-10-17 22:59:42 -07:00
pyflakes.py lint: Fix problematic merging of pyflakes stdout/stderr. 2017-08-29 10:44:50 -07:00