Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang-tidy CI #282

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: '*'
57 changes: 57 additions & 0 deletions .github/workflows/clangtidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Clang-tidy

on:
push:
branches:
-master
pull_request:
branches:
- master
- development
types:
- opened
- reopened
- synchronize
- ready_for_review

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 .

6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ build/*
# clangd
.clangd

# Clang-tidy
output.txt
error.txt

# Compressed Libraries
*.zip
*.tar.gz
Expand Down Expand Up @@ -101,7 +105,7 @@ DoxygenWarningLog.txt
*.cproject
*.DS_Store
freeEnergy.txt
output.txt


# Output files
integratedFields.txt
Expand Down
8 changes: 4 additions & 4 deletions include/EquationDependencyParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ class EquationDependencyParser
/*
* Method to strip excess whitespace for the dependency lists
*/
void
static void
strip_dependency_whitespace(std::string &dependency_list);

/**
* Method to parse the RHS dependency strings and populate the vectors for
* whether values, gradients, or hessians are needed.
*/
void
static void
parseDependencyListRHS(
std::vector<std::string> &variable_name_list,
std::vector<PDEType> variable_eq_type,
Expand All @@ -76,7 +76,7 @@ class EquationDependencyParser
* Method to parse the LHS dependency strings and populate the vectors for
* whether values, gradients, or hessians are needed.
*/
void
static void
parseDependencyListLHS(
std::vector<std::string> &variable_name_list,
std::vector<PDEType> variable_eq_type,
Expand All @@ -92,7 +92,7 @@ class EquationDependencyParser
* Method to parse the postprocessing dependency strings and populate the
* vectors for whether values, gradients, or hessians are needed.
*/
void
static void
parseDependencyListPP(
std::vector<std::string> &variable_name_list,
unsigned int variable_index,
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
Loading