chore: fix clang-tidy warnings (#38079)
* chore: fix clang-tidy warnings * refactor: avoid need for NOLINTNEXTLINE
This commit is contained in:
parent
fe5cdd39d6
commit
08593fd2bd
20 changed files with 41 additions and 37 deletions
4
.clang-tidy
Normal file
4
.clang-tidy
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
Checks: '-modernize-use-nullptr'
|
||||||
|
InheritParentConfig: true
|
||||||
|
...
|
|
@ -243,8 +243,8 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
|
||||||
std::vector<DesktopCapturer::Source> window_sources;
|
std::vector<DesktopCapturer::Source> window_sources;
|
||||||
window_sources.reserve(list->GetSourceCount());
|
window_sources.reserve(list->GetSourceCount());
|
||||||
for (int i = 0; i < list->GetSourceCount(); i++) {
|
for (int i = 0; i < list->GetSourceCount(); i++) {
|
||||||
window_sources.emplace_back(DesktopCapturer::Source{
|
window_sources.emplace_back(list->GetSource(i), std::string(),
|
||||||
list->GetSource(i), std::string(), fetch_window_icons_});
|
fetch_window_icons_);
|
||||||
}
|
}
|
||||||
std::move(window_sources.begin(), window_sources.end(),
|
std::move(window_sources.begin(), window_sources.end(),
|
||||||
std::back_inserter(captured_sources_));
|
std::back_inserter(captured_sources_));
|
||||||
|
@ -256,8 +256,7 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
|
||||||
std::vector<DesktopCapturer::Source> screen_sources;
|
std::vector<DesktopCapturer::Source> screen_sources;
|
||||||
screen_sources.reserve(list->GetSourceCount());
|
screen_sources.reserve(list->GetSourceCount());
|
||||||
for (int i = 0; i < list->GetSourceCount(); i++) {
|
for (int i = 0; i < list->GetSourceCount(); i++) {
|
||||||
screen_sources.emplace_back(
|
screen_sources.emplace_back(list->GetSource(i), std::string());
|
||||||
DesktopCapturer::Source{list->GetSource(i), std::string()});
|
|
||||||
}
|
}
|
||||||
#if BUILDFLAG(IS_WIN)
|
#if BUILDFLAG(IS_WIN)
|
||||||
// Gather the same unique screen IDs used by the electron.screen API in
|
// Gather the same unique screen IDs used by the electron.screen API in
|
||||||
|
|
|
@ -17,17 +17,21 @@ namespace electron::api {
|
||||||
|
|
||||||
gin::WrapperInfo SystemPreferences::kWrapperInfo = {gin::kEmbedderNativeGin};
|
gin::WrapperInfo SystemPreferences::kWrapperInfo = {gin::kEmbedderNativeGin};
|
||||||
|
|
||||||
|
#if BUILDFLAG(IS_WIN)
|
||||||
SystemPreferences::SystemPreferences() {
|
SystemPreferences::SystemPreferences() {
|
||||||
#if BUILDFLAG(IS_WIN)
|
|
||||||
InitializeWindow();
|
InitializeWindow();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
SystemPreferences::SystemPreferences() = default;
|
||||||
|
#endif
|
||||||
|
|
||||||
SystemPreferences::~SystemPreferences() {
|
|
||||||
#if BUILDFLAG(IS_WIN)
|
#if BUILDFLAG(IS_WIN)
|
||||||
|
SystemPreferences::~SystemPreferences() {
|
||||||
Browser::Get()->RemoveObserver(this);
|
Browser::Get()->RemoveObserver(this);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
SystemPreferences::~SystemPreferences() = default;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool SystemPreferences::IsInvertedColorScheme() {
|
bool SystemPreferences::IsInvertedColorScheme() {
|
||||||
return ui::NativeTheme::GetInstanceForNativeUi()
|
return ui::NativeTheme::GetInstanceForNativeUi()
|
||||||
|
|
|
@ -455,6 +455,7 @@ v8::Local<v8::Promise> SystemPreferences::PromptTouchID(
|
||||||
operation:LAAccessControlOperationUseKeySign
|
operation:LAAccessControlOperationUseKeySign
|
||||||
localizedReason:[NSString stringWithUTF8String:reason.c_str()]
|
localizedReason:[NSString stringWithUTF8String:reason.c_str()]
|
||||||
reply:^(BOOL success, NSError* error) {
|
reply:^(BOOL success, NSError* error) {
|
||||||
|
// NOLINTBEGIN(bugprone-use-after-move)
|
||||||
if (!success) {
|
if (!success) {
|
||||||
std::string err_msg = std::string(
|
std::string err_msg = std::string(
|
||||||
[error.localizedDescription UTF8String]);
|
[error.localizedDescription UTF8String]);
|
||||||
|
@ -470,6 +471,7 @@ v8::Local<v8::Promise> SystemPreferences::PromptTouchID(
|
||||||
gin_helper::Promise<void>::ResolvePromise,
|
gin_helper::Promise<void>::ResolvePromise,
|
||||||
std::move(p)));
|
std::move(p)));
|
||||||
}
|
}
|
||||||
|
// NOLINTEND(bugprone-use-after-move)
|
||||||
}];
|
}];
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
|
|
|
@ -279,7 +279,7 @@ void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {
|
||||||
|
|
||||||
bool UtilityProcessWrapper::Kill() const {
|
bool UtilityProcessWrapper::Kill() const {
|
||||||
if (pid_ == base::kNullProcessId)
|
if (pid_ == base::kNullProcessId)
|
||||||
return 0;
|
return false;
|
||||||
base::Process process = base::Process::Open(pid_);
|
base::Process process = base::Process::Open(pid_);
|
||||||
bool result = process.Terminate(content::RESULT_CODE_NORMAL_EXIT, false);
|
bool result = process.Terminate(content::RESULT_CODE_NORMAL_EXIT, false);
|
||||||
// Refs https://bugs.chromium.org/p/chromium/issues/detail?id=818244
|
// Refs https://bugs.chromium.org/p/chromium/issues/detail?id=818244
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
namespace electron {
|
namespace electron {
|
||||||
|
|
||||||
GPUInfoEnumerator::GPUInfoEnumerator() : value_stack_(), current_{} {}
|
GPUInfoEnumerator::GPUInfoEnumerator() = default;
|
||||||
|
|
||||||
GPUInfoEnumerator::~GPUInfoEnumerator() = default;
|
GPUInfoEnumerator::~GPUInfoEnumerator() = default;
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ std::string ElectronBluetoothDelegate::GetDeviceAddress(
|
||||||
RenderFrameHost* frame,
|
RenderFrameHost* frame,
|
||||||
const WebBluetoothDeviceId& device_id) {
|
const WebBluetoothDeviceId& device_id) {
|
||||||
NOTIMPLEMENTED();
|
NOTIMPLEMENTED();
|
||||||
return nullptr;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
WebBluetoothDeviceId ElectronBluetoothDelegate::AddScannedDevice(
|
WebBluetoothDeviceId ElectronBluetoothDelegate::AddScannedDevice(
|
||||||
|
|
|
@ -203,16 +203,16 @@ void ElectronPermissionManager::RequestPermissionsWithDetails(
|
||||||
int request_id = pending_requests_.Add(std::make_unique<PendingRequest>(
|
int request_id = pending_requests_.Add(std::make_unique<PendingRequest>(
|
||||||
render_frame_host, permissions, std::move(response_callback)));
|
render_frame_host, permissions, std::move(response_callback)));
|
||||||
|
|
||||||
|
details.Set("requestingUrl", render_frame_host->GetLastCommittedURL().spec());
|
||||||
|
details.Set("isMainFrame", render_frame_host->GetParent() == nullptr);
|
||||||
|
base::Value dict_value(std::move(details));
|
||||||
|
|
||||||
for (size_t i = 0; i < permissions.size(); ++i) {
|
for (size_t i = 0; i < permissions.size(); ++i) {
|
||||||
auto permission = permissions[i];
|
auto permission = permissions[i];
|
||||||
const auto callback =
|
const auto callback =
|
||||||
base::BindRepeating(&ElectronPermissionManager::OnPermissionResponse,
|
base::BindRepeating(&ElectronPermissionManager::OnPermissionResponse,
|
||||||
base::Unretained(this), request_id, i);
|
base::Unretained(this), request_id, i);
|
||||||
details.Set("requestingUrl",
|
request_handler_.Run(web_contents, permission, callback, dict_value);
|
||||||
render_frame_host->GetLastCommittedURL().spec());
|
|
||||||
details.Set("isMainFrame", render_frame_host->GetParent() == nullptr);
|
|
||||||
request_handler_.Run(web_contents, permission, callback,
|
|
||||||
base::Value(std::move(details)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,6 @@ struct FileSelectHelper::ActiveDirectoryEnumeration {
|
||||||
FileSelectHelper::FileSelectHelper()
|
FileSelectHelper::FileSelectHelper()
|
||||||
: render_frame_host_(nullptr),
|
: render_frame_host_(nullptr),
|
||||||
web_contents_(nullptr),
|
web_contents_(nullptr),
|
||||||
select_file_dialog_(),
|
|
||||||
select_file_types_(),
|
|
||||||
dialog_type_(ui::SelectFileDialog::SELECT_OPEN_FILE),
|
dialog_type_(ui::SelectFileDialog::SELECT_OPEN_FILE),
|
||||||
dialog_mode_(FileChooserParams::Mode::kOpen) {}
|
dialog_mode_(FileChooserParams::Mode::kOpen) {}
|
||||||
|
|
||||||
|
|
|
@ -103,13 +103,11 @@ const FontDefault kFontDefaults[] = {
|
||||||
IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN},
|
IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN},
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
const size_t kFontDefaultsLength = std::size(kFontDefaults);
|
|
||||||
|
|
||||||
// ^^^^^ DO NOT EDIT ^^^^^
|
// ^^^^^ DO NOT EDIT ^^^^^
|
||||||
|
|
||||||
std::string GetDefaultFontForPref(const char* pref_name) {
|
std::string GetDefaultFontForPref(const char* pref_name) {
|
||||||
for (size_t i = 0; i < kFontDefaultsLength; ++i) {
|
for (auto pref : kFontDefaults) {
|
||||||
FontDefault pref = kFontDefaults[i];
|
|
||||||
if (strcmp(pref.pref_name, pref_name) == 0) {
|
if (strcmp(pref.pref_name, pref_name) == 0) {
|
||||||
return l10n_util::GetStringUTF8(pref.resource_id);
|
return l10n_util::GetStringUTF8(pref.resource_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
// Unity data typedefs.
|
// Unity data typedefs.
|
||||||
typedef struct _UnityInspector UnityInspector;
|
typedef struct _UnityInspector UnityInspector;
|
||||||
typedef UnityInspector* (*unity_inspector_get_default_func)(void);
|
typedef UnityInspector* (*unity_inspector_get_default_func)();
|
||||||
typedef gboolean (*unity_inspector_get_unity_running_func)(
|
typedef gboolean (*unity_inspector_get_unity_running_func)(
|
||||||
UnityInspector* self);
|
UnityInspector* self);
|
||||||
|
|
||||||
|
|
|
@ -166,8 +166,8 @@ class AsarURLLoader : public network::mojom::URLLoader {
|
||||||
auto asar_validator = std::make_unique<AsarFileValidator>(
|
auto asar_validator = std::make_unique<AsarFileValidator>(
|
||||||
std::move(info.integrity.value()), std::move(file));
|
std::move(info.integrity.value()), std::move(file));
|
||||||
file_validator_raw = asar_validator.get();
|
file_validator_raw = asar_validator.get();
|
||||||
readable_data_source.reset(new mojo::FilteredDataSource(
|
readable_data_source = std::make_unique<mojo::FilteredDataSource>(
|
||||||
std::move(file_data_source), std::move(asar_validator)));
|
std::move(file_data_source), std::move(asar_validator));
|
||||||
} else {
|
} else {
|
||||||
readable_data_source = std::move(file_data_source);
|
readable_data_source = std::move(file_data_source);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,7 @@ std::string MakeCaseInsensitivePattern(const std::string& extension) {
|
||||||
return extension;
|
return extension;
|
||||||
|
|
||||||
std::string pattern("*.");
|
std::string pattern("*.");
|
||||||
for (std::size_t i = 0, n = extension.size(); i < n; i++) {
|
for (char ch : extension) {
|
||||||
char ch = extension[i];
|
|
||||||
if (!base::IsAsciiAlpha(ch)) {
|
if (!base::IsAsciiAlpha(ch)) {
|
||||||
pattern.push_back(ch);
|
pattern.push_back(ch);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -283,7 +283,7 @@ void ReadDialogPathsWithBookmarks(NSOpenPanel* dialog,
|
||||||
NSArray* urls = [dialog URLs];
|
NSArray* urls = [dialog URLs];
|
||||||
for (NSURL* url in urls)
|
for (NSURL* url in urls)
|
||||||
if ([url isFileURL]) {
|
if ([url isFileURL]) {
|
||||||
paths->push_back(base::FilePath(base::SysNSStringToUTF8([url path])));
|
paths->emplace_back(base::SysNSStringToUTF8([url path]));
|
||||||
bookmarks->push_back(GetBookmarkDataFromNSURL(url));
|
bookmarks->push_back(GetBookmarkDataFromNSURL(url));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@ void AddPropertyFilters(std::vector<ui::AXPropertyFilter>* property_filters,
|
||||||
ui::AXPropertyFilter::Type type) {
|
ui::AXPropertyFilter::Type type) {
|
||||||
for (const std::string& attribute : base::SplitString(
|
for (const std::string& attribute : base::SplitString(
|
||||||
attributes, " ", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) {
|
attributes, " ", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) {
|
||||||
property_filters->push_back(ui::AXPropertyFilter(attribute, type));
|
property_filters->emplace_back(attribute, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ UsbChooserContextFactory::UsbChooserContextFactory()
|
||||||
"UsbChooserContext",
|
"UsbChooserContext",
|
||||||
BrowserContextDependencyManager::GetInstance()) {}
|
BrowserContextDependencyManager::GetInstance()) {}
|
||||||
|
|
||||||
UsbChooserContextFactory::~UsbChooserContextFactory() {}
|
UsbChooserContextFactory::~UsbChooserContextFactory() = default;
|
||||||
|
|
||||||
KeyedService* UsbChooserContextFactory::BuildServiceInstanceFor(
|
KeyedService* UsbChooserContextFactory::BuildServiceInstanceFor(
|
||||||
content::BrowserContext* context) const {
|
content::BrowserContext* context) const {
|
||||||
|
|
|
@ -54,7 +54,7 @@ UsbChooserController::UsbChooserController(
|
||||||
}
|
}
|
||||||
|
|
||||||
UsbChooserController::~UsbChooserController() {
|
UsbChooserController::~UsbChooserController() {
|
||||||
RunCallback(/*device=*/nullptr);
|
RunCallback(/*device_info=*/nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
api::Session* UsbChooserController::GetSession() {
|
api::Session* UsbChooserController::GetSession() {
|
||||||
|
@ -85,7 +85,7 @@ void UsbChooserController::OnDeviceRemoved(
|
||||||
void UsbChooserController::OnDeviceChosen(gin::Arguments* args) {
|
void UsbChooserController::OnDeviceChosen(gin::Arguments* args) {
|
||||||
std::string device_id;
|
std::string device_id;
|
||||||
if (!args->GetNext(&device_id) || device_id.empty()) {
|
if (!args->GetNext(&device_id) || device_id.empty()) {
|
||||||
RunCallback(/*device=*/nullptr);
|
RunCallback(/*device_info=*/nullptr);
|
||||||
} else {
|
} else {
|
||||||
auto* device_info = chooser_context_->GetDeviceInfo(device_id);
|
auto* device_info = chooser_context_->GetDeviceInfo(device_id);
|
||||||
if (device_info) {
|
if (device_info) {
|
||||||
|
@ -95,7 +95,7 @@ void UsbChooserController::OnDeviceChosen(gin::Arguments* args) {
|
||||||
node::Environment* env = node::Environment::GetCurrent(isolate);
|
node::Environment* env = node::Environment::GetCurrent(isolate);
|
||||||
EmitWarning(env, "The device id " + device_id + " was not found.",
|
EmitWarning(env, "The device id " + device_id + " was not found.",
|
||||||
"UnknownUsbDeviceId");
|
"UnknownUsbDeviceId");
|
||||||
RunCallback(/*device=*/nullptr);
|
RunCallback(/*device_info=*/nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ void UsbChooserController::GotUsbDeviceList(
|
||||||
weak_factory_.GetWeakPtr())));
|
weak_factory_.GetWeakPtr())));
|
||||||
}
|
}
|
||||||
if (!prevent_default) {
|
if (!prevent_default) {
|
||||||
RunCallback(/*port=*/nullptr);
|
RunCallback(/*device_info=*/nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class IDUserData : public base::SupportsUserData::Data {
|
||||||
public:
|
public:
|
||||||
explicit IDUserData(int32_t id) : id_(id) {}
|
explicit IDUserData(int32_t id) : id_(id) {}
|
||||||
|
|
||||||
operator int32_t() const { return id_; }
|
explicit operator int32_t() const { return id_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32_t id_;
|
int32_t id_;
|
||||||
|
@ -58,7 +58,7 @@ int32_t TrackableObjectBase::GetIDFromWrappedClass(
|
||||||
auto* id =
|
auto* id =
|
||||||
static_cast<IDUserData*>(wrapped->GetUserData(kTrackedObjectKey));
|
static_cast<IDUserData*>(wrapped->GetUserData(kTrackedObjectKey));
|
||||||
if (id)
|
if (id)
|
||||||
return *id;
|
return int32_t(*id);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ class ShowItemHelper {
|
||||||
return *instance;
|
return *instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowItemHelper() {}
|
ShowItemHelper() = default;
|
||||||
|
|
||||||
ShowItemHelper(const ShowItemHelper&) = delete;
|
ShowItemHelper(const ShowItemHelper&) = delete;
|
||||||
ShowItemHelper& operator=(const ShowItemHelper&) = delete;
|
ShowItemHelper& operator=(const ShowItemHelper&) = delete;
|
||||||
|
|
|
@ -46,7 +46,7 @@ void GetDataListSuggestions(const blink::WebInputElement& element,
|
||||||
if (option.Value() != option.Label())
|
if (option.Value() != option.Label())
|
||||||
labels->push_back(option.Label().Utf16());
|
labels->push_back(option.Label().Utf16());
|
||||||
else
|
else
|
||||||
labels->push_back(std::u16string());
|
labels->emplace_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
TrimStringVectorForIPC(values);
|
TrimStringVectorForIPC(values);
|
||||||
|
|
Loading…
Reference in a new issue