mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
tools: add C++ lint rule to avoid using String::Utf8Value
We should be using our own helpers for this instead. PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
39447be4e4
commit
e6d94ef106
22
tools/cpplint.py
vendored
22
tools/cpplint.py
vendored
|
|
@ -6489,6 +6489,26 @@ def CheckLocalVectorUsage(filename, lines, error):
|
|||
'Do not use std::vector<v8::Local<T>>. '
|
||||
'Use v8::LocalVector<T> instead.')
|
||||
|
||||
def CheckStringValueUsage(filename, lines, error):
|
||||
"""Logs an error if v8's String::Value/Utf8Value are used.
|
||||
Args:
|
||||
filename: The name of the current file.
|
||||
lines: An array of strings, each representing a line of the file.
|
||||
error: The function to call with any errors found.
|
||||
"""
|
||||
if filename.startswith('test/') or filename.startswith('test\\'):
|
||||
return # Skip test files, where Node.js headers may not be available
|
||||
|
||||
for linenum, line in enumerate(lines):
|
||||
if Search(r'\bString::Utf8Value\b', line):
|
||||
error(filename, linenum, 'runtime/v8_string_value', 5,
|
||||
'Do not use v8::String::Utf8Value. '
|
||||
'Use node::Utf8Value instead.')
|
||||
if Search(r'\bString::Value\b', line):
|
||||
error(filename, linenum, 'runtime/v8_string_value', 5,
|
||||
'Do not use v8::String::Value. '
|
||||
'Use node::TwoByteValue instead.')
|
||||
|
||||
def ProcessLine(filename, file_extension, clean_lines, line,
|
||||
include_state, function_state, nesting_state, error,
|
||||
extra_check_functions=None):
|
||||
|
|
@ -6660,6 +6680,8 @@ def ProcessFileData(filename, file_extension, lines, error,
|
|||
|
||||
CheckLocalVectorUsage(filename, lines, error)
|
||||
|
||||
CheckStringValueUsage(filename, lines, error)
|
||||
|
||||
def ProcessConfigOverrides(filename):
|
||||
""" Loads the configuration files and processes the config overrides.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user