Skip to content

Commit

Permalink
tools: add clang-tidy rule in src
Browse files Browse the repository at this point in the history
  • Loading branch information
gengjiawen committed Jan 8, 2020
1 parent bd6d651 commit 87828b1
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 12 deletions.
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,
# 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,
# 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
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

0 comments on commit 87828b1

Please sign in to comment.