Skip to content

Commit 0363953

Browse files
committed
Add else after return
1 parent 822b092 commit 0363953

17 files changed

Lines changed: 59 additions & 76 deletions

File tree

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Checks: '-*,modernize-avoid-bind,modernize-deprecated-headers,modernize-deprecated-ios-base-aliases,modernize-macro-to-enum,modernize-pass-by-value,modernize-raw-string-literal,modernize-redundant-void-arg,modernize-replace-auto-ptr,modernize-replace-disallow-copy-and-assign-macro,modernize-replace-random-shuffle,modernize-return-braced-init-list,modernize-shrink-to-fit,modernize-unary-static-assert,modernize-use-auto,modernize-use-bool-literals,modernize-use-default-member-init,modernize-use-emplace,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-noexcept,modernize-use-nullptr,modernize-use-override,modernize-use-transparent-functors,modernize-use-using,readability-const-return-type,readability-avoid-const-params-in-decls,readability-container-data-pointer,readability-container-size-empty,readability-delete-null-pointer,readability-duplicate-include,readability-non-const-parameter,readability-redundant-access-specifiers,readability-redundant-control-flow,readability-redundant-declaration,readability-redundant-function-ptr-dereference,readability-redundant-smartptr-get,readability-redundant-string-cstr,readability-redundant-string-init,readability-simplify-boolean-expr,readability-simplify-subscript-expr,performance-*'
1+
Checks: '-*,modernize-avoid-bind,modernize-deprecated-headers,modernize-deprecated-ios-base-aliases,modernize-macro-to-enum,modernize-pass-by-value,modernize-raw-string-literal,modernize-redundant-void-arg,modernize-replace-auto-ptr,modernize-replace-disallow-copy-and-assign-macro,modernize-replace-random-shuffle,modernize-return-braced-init-list,modernize-shrink-to-fit,modernize-unary-static-assert,modernize-use-auto,modernize-use-bool-literals,modernize-use-default-member-init,modernize-use-emplace,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-noexcept,modernize-use-nullptr,modernize-use-override,modernize-use-transparent-functors,modernize-use-using,readability-const-return-type,readability-avoid-const-params-in-decls,readability-container-data-pointer,readability-container-size-empty,readability-delete-null-pointer,readability-duplicate-include,readability-non-const-parameter,readability-redundant-access-specifiers,readability-redundant-control-flow,readability-redundant-declaration,readability-redundant-function-ptr-dereference,readability-redundant-smartptr-get,readability-redundant-string-cstr,readability-redundant-string-init,readability-simplify-boolean-expr,readability-simplify-subscript-expr,readability-else-after-return,performance-*'
22
CheckOptions:
33
- {key: modernize-use-override.AllowOverrideAndFinal, value: 'true'}
44
- {key: performance-unnecessary-copy-initialization.AllowedTypes, value: 'su2double'}

Common/src/CConfig.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7659,9 +7659,8 @@ bool CConfig::TokenizeString(string & str, string & option_name,
76597659
}
76607660
it = option_value.begin(); // go back to beginning; not efficient
76617661
continue;
7662-
} else {
7663-
it++;
7664-
}
7662+
} it++;
7663+
76657664
}
76667665
#if 0
76677666
cout << "option value(s) = ";
@@ -8842,9 +8841,8 @@ const su2double* CConfig::GetInlet_TurbVal(const string& val_marker) const {
88428841
}
88438842
if (Kind_Turb_Model == TURB_MODEL::SST) {
88448843
return TurbIntensityAndViscRatioFreeStream;
8845-
} else {
8846-
return &NuFactor_FreeStream;
8847-
}
8844+
} return &NuFactor_FreeStream;
8845+
88488846
}
88498847

88508848
su2double CConfig::GetOutlet_Pressure(const string& val_marker) const {

Common/src/fem/fem_geometry_structure.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,10 @@ bool CSortFaces::operator()(const CFaceOfElement& f0, const CFaceOfElement& f1)
134134
to their element ID's in order to increase cache performance. */
135135
if (elemIDMin0 != elemIDMin1) return elemIDMin0 < elemIDMin1;
136136
return elemIDMax0 < elemIDMax1;
137-
} else {
138-
/* One face is a local face and the other is not. Make sure that
139-
the local faces are numbered first. */
140-
return face0IsLocal;
141-
}
137+
} /* One face is a local face and the other is not. Make sure that
138+
the local faces are numbered first. */
139+
return face0IsLocal;
140+
142141
} else if (elemIDMax0 >= nVolElemTot && elemIDMax1 >= nVolElemTot) {
143142
/* Both faces are non-matching internal faces. Sort them according to
144143
their relevant element ID. The time level is not taken into account

Common/src/geometry/CGeometry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,7 @@ bool CGeometry::SegmentIntersectsLine(const su2double point0[2], const su2double
15151515

15161516
length = diff0_A * diff0_A + diff1_A * diff1_A;
15171517

1518-
return !((dist0 > length) || (dist1 > length));
1518+
return (dist0 <= length) && (dist1 <= length);
15191519
}
15201520

15211521
bool CGeometry::SegmentIntersectsTriangle(su2double point0[3], const su2double point1[3], su2double vert0[3],

Common/src/geometry/meshreader/CCGNSMeshReaderFVM.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,8 @@ void CCGNSMeshReaderFVM::ReadCGNSVolumeSection(int val_section) {
754754

755755
/*--- Free temporary memory from communications ---*/
756756

757-
if (connSendReq != nullptr) delete[] connSendReq;
758-
if (connRecvReq != nullptr) delete[] connRecvReq;
757+
delete[] connSendReq;
758+
delete[] connRecvReq;
759759

760760
delete[] connSend;
761761
delete[] connRecv;

Common/src/grid_movement/CBezierBlending.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,14 @@ su2double CBezierBlending::GetBernsteinDerivative(short val_n, short val_i, su2d
8888
if (val_i == 0) {
8989
value = val_n * (-GetBernsteinDerivative(val_n - 1, val_i, val_t, val_order_der - 1));
9090
return value;
91+
}
92+
if (val_n == 0) {
93+
value = val_t;
94+
return value;
9195
} else {
92-
if (val_n == 0) {
93-
value = val_t;
94-
return value;
95-
} else {
96-
value = val_n * (GetBernsteinDerivative(val_n - 1, val_i - 1, val_t, val_order_der - 1) -
97-
GetBernsteinDerivative(val_n - 1, val_i, val_t, val_order_der - 1));
98-
return value;
99-
}
96+
value = val_n * (GetBernsteinDerivative(val_n - 1, val_i - 1, val_t, val_order_der - 1) -
97+
GetBernsteinDerivative(val_n - 1, val_i, val_t, val_order_der - 1));
98+
return value;
10099
}
101100

102101
return value;

SU2_CFD/src/drivers/CDriver.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,8 +2821,7 @@ void CDriver::PrintDirectResidual(RECORDING kind_recording) {
28212821
auto iVar_iZone2string = [&](unsigned short ivar, unsigned short izone) {
28222822
if (multizone)
28232823
return "[" + std::to_string(ivar) + "][" + std::to_string(izone) + "]";
2824-
else
2825-
return "[" + std::to_string(ivar) + "]";
2824+
return "[" + std::to_string(ivar) + "]";
28262825
};
28272826

28282827
/*--- Print residuals in the first iteration ---*/

SU2_CFD/src/drivers/CMultizoneDriver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ bool CMultizoneDriver::Monitor(unsigned long TimeIter){
620620

621621
return (MaxIterationsReached || InnerConvergence);
622622
}
623-
else { // i.e. unsteady simulation
623+
// i.e. unsteady simulation
624624

625625
/*--- Check whether the outer time integration has reached the final time ---*/
626626
const auto TimeConvergence = GetTimeConvergence();
@@ -641,7 +641,7 @@ bool CMultizoneDriver::Monitor(unsigned long TimeIter){
641641
}
642642

643643
return (FinalTimeReached || MaxIterationsReached);
644-
}
644+
645645

646646
}
647647

SU2_CFD/src/fluid/CSU2TCLib.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,7 +1581,7 @@ void CSU2TCLib::ComputeKeqConstants(unsigned short val_Reaction) {
15811581
for (ii = 0; ii < 5; ii++)
15821582
A[ii] = RxnConstantTable(0,ii);
15831583
return;
1584-
} else if (iIndex >= 5) {
1584+
} if (iIndex >= 5) {
15851585
for (ii = 0; ii < 5; ii++)
15861586
A[ii] = RxnConstantTable(5,ii);
15871587
return;
@@ -1902,7 +1902,7 @@ su2double CSU2TCLib::ComputeCollisionCrossSection(unsigned iSpecies, unsigned jS
19021902

19031903
if (Omega11(iSpecies, jSpecies, 0) == 1.0 && d1) {
19041904
return 1E-20 * 5E15 * pi * pow((debyeLength / T), 2) * log(D1_a*T_star*(1 - C1_a * exp(-c1_a * T_star))+1);
1905-
} else if (Omega11(iSpecies, jSpecies, 0) == -1.0 && d1) {
1905+
} if (Omega11(iSpecies, jSpecies, 0) == -1.0 && d1) {
19061906
return 1E-20 * 5E15 * pi * pow((debyeLength / T), 2) * log(D1_r*T_star*(1 - C1_r * exp(-c1_r * T_star))+1);
19071907
} else if (Omega22(iSpecies, jSpecies, 0) == 1.0 && !d1) {
19081908
return 1E-20 * 5E15 * pi * pow((debyeLength / T), 2) * log(D2_a*T_star*(1 - C2_a * exp(-c2_a * T_star))+1);
@@ -1913,9 +1913,8 @@ su2double CSU2TCLib::ComputeCollisionCrossSection(unsigned iSpecies, unsigned jS
19131913
} else {
19141914
if (d1) {
19151915
return 1E-20 * Omega11(iSpecies,jSpecies,3) * pow(T, Omega11(iSpecies,jSpecies,0)*log(T)*log(T) + Omega11(iSpecies,jSpecies,1)*log(T) + Omega11(iSpecies,jSpecies,2));
1916-
} else {
1917-
return 1E-20 * Omega22(iSpecies,jSpecies,3) * pow(T, Omega22(iSpecies,jSpecies,0)*log(T)*log(T) + Omega22(iSpecies,jSpecies,1)*log(T) + Omega22(iSpecies,jSpecies,2));
1918-
}
1916+
} return 1E-20 * Omega22(iSpecies,jSpecies,3) * pow(T, Omega22(iSpecies,jSpecies,0)*log(T)*log(T) + Omega22(iSpecies,jSpecies,1)*log(T) + Omega22(iSpecies,jSpecies,2));
1917+
19191918
}
19201919
}
19211920

@@ -2169,9 +2168,8 @@ vector<su2double>& CSU2TCLib::ComputeTemperatures(vector<su2double>& val_rhos, s
21692168
NRconvg = true;
21702169
Tve = Tve2;
21712170
break;
2172-
} else {
2173-
Tve = Tve2;
2174-
}
2171+
} Tve = Tve2;
2172+
21752173
}
21762174

21772175
// If the Newton-Raphson method has converged, assign the value of Tve.
@@ -2186,10 +2184,9 @@ vector<su2double>& CSU2TCLib::ComputeTemperatures(vector<su2double>& val_rhos, s
21862184
if (fabs(rhoEve_t - rhoEve) < Btol) {
21872185
Bconvg = true;
21882186
break;
2189-
} else {
2190-
if (rhoEve_t > rhoEve) Tve2 = Tve;
2187+
} if (rhoEve_t > rhoEve) Tve2 = Tve;
21912188
else Tve_o = Tve;
2192-
}
2189+
21932190
}
21942191
}
21952192

SU2_CFD/src/interfaces/CInterface.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,10 @@ void CInterface::PreprocessAverage(CGeometry *donor_geometry, CGeometry *target_
227227
/*--- Exit the for loop: we have found the local index for Mixing-Plane interface ---*/
228228
break;
229229
}
230-
else {
231-
/*--- If the tag hasn't matched any tag within the donor markers ---*/
230+
/*--- If the tag hasn't matched any tag within the donor markers ---*/
232231
Marker_Donor = -1;
233232
Donor_Flag = -1;
234-
}
233+
235234
}
236235

237236
#ifdef HAVE_MPI
@@ -273,10 +272,9 @@ void CInterface::PreprocessAverage(CGeometry *donor_geometry, CGeometry *target_
273272
/*--- Exit the for loop: we have found the local index for iMarkerFSI on the FEA side ---*/
274273
break;
275274
}
276-
else {
277-
/*--- If the tag hasn't matched any tag within the Flow markers ---*/
275+
/*--- If the tag hasn't matched any tag within the Flow markers ---*/
278276
Marker_Target = -1;
279-
}
277+
280278
}
281279

282280
if (Marker_Target != -1 && Marker_Donor != -1){
@@ -418,10 +416,9 @@ void CInterface::AllgatherAverage(CSolver *donor_solution, CSolver *target_solut
418416
/*--- Exit the for loop: we have found the local index for Mixing-Plane interface ---*/
419417
break;
420418
}
421-
else {
422-
/*--- If the tag hasn't matched any tag within the donor markers ---*/
419+
/*--- If the tag hasn't matched any tag within the donor markers ---*/
423420
Marker_Donor = -1;
424-
}
421+
425422
}
426423
/*--- Here we want to make available the quantities for all the processors and collect them in a buffer
427424
* for each span of the donor the span-wise height vector also so
@@ -534,10 +531,9 @@ void CInterface::AllgatherAverage(CSolver *donor_solution, CSolver *target_solut
534531
/*--- Exit the for loop: we have found the local index for iMarkerFSI on the FEA side ---*/
535532
break;
536533
}
537-
else {
538-
/*--- If the tag hasn't matched any tag within the Flow markers ---*/
534+
/*--- If the tag hasn't matched any tag within the Flow markers ---*/
539535
Marker_Target = -1;
540-
}
536+
541537
}
542538

543539

0 commit comments

Comments
 (0)