Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
tools: add C++ lint rule to avoid using String::Utf8Value
We should be using our own helpers for this instead.
  • Loading branch information
addaleax committed Oct 13, 2025
commit 83907b6ca2e475c5a1efa658e8378632c1ce8243
19 changes: 19 additions & 0 deletions tools/cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -6489,6 +6489,23 @@ 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.
"""
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):
Expand Down Expand Up @@ -6660,6 +6677,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.

Expand Down
Loading