Skip to content

Use 'in' instead of 'find()' in tidy.py #21377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/etc/tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ def do_license_check(name, contents):
for line in fileinput.input(file_names,
openhook=fileinput.hook_encoded("utf-8")):

if fileinput.filename().find("tidy.py") == -1:
if line.find(cr_flag) != -1:
if "tidy.py" not in fileinput.filename():
if cr_flag in line:
check_cr = False
if line.find(tab_flag) != -1:
if tab_flag in line:
check_tab = False
if line.find(linelength_flag) != -1:
if linelength_flag in line:
check_linelength = False
if line.find("TODO") != -1:
if "TODO" in line:
report_err("TODO is deprecated; use FIXME")
match = re.match(r'^.*/(\*|/!?)\s*XXX', line)
if match:
Expand All @@ -86,10 +86,10 @@ def do_license_check(name, contents):
if "SNAP" in line:
report_warn("unmatched SNAP line: " + line)

if check_tab and (line.find('\t') != -1 and
fileinput.filename().find("Makefile") == -1):
if check_tab and ('\t' in line and
"Makefile" not in fileinput.filename()):
report_err("tab character")
if check_cr and not autocrlf and line.find('\r') != -1:
if check_cr and not autocrlf and '\r' in line:
report_err("CR character")
if line.endswith(" \n") or line.endswith("\t\n"):
report_err("trailing whitespace")
Expand Down