-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Rewards style guide
Nejc Zdovc edited this page Oct 1, 2019
·
2 revisions
❌
void FooDOMHandler::Function(const base::ListValue* args) {
std::string param1;
args->GetString(0, ¶m1);
int32 param2;
args->GetInteger(0, ¶m2);
service_->Function(param1, param2);
}
✔️
void FooDOMHandler::Function(const base::ListValue* args) {
CHECK_EQ(2U, args->GetSize());
if (rewards_service_) {
const std::string param1 = args->GetList()[0].GetString();
const int32 param2 = args->GetList()[1].GetInt();
service_->Function(param1, param2);
}
}
❌
const std::string val("10");
✔️
const std::string val = "10";
❌
void Foo(bool ok) {
std::string val = ":(";
if (ok) {
val = std::string();
}
FooSecond(val, std::string());
}
✔️
void Foo(bool ok) {
std::string val = ":(";
if (ok) {
val = "";
}
FooSecond(val, "");
}
❌
int Foo(int ok) {
return ok + 1;
}
✔️
int Foo(const int ok) {
return ok + 1;
}
❌
if (true)
return;
✔️
if (true) {
return;
}