Skip to content

Commit a42dcbe

Browse files
gengjiawenTrott
authored andcommitted
tools: add clang-tidy rule in src
PR-URL: nodejs#26840 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent fe05818 commit a42dcbe

File tree

6 files changed

+43
-12
lines changed

6 files changed

+43
-12
lines changed

src/.clang-tidy

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
Checks: '-*,
3+
# modernize-use-auto,
4+
# modernize-use-equals-delete,
5+
modernize-deprecated-headers,
6+
modernize-make-unique,
7+
modernize-make-shared,
8+
modernize-redundant-void-arg,
9+
modernize-replace-random-shuffle,
10+
modernize-shrink-to-fit,
11+
modernize-use-bool-literals,
12+
modernize-use-emplace,
13+
modernize-use-equals-default,
14+
modernize-use-nullptr,
15+
modernize-use-override,
16+
performance-faster-string-find,
17+
# performance-unnecessary-value-param, see https://github.com/nodejs/node/pull/26042
18+
readability-delete-null-pointer, '
19+
WarningsAsErrors: ''
20+
HeaderFilterRegex: ''
21+
AnalyzeTemporaryDtors: false
22+
FormatStyle: none
23+
User: nodejs/cpp
24+
CheckOptions:
25+
- key: google-readability-braces-around-statements.ShortStatementLines
26+
value: 1
27+
...

src/env.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ struct AllocatedBuffer {
589589
class AsyncRequest : public MemoryRetainer {
590590
public:
591591
AsyncRequest() = default;
592-
~AsyncRequest();
592+
~AsyncRequest() override;
593593

594594
AsyncRequest(const AsyncRequest&) = delete;
595595
AsyncRequest& operator=(const AsyncRequest&) = delete;
@@ -907,7 +907,7 @@ class Environment : public MemoryRetainer {
907907
const std::vector<std::string>& exec_args,
908908
Flags flags = Flags(),
909909
uint64_t thread_id = kNoThreadId);
910-
~Environment();
910+
~Environment() override;
911911

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

1382-
bool debug_enabled_[static_cast<int>(DebugCategory::CATEGORY_COUNT)] = {0};
1382+
bool debug_enabled_[static_cast<int>(DebugCategory::CATEGORY_COUNT)] = {
1383+
false};
13831384

13841385
AliasedFloat64Array fs_stats_field_array_;
13851386
AliasedBigUint64Array fs_stats_field_bigint_array_;

src/fs_event_wrap.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class FSEventWrap: public HandleWrap {
6464
static const encoding kDefaultEncoding = UTF8;
6565

6666
FSEventWrap(Environment* env, Local<Object> object);
67-
~FSEventWrap() = default;
67+
~FSEventWrap() override = default;
6868

6969
static void OnEvent(uv_fs_event_t* handle, const char* filename, int events,
7070
int status);

src/node.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv,
877877
}
878878

879879
if (will_start_new_arg) {
880-
env_argv.push_back(std::string(1, c));
880+
env_argv.emplace_back(std::string(1, c));
881881
will_start_new_arg = false;
882882
} else {
883883
env_argv.back() += c;

src/node_main_instance.cc

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <memory>
2+
13
#include "node_main_instance.h"
24
#include "node_internals.h"
35
#include "node_options-inl.h"
@@ -34,7 +36,8 @@ NodeMainInstance::NodeMainInstance(Isolate* isolate,
3436
isolate_data_(nullptr),
3537
owns_isolate_(false),
3638
deserialize_mode_(false) {
37-
isolate_data_.reset(new IsolateData(isolate_, event_loop, platform, nullptr));
39+
isolate_data_ =
40+
std::make_unique<IsolateData>(isolate_, event_loop, platform, nullptr);
3841

3942
IsolateSettings misc;
4043
SetIsolateMiscHandlers(isolate_, misc);
@@ -76,11 +79,11 @@ NodeMainInstance::NodeMainInstance(
7679
deserialize_mode_ = per_isolate_data_indexes != nullptr;
7780
// If the indexes are not nullptr, we are not deserializing
7881
CHECK_IMPLIES(deserialize_mode_, params->external_references != nullptr);
79-
isolate_data_.reset(new IsolateData(isolate_,
80-
event_loop,
81-
platform,
82-
array_buffer_allocator_.get(),
83-
per_isolate_data_indexes));
82+
isolate_data_ = std::make_unique<IsolateData>(isolate_,
83+
event_loop,
84+
platform,
85+
array_buffer_allocator_.get(),
86+
per_isolate_data_indexes);
8487
IsolateSettings s;
8588
SetIsolateMiscHandlers(isolate_, s);
8689
if (!deserialize_mode_) {

src/tracing/traced_value.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace tracing {
1818

1919
class TracedValue : public v8::ConvertableToTraceFormat {
2020
public:
21-
~TracedValue() = default;
21+
~TracedValue() override = default;
2222

2323
static std::unique_ptr<TracedValue> Create();
2424
static std::unique_ptr<TracedValue> CreateArray();

0 commit comments

Comments
 (0)