Skip to content

Commit 2bc30f2

Browse files
committed
cpplint: disallow if one-liners
1 parent 7063c59 commit 2bc30f2

22 files changed

+340
-168
lines changed

src/cares_wrap.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ typedef class ReqWrap<uv_getaddrinfo_t> GetAddrInfoReqWrap;
6464

6565

6666
static int cmp_ares_tasks(const ares_task_t* a, const ares_task_t* b) {
67-
if (a->sock < b->sock) return -1;
68-
if (a->sock > b->sock) return 1;
67+
if (a->sock < b->sock)
68+
return -1;
69+
if (a->sock > b->sock)
70+
return 1;
6971
return 0;
7072
}
7173

@@ -810,7 +812,8 @@ static void Query(const FunctionCallbackInfo<Value>& args) {
810812

811813
String::Utf8Value name(string);
812814
int err = wrap->Send(*name);
813-
if (err) delete wrap;
815+
if (err)
816+
delete wrap;
814817

815818
args.GetReturnValue().Set(err);
816819
}
@@ -974,7 +977,8 @@ static void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
974977
NULL,
975978
&hints);
976979
req_wrap->Dispatched();
977-
if (err) delete req_wrap;
980+
if (err)
981+
delete req_wrap;
978982

979983
args.GetReturnValue().Set(err);
980984
}

src/fs_event_wrap.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ void FSEventWrap::Close(const FunctionCallbackInfo<Value>& args) {
181181
FSEventWrap* wrap;
182182
NODE_UNWRAP_NO_ABORT(args.This(), FSEventWrap, wrap);
183183

184-
if (wrap == NULL || wrap->initialized_ == false) return;
184+
if (wrap == NULL || wrap->initialized_ == false)
185+
return;
185186
wrap->initialized_ = false;
186187

187188
HandleWrap::Close(args);

src/handle_wrap.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ void HandleWrap::Close(const FunctionCallbackInfo<Value>& args) {
7272
NODE_UNWRAP_NO_ABORT(args.This(), HandleWrap, wrap);
7373

7474
// guard against uninitialized handle or double close
75-
if (wrap == NULL || wrap->handle__ == NULL) return;
75+
if (wrap == NULL || wrap->handle__ == NULL)
76+
return;
7677

7778
Environment* env = wrap->env();
7879
assert(!wrap->persistent().IsEmpty());

src/node.cc

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ ArrayBufferAllocator ArrayBufferAllocator::the_singleton;
164164

165165

166166
void* ArrayBufferAllocator::Allocate(size_t length) {
167-
if (length > kMaxLength) return NULL;
167+
if (length > kMaxLength)
168+
return NULL;
168169
return new char[length];
169170
}
170171

@@ -839,7 +840,8 @@ Local<Value> WinapiErrnoException(int errorno,
839840
void SetupDomainUse(const FunctionCallbackInfo<Value>& args) {
840841
Environment* env = Environment::GetCurrent(args.GetIsolate());
841842

842-
if (env->using_domains()) return;
843+
if (env->using_domains())
844+
return;
843845
env->set_using_domains(true);
844846

845847
HandleScope scope(node_isolate);
@@ -1122,7 +1124,8 @@ Handle<Value> MakeDomainCallback(const Handle<Object> object,
11221124
enum encoding ParseEncoding(Handle<Value> encoding_v, enum encoding _default) {
11231125
HandleScope scope(node_isolate);
11241126

1125-
if (!encoding_v->IsString()) return _default;
1127+
if (!encoding_v->IsString())
1128+
return _default;
11261129

11271130
String::Utf8Value encoding(encoding_v);
11281131

@@ -1203,7 +1206,8 @@ void DisplayExceptionLine(Handle<Message> message) {
12031206
// then we want to show the original failure, not the secondary one.
12041207
static bool displayed_error = false;
12051208

1206-
if (displayed_error) return;
1209+
if (displayed_error)
1210+
return;
12071211
displayed_error = true;
12081212

12091213
uv_tty_reset_mode();
@@ -1339,7 +1343,8 @@ static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
13391343

13401344
QUEUE_FOREACH(q, &req_wrap_queue) {
13411345
ReqWrap<uv_req_t>* w = container_of(q, ReqWrap<uv_req_t>, req_wrap_queue_);
1342-
if (w->persistent().IsEmpty()) continue;
1346+
if (w->persistent().IsEmpty())
1347+
continue;
13431348
ary->Set(i++, w->object());
13441349
}
13451350

@@ -1360,10 +1365,12 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
13601365

13611366
QUEUE_FOREACH(q, &handle_wrap_queue) {
13621367
HandleWrap* w = container_of(q, HandleWrap, handle_wrap_queue_);
1363-
if (w->persistent().IsEmpty() || (w->flags_ & HandleWrap::kUnref)) continue;
1368+
if (w->persistent().IsEmpty() || (w->flags_ & HandleWrap::kUnref))
1369+
continue;
13641370
Local<Object> object = w->object();
13651371
Local<Value> owner = object->Get(owner_sym);
1366-
if (owner->IsUndefined()) owner = object;
1372+
if (owner->IsUndefined())
1373+
owner = object;
13671374
ary->Set(i++, owner);
13681375
}
13691376

@@ -1622,7 +1629,8 @@ static void GetGroups(const FunctionCallbackInfo<Value>& args) {
16221629

16231630
for (int i = 0; i < ngroups; i++) {
16241631
groups_list->Set(i, Integer::New(groups[i], node_isolate));
1625-
if (groups[i] == egid) seen_egid = true;
1632+
if (groups[i] == egid)
1633+
seen_egid = true;
16261634
}
16271635

16281636
delete[] groups;
@@ -1697,7 +1705,8 @@ static void InitGroups(const FunctionCallbackInfo<Value>& args) {
16971705
extra_group = gid_by_name(args[1]);
16981706

16991707
if (extra_group == gid_not_found) {
1700-
if (must_free) free(user);
1708+
if (must_free)
1709+
free(user);
17011710
return ThrowError("initgroups extra group not found");
17021711
}
17031712

@@ -1724,7 +1733,8 @@ void Exit(const FunctionCallbackInfo<Value>& args) {
17241733
static void Uptime(const FunctionCallbackInfo<Value>& args) {
17251734
HandleScope scope(node_isolate);
17261735
double uptime;
1727-
if (uv_uptime(&uptime)) return;
1736+
if (uv_uptime(&uptime))
1737+
return;
17281738
args.GetReturnValue().Set(uptime - prog_start_time);
17291739
}
17301740

@@ -1871,7 +1881,8 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
18711881
* look for foo_bar_module, not foo-bar_module.
18721882
*/
18731883
for (pos = symbol; *pos != '\0'; ++pos) {
1874-
if (*pos == '-') *pos = '_';
1884+
if (*pos == '-')
1885+
*pos = '_';
18751886
}
18761887

18771888
node_module_struct *mod;
@@ -2105,7 +2116,8 @@ static void EnvQuery(Local<String> property,
21052116
int32_t rc = -1; // Not found unless proven otherwise.
21062117
#ifdef __POSIX__
21072118
String::Utf8Value key(property);
2108-
if (getenv(*key)) rc = 0;
2119+
if (getenv(*key))
2120+
rc = 0;
21092121
#else // _WIN32
21102122
String::Value key(property);
21112123
WCHAR* key_ptr = reinterpret_cast<WCHAR*>(*key);
@@ -2120,7 +2132,8 @@ static void EnvQuery(Local<String> property,
21202132
}
21212133
}
21222134
#endif
2123-
if (rc != -1) info.GetReturnValue().Set(rc);
2135+
if (rc != -1)
2136+
info.GetReturnValue().Set(rc);
21242137
}
21252138

21262139

@@ -2131,7 +2144,8 @@ static void EnvDeleter(Local<String> property,
21312144
#ifdef __POSIX__
21322145
String::Utf8Value key(property);
21332146
rc = getenv(*key) != NULL;
2134-
if (rc) unsetenv(*key);
2147+
if (rc)
2148+
unsetenv(*key);
21352149
#else
21362150
String::Value key(property);
21372151
WCHAR* key_ptr = reinterpret_cast<WCHAR*>(*key);
@@ -2150,7 +2164,8 @@ static void EnvEnumerator(const PropertyCallbackInfo<Array>& info) {
21502164
HandleScope scope(node_isolate);
21512165
#ifdef __POSIX__
21522166
int size = 0;
2153-
while (environ[size]) size++;
2167+
while (environ[size])
2168+
size++;
21542169

21552170
Local<Array> env = Array::New(size);
21562171

@@ -2166,7 +2181,8 @@ static void EnvEnumerator(const PropertyCallbackInfo<Array>& info) {
21662181
}
21672182
#else // _WIN32
21682183
WCHAR* environment = GetEnvironmentStringsW();
2169-
if (environment == NULL) return; // This should not happen.
2184+
if (environment == NULL)
2185+
return; // This should not happen.
21702186
Local<Array> env = Array::New();
21712187
WCHAR* p = environment;
21722188
int i = 0;
@@ -2394,7 +2410,8 @@ void SetupProcessObject(Environment* env,
23942410
if ('0' <= c && c <= '9') {
23952411
for (j = i + 1; j < l; j++) {
23962412
c = OPENSSL_VERSION_TEXT[j];
2397-
if (c == ' ') break;
2413+
if (c == ' ')
2414+
break;
23982415
}
23992416
break;
24002417
}
@@ -2671,7 +2688,8 @@ static void ParseDebugOpt(const char* arg) {
26712688
return;
26722689

26732690
fprintf(stderr, "Bad debug option.\n");
2674-
if (p) fprintf(stderr, "Debug port must be in range 1025 to 65535.\n");
2691+
if (p)
2692+
fprintf(stderr, "Debug port must be in range 1025 to 65535.\n");
26752693

26762694
PrintHelp();
26772695
exit(12);
@@ -2929,7 +2947,8 @@ static int RegisterDebugSignalHandler() {
29292947
RegisterSignalHandler(SIGUSR1, EnableDebugSignalHandler);
29302948
// If we caught a SIGUSR1 during the bootstrap process, re-raise it
29312949
// now that the debugger infrastructure is in place.
2932-
if (caught_early_debug_signal) raise(SIGUSR1);
2950+
if (caught_early_debug_signal)
2951+
raise(SIGUSR1);
29332952
return 0;
29342953
}
29352954
#endif // __POSIX__

src/node_buffer.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,8 @@ void ReadFloatGeneric(const FunctionCallbackInfo<Value>& args) {
471471
const void* data = args.This()->GetIndexedPropertiesExternalArrayData();
472472
const char* ptr = static_cast<const char*>(data) + offset;
473473
memcpy(na.bytes, ptr, sizeof(na.bytes));
474-
if (endianness != GetEndianness()) Swizzle(na.bytes, sizeof(na.bytes));
474+
if (endianness != GetEndianness())
475+
Swizzle(na.bytes, sizeof(na.bytes));
475476

476477
args.GetReturnValue().Set(na.val);
477478
}
@@ -525,7 +526,8 @@ uint32_t WriteFloatGeneric(const FunctionCallbackInfo<Value>& args) {
525526
union NoAlias na = { val };
526527
void* data = args.This()->GetIndexedPropertiesExternalArrayData();
527528
char* ptr = static_cast<char*>(data) + offset;
528-
if (endianness != GetEndianness()) Swizzle(na.bytes, sizeof(na.bytes));
529+
if (endianness != GetEndianness())
530+
Swizzle(na.bytes, sizeof(na.bytes));
529531
memcpy(ptr, na.bytes, sizeof(na.bytes));
530532
return offset + sizeof(na.bytes);
531533
}

0 commit comments

Comments
 (0)