Skip to content

Commit

Permalink
Merge pull request #282 from landinjm/clangtidy_CI
Browse files Browse the repository at this point in the history
Clang-tidy CI
  • Loading branch information
landinjm authored Nov 25, 2024
2 parents 90165de + eb44fb2 commit 9b63518
Show file tree
Hide file tree
Showing 65 changed files with 2,149 additions and 1,724 deletions.
22 changes: 19 additions & 3 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,26 @@
Checks: >
-*,
boost-*,
bugprone-*,
-bugprone-easily-swappable-parameters,
cert-*,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-avoid-magic-numbers,
hicpp-*,
misc-*,
-misc-non-private-member-variables-in-classes,
-misc-include-cleaner,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-use-trailing-return-type,
mpi-*,
performance-*
performance-*,
readability-*,
-readability-else-after-return,
-readability-static-accessed-through-instance,
-readability-avoid-const-params-in-decls,
-readability-magic-numbers,
-readability-identifier-length,
WarningsAsErrors: '*'
WarningsAsErrors: '*'
58 changes: 58 additions & 0 deletions .github/workflows/clangtidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Clang-tidy

on:
push:
branches:
- master
pull_request:
branches:
- master
types:
- opened
- reopened
- synchronize
- ready_for_review
paths-ignore:
- 'applications/**'

concurrency:
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request'}}

jobs:
clang-tidy:
runs-on: [ubuntu-22.04]

container:
image: dealii/dealii:v9.6.0-jammy
options: --user root

steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 30

- name: Cache llvm-18 installation
uses: actions/cache@v3
with:
path: /usr/lib/llvm-18
key: ${{ runner.os }}-llvm-18
restore-keys: |
${{ runner.os }}-llvm
- name: Install llvm-18
if: steps.cache.outputs.cache-hit != 'true'
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
./llvm.sh 18 all
- name: Set up path for llvm-18
run: |
echo "/usr/lib/llvm-18/bin" >> "$GITHUB_PATH"
- name: Run clang-tidy
run: |
./utilities/clang_tidy.sh .
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ compile_commands.json
.venv/*
*.venv/

# Clang-tidy
output.txt
error.txt

# Compressed Libraries
*.zip
*.tar.gz
Expand Down
16 changes: 7 additions & 9 deletions include/FloodFiller.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <deal.II/matrix_free/fe_evaluation.h>

#ifndef vectorType
typedef dealii::LinearAlgebra::distributed::Vector<double> vectorType;
using vectorType = dealii::LinearAlgebra::distributed::Vector<double>;
#endif

/**
Expand All @@ -35,7 +35,7 @@ class GrainSet
/**
* Gets the grain index.
*/
unsigned int
[[nodiscard]] unsigned int
getGrainIndex() const
{
return grain_index;
Expand All @@ -53,7 +53,7 @@ class GrainSet
/**
* Gets the order parameter index.
*/
unsigned int
[[nodiscard]] unsigned int
getOrderParameterIndex() const
{
return order_parameter_index;
Expand Down Expand Up @@ -111,16 +111,14 @@ class FloodFiller
: quadrature(_quadrature)
, num_quad_points(_quadrature.size())
, dofs_per_cell(_fe.dofs_per_cell)
{
fe = &_fe;
};
, fe(&_fe) {};

/**
* The primary external interface. This method takes in information about the
* mesh/field and outputs a vector of GrainSet objects.
*/
void
calcGrainSets(dealii::FESystem<dim> &fe,
calcGrainSets(dealii::FESystem<dim> &finite_element,
dealii::DoFHandler<dim> &dof_handler,
vectorType *solution_field,
double threshold_lower,
Expand All @@ -135,8 +133,8 @@ class FloodFiller
*/
template <typename T>
void
recursiveFloodFill(T di,
T di_end,
recursiveFloodFill(T cell,
T cell_end,
vectorType *solution_field,
double threshold_lower,
double threshold_upper,
Expand Down
12 changes: 9 additions & 3 deletions include/IntegrationTools/datastruc/Bin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ namespace PRISMS
for (int i = 0; i < singlebin.size(); i++)
{
if (singlebin[i] == newitem)
return;
{
return;
}
}

singlebin.push_back(newitem);
Expand Down Expand Up @@ -171,8 +173,12 @@ namespace PRISMS
{
unsigned int max = 0;
for (int i = 0; i < _item.volume(); i++)
if (_item(i).size() > max)
max = _item(i).size();
{
if (_item(i).size() > max)
{
max = _item(i).size();
}
}
return max;
}

Expand Down
10 changes: 5 additions & 5 deletions include/IntegrationTools/datastruc/PNDArray.hh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace PRISMS
resize(dim);
}

PNDArray(const std::vector<int> &dim, const std::vector<OutType> &value)
[[nodiscard]] PNDArray(const std::vector<int> &dim, const std::vector<OutType> &value)
{
resize(dim);
if (_volume != value.size())
Expand All @@ -47,13 +47,13 @@ namespace PRISMS
_val = value;
}

int
[[nodiscard]] int
order() const
{
return _order;
}

int
[[nodiscard]] int
volume() const
{
return _volume;
Expand Down Expand Up @@ -96,13 +96,13 @@ namespace PRISMS
_volume = 0;
}

const std::vector<int> &
[[nodiscard]] const std::vector<int> &
dim() const
{
return _dim;
}

int
[[nodiscard]] int
dim(int i) const
{
return _dim[i];
Expand Down
6 changes: 4 additions & 2 deletions include/IntegrationTools/pfield/Coordinate.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace PRISMS
float _coord[DIM];

public:
int
[[nodiscard]] int
size() const
{
return DIM;
Expand Down Expand Up @@ -47,7 +47,9 @@ namespace PRISMS
{
outstream << coord[i];
if (i < coord.size() - 1)
outstream << " ";
{
outstream << " ";
}
}
return outstream;
}
Expand Down
8 changes: 6 additions & 2 deletions include/IntegrationTools/pfield/Mesh.hh
Original file line number Diff line number Diff line change
Expand Up @@ -732,14 +732,18 @@ namespace PRISMS
min(Coordinate &coord)
{
for (int i = 0; i < DIM; i++)
coord[i] = _min[i];
{
coord[i] = _min[i];
}
}

void
max(Coordinate &coord)
{
for (int i = 0; i < DIM; i++)
coord[i] = _max[i];
{
coord[i] = _max[i];
}
}

double
Expand Down
14 changes: 10 additions & 4 deletions include/IntegrationTools/pfield/PField.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace PRISMS
class PField : public PFuncBase<Coordinate, FieldType>
{
public:
typedef typename PFuncBase<Coordinate, FieldType>::size_type size_type;
using size_type = typename PFuncBase<Coordinate, FieldType>::size_type;

// pointer to a Mesh that lives in a Body
Mesh<Coordinate, DIM> *_mesh;
Expand Down Expand Up @@ -178,16 +178,22 @@ namespace PRISMS
PField<Coordinate, FieldType, DIM>::eval_grad(const Coordinate &coord)
{
for (int di = 0; di < DIM; di++)
(*this).grad(coord, di);
{
(*this).grad(coord, di);
}
}

template <class Coordinate, class FieldType, int DIM>
void
PField<Coordinate, FieldType, DIM>::eval_hess(const Coordinate &coord)
{
for (int di = 0; di < DIM; di++)
for (int dj = 0; dj < DIM; dj++)
(*this).hess(coord, di, dj);
{
for (int dj = 0; dj < DIM; dj++)
{
(*this).hess(coord, di, dj);
}
}
}

template <class Coordinate, class FieldType, int DIM>
Expand Down
Loading

0 comments on commit 9b63518

Please sign in to comment.