You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +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:
@@ -46,8 +46,9 @@ void Array::_ref(const Array &p_from) const {
|
||||
|
||||
ERR_FAIL_COND(!_fp); // should NOT happen.
|
||||
|
||||
if (_fp == _p)
|
||||
if (_fp == _p) {
|
||||
return; // whatever it is, nothing to do here move along
|
||||
}
|
||||
|
||||
bool success = _fp->refcount.ref();
|
||||
|
||||
@@ -59,8 +60,9 @@ void Array::_ref(const Array &p_from) const {
|
||||
}
|
||||
|
||||
void Array::_unref() const {
|
||||
if (!_p)
|
||||
if (!_p) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_p->refcount.unref()) {
|
||||
memdelete(_p);
|
||||
@@ -136,8 +138,9 @@ int Array::find(const Variant &p_value, int p_from) const {
|
||||
}
|
||||
|
||||
int Array::rfind(const Variant &p_value, int p_from) const {
|
||||
if (_p->array.size() == 0)
|
||||
if (_p->array.size() == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (p_from < 0) {
|
||||
// Relative offset from the end
|
||||
@@ -162,8 +165,9 @@ int Array::find_last(const Variant &p_value) const {
|
||||
}
|
||||
|
||||
int Array::count(const Variant &p_value) const {
|
||||
if (_p->array.size() == 0)
|
||||
if (_p->array.size() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int amount = 0;
|
||||
for (int i = 0; i < _p->array.size(); i++) {
|
||||
@@ -217,14 +221,17 @@ Array Array::slice(int p_begin, int p_end, int p_step, bool p_deep) const { // l
|
||||
|
||||
ERR_FAIL_COND_V_MSG(p_step == 0, new_arr, "Array slice step size cannot be zero.");
|
||||
|
||||
if (empty()) // Don't try to slice empty arrays.
|
||||
if (empty()) { // Don't try to slice empty arrays.
|
||||
return new_arr;
|
||||
}
|
||||
if (p_step > 0) {
|
||||
if (p_begin >= size() || p_end < -size())
|
||||
if (p_begin >= size() || p_end < -size()) {
|
||||
return new_arr;
|
||||
}
|
||||
} else { // p_step < 0
|
||||
if (p_begin < -size() || p_end >= size())
|
||||
if (p_begin < -size() || p_end >= size()) {
|
||||
return new_arr;
|
||||
}
|
||||
}
|
||||
|
||||
int begin = _clamp_slice_index(p_begin);
|
||||
@@ -255,8 +262,9 @@ struct _ArrayVariantSort {
|
||||
bool valid = false;
|
||||
Variant res;
|
||||
Variant::evaluate(Variant::OP_LESS, p_l, p_r, res, valid);
|
||||
if (!valid)
|
||||
if (!valid) {
|
||||
res = false;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
@@ -274,8 +282,9 @@ struct _ArrayVariantSortCustom {
|
||||
const Variant *args[2] = { &p_l, &p_r };
|
||||
Variant::CallError err;
|
||||
bool res = obj->call(func, args, 2, err);
|
||||
if (err.error != Variant::CallError::CALL_OK)
|
||||
if (err.error != Variant::CallError::CALL_OK) {
|
||||
res = false;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
@@ -291,8 +300,9 @@ Array &Array::sort_custom(Object *p_obj, const StringName &p_function) {
|
||||
|
||||
void Array::shuffle() {
|
||||
const int n = _p->array.size();
|
||||
if (n < 2)
|
||||
if (n < 2) {
|
||||
return;
|
||||
}
|
||||
Variant *data = _p->array.ptrw();
|
||||
for (int i = n - 1; i >= 1; i--) {
|
||||
const int j = Math::rand() % (i + 1);
|
||||
|
||||
Reference in New Issue
Block a user