mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
[cpplint] add stdin support in stdin
Cpplint can already process input from stdin (when the filename is '-'), but `git cl lint` currently lacks this capability. Adding stdin support to `git cl lint` would enable seamless integration with IDEs like Visual Studio. Linters could then operate directly on unsaved code within the editor. Bug: 372288610 Change-Id: Ib2d5a3534ac0c5afcfcac64b708becde41612881 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5917767 Commit-Queue: Scott Lee <ddoman@chromium.org> Reviewed-by: Gavin Mak <gavinmak@google.com>
This commit is contained in:
7
cpplint.py
vendored
7
cpplint.py
vendored
@@ -6399,10 +6399,9 @@ def ProcessFile(filename, vlevel, extra_check_functions=[]):
|
||||
# If after the split a trailing '\r' is present, it is removed
|
||||
# below.
|
||||
if filename == '-':
|
||||
lines = codecs.StreamReaderWriter(sys.stdin,
|
||||
codecs.getreader('utf8'),
|
||||
codecs.getwriter('utf8'),
|
||||
'replace').read().split('\n')
|
||||
lines = codecs.StreamReaderWriter(
|
||||
sys.stdin.read().encode('utf8'), codecs.getreader('utf8'),
|
||||
codecs.getwriter('utf8'), 'replace').decode('utf8').split('\n')
|
||||
else:
|
||||
with codecs.open(filename, 'r', 'utf8', 'replace') as stream:
|
||||
lines = stream.read().split('\n')
|
||||
|
||||
Reference in New Issue
Block a user