You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
This commit is contained in:
@@ -111,8 +111,9 @@ const char *Expression::func_name[Expression::FUNC_MAX] = {
|
||||
|
||||
Expression::BuiltinFunc Expression::find_function(const String &p_string) {
|
||||
for (int i = 0; i < FUNC_MAX; i++) {
|
||||
if (p_string == func_name[i])
|
||||
if (p_string == func_name[i]) {
|
||||
return BuiltinFunc(i);
|
||||
}
|
||||
}
|
||||
|
||||
return FUNC_MAX;
|
||||
@@ -1036,8 +1037,9 @@ Error Expression::_get_token(Token &r_token) {
|
||||
exp_beg = true;
|
||||
|
||||
} else if ((c == '-' || c == '+') && !exp_sign && !exp_beg) {
|
||||
if (c == '-')
|
||||
if (c == '-') {
|
||||
is_float = true;
|
||||
}
|
||||
exp_sign = true;
|
||||
|
||||
} else {
|
||||
@@ -1046,8 +1048,9 @@ Error Expression::_get_token(Token &r_token) {
|
||||
} break;
|
||||
}
|
||||
|
||||
if (reading == READING_DONE)
|
||||
if (reading == READING_DONE) {
|
||||
break;
|
||||
}
|
||||
num += String::chr(c);
|
||||
c = GET_CHAR();
|
||||
}
|
||||
@@ -1056,10 +1059,11 @@ Error Expression::_get_token(Token &r_token) {
|
||||
|
||||
r_token.type = TK_CONSTANT;
|
||||
|
||||
if (is_float)
|
||||
if (is_float) {
|
||||
r_token.value = num.to_double();
|
||||
else
|
||||
} else {
|
||||
r_token.value = num.to_int64();
|
||||
}
|
||||
return OK;
|
||||
|
||||
} else if ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_') {
|
||||
@@ -1196,8 +1200,9 @@ Expression::ENode *Expression::_parse_expression() {
|
||||
|
||||
Token tk;
|
||||
_get_token(tk);
|
||||
if (error_set)
|
||||
if (error_set) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
switch (tk.type) {
|
||||
case TK_CURLY_BRACKET_OPEN: {
|
||||
@@ -1213,8 +1218,9 @@ Expression::ENode *Expression::_parse_expression() {
|
||||
str_ofs = cofs; //revert
|
||||
//parse an expression
|
||||
ENode *subexpr = _parse_expression();
|
||||
if (!subexpr)
|
||||
if (!subexpr) {
|
||||
return nullptr;
|
||||
}
|
||||
dn->dict.push_back(subexpr);
|
||||
|
||||
_get_token(tk);
|
||||
@@ -1224,8 +1230,9 @@ Expression::ENode *Expression::_parse_expression() {
|
||||
}
|
||||
|
||||
subexpr = _parse_expression();
|
||||
if (!subexpr)
|
||||
if (!subexpr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
dn->dict.push_back(subexpr);
|
||||
|
||||
@@ -1256,8 +1263,9 @@ Expression::ENode *Expression::_parse_expression() {
|
||||
str_ofs = cofs; //revert
|
||||
//parse an expression
|
||||
ENode *subexpr = _parse_expression();
|
||||
if (!subexpr)
|
||||
if (!subexpr) {
|
||||
return nullptr;
|
||||
}
|
||||
an->array.push_back(subexpr);
|
||||
|
||||
cofs = str_ofs;
|
||||
@@ -1276,8 +1284,9 @@ Expression::ENode *Expression::_parse_expression() {
|
||||
case TK_PARENTHESIS_OPEN: {
|
||||
//a suexpression
|
||||
ENode *e = _parse_expression();
|
||||
if (error_set)
|
||||
if (error_set) {
|
||||
return nullptr;
|
||||
}
|
||||
_get_token(tk);
|
||||
if (tk.type != TK_PARENTHESIS_CLOSE) {
|
||||
_set_error("Expected ')'");
|
||||
@@ -1308,8 +1317,9 @@ Expression::ENode *Expression::_parse_expression() {
|
||||
str_ofs = cofs2; //revert
|
||||
//parse an expression
|
||||
ENode *subexpr = _parse_expression();
|
||||
if (!subexpr)
|
||||
if (!subexpr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
func_call->arguments.push_back(subexpr);
|
||||
|
||||
@@ -1386,8 +1396,9 @@ Expression::ENode *Expression::_parse_expression() {
|
||||
str_ofs = cofs; //revert
|
||||
//parse an expression
|
||||
ENode *subexpr = _parse_expression();
|
||||
if (!subexpr)
|
||||
if (!subexpr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
constructor->arguments.push_back(subexpr);
|
||||
|
||||
@@ -1426,8 +1437,9 @@ Expression::ENode *Expression::_parse_expression() {
|
||||
str_ofs = cofs; //revert
|
||||
//parse an expression
|
||||
ENode *subexpr = _parse_expression();
|
||||
if (!subexpr)
|
||||
if (!subexpr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bifunc->arguments.push_back(subexpr);
|
||||
|
||||
@@ -1476,8 +1488,9 @@ Expression::ENode *Expression::_parse_expression() {
|
||||
while (true) {
|
||||
int cofs2 = str_ofs;
|
||||
_get_token(tk);
|
||||
if (error_set)
|
||||
if (error_set) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool done = false;
|
||||
|
||||
@@ -1489,8 +1502,9 @@ Expression::ENode *Expression::_parse_expression() {
|
||||
index->base = expr;
|
||||
|
||||
ENode *what = _parse_expression();
|
||||
if (!what)
|
||||
if (!what) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
index->index = what;
|
||||
|
||||
@@ -1529,8 +1543,9 @@ Expression::ENode *Expression::_parse_expression() {
|
||||
str_ofs = cofs3; //revert
|
||||
//parse an expression
|
||||
ENode *subexpr = _parse_expression();
|
||||
if (!subexpr)
|
||||
if (!subexpr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
func_call->arguments.push_back(subexpr);
|
||||
|
||||
@@ -1563,8 +1578,9 @@ Expression::ENode *Expression::_parse_expression() {
|
||||
} break;
|
||||
}
|
||||
|
||||
if (done)
|
||||
if (done) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//push expression
|
||||
@@ -1579,8 +1595,9 @@ Expression::ENode *Expression::_parse_expression() {
|
||||
|
||||
int cofs = str_ofs;
|
||||
_get_token(tk);
|
||||
if (error_set)
|
||||
if (error_set) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Variant::Operator op = Variant::OP_MAX;
|
||||
|
||||
@@ -1843,8 +1860,9 @@ Expression::ENode *Expression::_parse_expression() {
|
||||
}
|
||||
|
||||
bool Expression::_compile_expression() {
|
||||
if (!expression_dirty)
|
||||
if (!expression_dirty) {
|
||||
return error_set;
|
||||
}
|
||||
|
||||
if (nodes) {
|
||||
memdelete(nodes);
|
||||
@@ -1898,15 +1916,17 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
|
||||
|
||||
Variant a;
|
||||
bool ret = _execute(p_inputs, p_instance, op->nodes[0], a, r_error_str);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Variant b;
|
||||
|
||||
if (op->nodes[1]) {
|
||||
ret = _execute(p_inputs, p_instance, op->nodes[1], b, r_error_str);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool valid = true;
|
||||
@@ -1922,14 +1942,16 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
|
||||
|
||||
Variant base;
|
||||
bool ret = _execute(p_inputs, p_instance, index->base, base, r_error_str);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Variant idx;
|
||||
|
||||
ret = _execute(p_inputs, p_instance, index->index, idx, r_error_str);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool valid;
|
||||
r_ret = base.get(idx, &valid);
|
||||
@@ -1944,8 +1966,9 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
|
||||
|
||||
Variant base;
|
||||
bool ret = _execute(p_inputs, p_instance, index->base, base, r_error_str);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool valid;
|
||||
r_ret = base.get_named(index->name, &valid);
|
||||
@@ -1964,8 +1987,9 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
|
||||
Variant value;
|
||||
bool ret = _execute(p_inputs, p_instance, array->array[i], value, r_error_str);
|
||||
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
arr[i] = value;
|
||||
}
|
||||
|
||||
@@ -1980,13 +2004,15 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
|
||||
Variant key;
|
||||
bool ret = _execute(p_inputs, p_instance, dictionary->dict[i + 0], key, r_error_str);
|
||||
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Variant value;
|
||||
ret = _execute(p_inputs, p_instance, dictionary->dict[i + 1], value, r_error_str);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
|
||||
d[key] = value;
|
||||
}
|
||||
@@ -2005,8 +2031,9 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
|
||||
Variant value;
|
||||
bool ret = _execute(p_inputs, p_instance, constructor->arguments[i], value, r_error_str);
|
||||
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
arr.write[i] = value;
|
||||
argp.write[i] = &arr[i];
|
||||
}
|
||||
@@ -2031,8 +2058,9 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
|
||||
for (int i = 0; i < bifunc->arguments.size(); i++) {
|
||||
Variant value;
|
||||
bool ret = _execute(p_inputs, p_instance, bifunc->arguments[i], value, r_error_str);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
arr.write[i] = value;
|
||||
argp.write[i] = &arr[i];
|
||||
}
|
||||
@@ -2052,8 +2080,9 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
|
||||
Variant base;
|
||||
bool ret = _execute(p_inputs, p_instance, call->base, base, r_error_str);
|
||||
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector<Variant> arr;
|
||||
Vector<const Variant *> argp;
|
||||
@@ -2064,8 +2093,9 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
|
||||
Variant value;
|
||||
ret = _execute(p_inputs, p_instance, call->arguments[i], value, r_error_str);
|
||||
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
arr.write[i] = value;
|
||||
argp.write[i] = &arr[i];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user