This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Improve rename_check.py
ClosedPublic

Authored by omtcyfz on Sep 30 2016, 12:06 AM.

Details

Summary

-Start using argparse instead of mimicking CLI parsing.
-PEPify the code.
-Decrease the number of imports by slightly cleaning up the script.

Diff Detail

Event Timeline

omtcyfz updated this revision to Diff 72990.Sep 30 2016, 12:06 AM
omtcyfz retitled this revision from to [clang-tidy] Improve rename_check.py.
omtcyfz updated this object.
omtcyfz added reviewers: PiotrZSL, ioeric, aaron.ballman.
omtcyfz added a subscriber: cfe-commits.
alexander-shaposhnikov added inline comments.
clang-tidy/rename_check.py
113

the script always prints the args, is it intentional ?

omtcyfz updated this revision to Diff 73018.Sep 30 2016, 2:29 AM
omtcyfz marked an inline comment as done.

Remove leftover from debugging.

omtcyfz added inline comments.Sep 30 2016, 3:19 AM
clang-tidy/rename_check.py
113

Aw, a leftover from debugging.

Good catch! Thanks for the note!

omtcyfz edited reviewers, added: bkramer; removed: ioeric.Sep 30 2016, 5:31 AM
alexfh requested changes to this revision.Oct 27 2016, 7:34 AM
alexfh added a reviewer: alexfh.
alexfh added a subscriber: alexfh.

Kirill, if you still have time for this, could you submit reformatting as a separate patch to make semantic changes more visible?

This revision now requires changes to proceed.Oct 27 2016, 7:34 AM
omtcyfz updated this revision to Diff 76593.Nov 1 2016, 10:34 AM
omtcyfz edited edge metadata.

Reversed "tabwidth:2 -> tabwidth:4" change.
Removed unused dependency (re).
Got rid of sys.argv[0] via using Pythonic __file__ and removed (now) redundant dependency (sys).

alexfh accepted this revision.Nov 7 2016, 11:22 AM
alexfh edited edge metadata.

One nit. Otherwise looks good. Thank you!

clang-tidy/rename_check.py
89

Does PEP8 have any preferences with regard to using a terminating backslash over enclosing an expression that needs to be wrapped in parentheses? If no, I'd better use parentheses.

This revision is now accepted and ready to land.Nov 7 2016, 11:22 AM
omtcyfz updated this revision to Diff 77168.Nov 8 2016, 3:42 AM
omtcyfz edited edge metadata.

Addressing comments Alex made about line breaks.

clang-tidy/rename_check.py
89

Hm, apparently it does.

The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. Long lines can be broken over multiple lines by wrapping expressions in parentheses. These should be used in preference to using a backslash for line continuation.

Didn't know it, though. Thank you for pointing it out!

omtcyfz updated this object.Nov 8 2016, 3:49 AM
This revision was automatically updated to reflect the committed changes.