Add clang-tidy checks and apply them by kursatyurt · Pull Request #1989 · su2code/SU2

@kursatyurt

Proposed Changes

clang-tidy is a well-known tool. This PR adds clang-tidy file with common checks and applies to the code base.

PR Checklist

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
  • My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.

pcarruscag

github-advanced-security[bot]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

@kursatyurt

@kursatyurt

pcarruscag

@pcarruscag

Else after return is fine but I don't like the others.
Isolate declarations is not addressing the true problem. Variables should be declared when needed and made const if possible.
We cannot use auto for the return type of operations with su2double

github-advanced-security[bot]

}

void CFEMStandardElementBase::IntegrationPointsTriangle(void) {
void CFEMStandardElementBase::IntegrationPointsTriangle() {

Check warning

Code scanning / CodeQL

Poorly documented large function

Poorly documented function: fewer than 2% comments for a function of 5388 lines.

}

void CFEMStandardElementBase::IntegrationPointsTetrahedron(void) {
void CFEMStandardElementBase::IntegrationPointsTetrahedron() {

Check warning

Code scanning / CodeQL

Poorly documented large function

Poorly documented function: fewer than 2% comments for a function of 4733 lines.


Xcoord.push_back(Airfoil_Coord[0]);
Ycoord.push_back(Airfoil_Coord[1] * factor * AirfoilScale);
Ycoord.emplace_back(Airfoil_Coord[1] * factor * AirfoilScale);

Check failure

Code scanning / CodeQL

Missing return-value check for a 'scanf'-like function

This variable is read, but may not have been written. It should be guarded by a check that the [call to scanf](1) returns at least 1.

pcarruscag

@pcarruscag

@pcarruscag

I went over the changes very quickly, if someone else wants to take a look it would be nice.

@kursatyurt

@kursatyurt

@bigfooted

@bigfooted, @tbellosta, @WallyMaier if any of you had time I would be great.

I've had a look at the changes. I do not have strong opinions about the checks that were chosen (or not chosen), but I am glad that we have this now.

bigfooted

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!