Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: add clang-tidy rule in src #26840

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 28 additions & 0 deletions src/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
Checks: '-*,
# modernize-use-auto,
gengjiawen marked this conversation as resolved.
Show resolved Hide resolved
# modernize-use-equals-delete,
modernize-deprecated-headers,
modernize-make-unique,
modernize-make-shared,
modernize-redundant-void-arg,
modernize-replace-random-shuffle,
modernize-shrink-to-fit,
modernize-use-bool-literals,
modernize-use-emplace,
modernize-use-equals-default,
modernize-use-nullptr,
modernize-use-override,
performance-faster-string-find,
gengjiawen marked this conversation as resolved.
Show resolved Hide resolved
# performance-unnecessary-value-param, see https://github.com/nodejs/node/pull/26042
readability-delete-null-pointer, '
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
User: nodejs/cpp
CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines
gengjiawen marked this conversation as resolved.
Show resolved Hide resolved
value: 1
...

7 changes: 4 additions & 3 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ struct AllocatedBuffer {
class AsyncRequest : public MemoryRetainer {
public:
AsyncRequest() = default;
~AsyncRequest();
~AsyncRequest() override;

AsyncRequest(const AsyncRequest&) = delete;
AsyncRequest& operator=(const AsyncRequest&) = delete;
Expand Down Expand Up @@ -907,7 +907,7 @@ class Environment : public MemoryRetainer {
const std::vector<std::string>& exec_args,
Flags flags = Flags(),
uint64_t thread_id = kNoThreadId);
~Environment();
~Environment() override;

void InitializeLibuv(bool start_profiler_idle_notifier);
inline const std::vector<std::string>& exec_argv();
Expand Down Expand Up @@ -1379,7 +1379,8 @@ class Environment : public MemoryRetainer {
bool http_parser_buffer_in_use_ = false;
std::unique_ptr<http2::Http2State> http2_state_;

bool debug_enabled_[static_cast<int>(DebugCategory::CATEGORY_COUNT)] = {0};
bool debug_enabled_[static_cast<int>(DebugCategory::CATEGORY_COUNT)] = {
false};

AliasedFloat64Array fs_stats_field_array_;
AliasedBigUint64Array fs_stats_field_bigint_array_;
Expand Down
2 changes: 1 addition & 1 deletion src/fs_event_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class FSEventWrap: public HandleWrap {
static const encoding kDefaultEncoding = UTF8;

FSEventWrap(Environment* env, Local<Object> object);
~FSEventWrap() = default;
~FSEventWrap() override = default;

static void OnEvent(uv_fs_event_t* handle, const char* filename, int events,
int status);
Expand Down
2 changes: 1 addition & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv,
}

if (will_start_new_arg) {
env_argv.push_back(std::string(1, c));
env_argv.emplace_back(std::string(1, c));
will_start_new_arg = false;
} else {
env_argv.back() += c;
Expand Down
15 changes: 9 additions & 6 deletions src/node_main_instance.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <memory>

#include "node_main_instance.h"
#include "node_internals.h"
#include "node_options-inl.h"
Expand Down Expand Up @@ -34,7 +36,8 @@ NodeMainInstance::NodeMainInstance(Isolate* isolate,
isolate_data_(nullptr),
owns_isolate_(false),
deserialize_mode_(false) {
isolate_data_.reset(new IsolateData(isolate_, event_loop, platform, nullptr));
isolate_data_ =
std::make_unique<IsolateData>(isolate_, event_loop, platform, nullptr);

IsolateSettings misc;
SetIsolateMiscHandlers(isolate_, misc);
Expand Down Expand Up @@ -76,11 +79,11 @@ NodeMainInstance::NodeMainInstance(
deserialize_mode_ = per_isolate_data_indexes != nullptr;
// If the indexes are not nullptr, we are not deserializing
CHECK_IMPLIES(deserialize_mode_, params->external_references != nullptr);
isolate_data_.reset(new IsolateData(isolate_,
event_loop,
platform,
array_buffer_allocator_.get(),
per_isolate_data_indexes));
isolate_data_ = std::make_unique<IsolateData>(isolate_,
event_loop,
platform,
array_buffer_allocator_.get(),
per_isolate_data_indexes);
IsolateSettings s;
SetIsolateMiscHandlers(isolate_, s);
if (!deserialize_mode_) {
Expand Down
2 changes: 1 addition & 1 deletion src/tracing/traced_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace tracing {

class TracedValue : public v8::ConvertableToTraceFormat {
public:
~TracedValue() = default;
~TracedValue() override = default;

static std::unique_ptr<TracedValue> Create();
static std::unique_ptr<TracedValue> CreateArray();
Expand Down