Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 11ebb04

Browse filesBrowse files
addaleaxaduh95
authored andcommitted
tools: add C++ lint rule to avoid using String::Utf8Value
We should be using our own helpers for this instead. PR-URL: #60244 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ilyas Shabi <ilyasshabi94@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Vladimir Morozov <vmorozov@microsoft.com>
1 parent afdb362 commit 11ebb04
Copy full SHA for 11ebb04

File tree

Expand file treeCollapse file tree

1 file changed

+22
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+22
-0
lines changed
Open diff view settings
Collapse file

‎tools/cpplint.py‎

Copy file name to clipboardExpand all lines: tools/cpplint.py
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6489,6 +6489,26 @@ def CheckLocalVectorUsage(filename, lines, error):
64896489
'Do not use std::vector<v8::Local<T>>. '
64906490
'Use v8::LocalVector<T> instead.')
64916491

6492+
def CheckStringValueUsage(filename, lines, error):
6493+
"""Logs an error if v8's String::Value/Utf8Value are used.
6494+
Args:
6495+
filename: The name of the current file.
6496+
lines: An array of strings, each representing a line of the file.
6497+
error: The function to call with any errors found.
6498+
"""
6499+
if filename.startswith('test/') or filename.startswith('test\\'):
6500+
return # Skip test files, where Node.js headers may not be available
6501+
6502+
for linenum, line in enumerate(lines):
6503+
if Search(r'\bString::Utf8Value\b', line):
6504+
error(filename, linenum, 'runtime/v8_string_value', 5,
6505+
'Do not use v8::String::Utf8Value. '
6506+
'Use node::Utf8Value instead.')
6507+
if Search(r'\bString::Value\b', line):
6508+
error(filename, linenum, 'runtime/v8_string_value', 5,
6509+
'Do not use v8::String::Value. '
6510+
'Use node::TwoByteValue instead.')
6511+
64926512
def ProcessLine(filename, file_extension, clean_lines, line,
64936513
include_state, function_state, nesting_state, error,
64946514
extra_check_functions=None):
@@ -6660,6 +6680,8 @@ def ProcessFileData(filename, file_extension, lines, error,
66606680

66616681
CheckLocalVectorUsage(filename, lines, error)
66626682

6683+
CheckStringValueUsage(filename, lines, error)
6684+
66636685
def ProcessConfigOverrides(filename):
66646686
""" Loads the configuration files and processes the config overrides.
66656687

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.