Skip to content

Commit 99ba09a

Browse files
authored
Merge pull request #2407 from jougs/update-ci
Update clang-format requirement and code to version 13
2 parents 2ebc3ff + b116e3e commit 99ba09a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+210
-151
lines changed

.github/workflows/nestbuildmatrix.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
sudo apt-get install libltdl-dev libreadline6-dev libncurses5-dev libgsl0-dev python3-all-dev jq pycodestyle libpcre3 libpcre3-dev libboost-all-dev
4848
sudo apt-get install openmpi-bin libopenmpi-dev libgsl0-dev tcl8.6 tcl8.6-dev tk8.6-dev
4949
sudo apt-get install libboost-filesystem-dev libboost-regex-dev libboost-wave-dev libboost-python-dev libboost-program-options-dev libboost-test-dev
50-
sudo apt-get install vera++ clang-format-9
50+
sudo apt-get install vera++
5151
sudo ldconfig
5252
g++ --version
5353
@@ -67,6 +67,7 @@ jobs:
6767
- name: "Install Python dependencies"
6868
run: |
6969
python -m pip install --upgrade pip setuptools
70+
python -m pip install clang-format==13.0
7071
python -c "import setuptools; print('package location:', setuptools.__file__)"
7172
python -m pip install --force-reinstall --upgrade scipy 'junitparser>=2' numpy pytest pytest-timeout pytest-xdist mpi4py cython matplotlib terminaltables pandoc
7273
python -c "import pytest; print('package location:', pytest.__file__)"

build_support/check_code_style.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ GIT_END_SHA=HEAD # '<master>..<HEAD>' are processed.
3030

3131
VERA=vera++ # The names of the static code analysis tools executables.
3232
CPPCHECK=cppcheck # CPPCHECK version 1.69 or later is required !
33-
CLANG_FORMAT=clang-format-9 # CLANG-FORMAT version 9 is required !
33+
CLANG_FORMAT=clang-format # CLANG-FORMAT version 13 is required !
3434
PEP8=pycodestyle
3535
PYCODESTYLE_IGNORES="E121,E123,E126,E226,E24,E704,W503,W504"
3636

@@ -113,8 +113,8 @@ Options:
113113
the NEST CI build and test environment.
114114
115115
--clang-format=exe The name of the CLANG-FORMAT executable.
116-
Default: --clang-format=clang-format-9
117-
Note: CLANG-FORMAT version 9 is required.
116+
Default: --clang-format=clang-format
117+
Note: CLANG-FORMAT version 13 is required.
118118
119119
--pep8=exe The name of the PEP8 executable.
120120
Default: --pep8=pycodestyle
@@ -268,12 +268,12 @@ if $PERFORM_CPPCHECK; then
268268
fi
269269
fi
270270

271-
# Verify the CLANG-FORMAT installation. CLANG-FORMAT version 9 is required.
271+
# Verify the CLANG-FORMAT installation. CLANG-FORMAT version 13 is required.
272272
if $PERFORM_CLANG_FORMAT; then
273273
$CLANG_FORMAT -style=file ./nest/main.cpp >/dev/null 2>&1 || error_exit "Failed to verify the CLANG-FORMAT installation. Executable: $CLANG_FORMAT"
274274
clang_format_version=`$CLANG_FORMAT --version | sed -${EXTENDED_REGEX_PARAM} 's/^.*([0-9]\.[0-9])\..*/\1/'`
275-
if [[ "x$clang_format_version" != "x9.0" ]]; then
276-
error_exit "Failed to verify the CLANG-FORMAT installation. Version 9 is required. The executable '$CLANG_FORMAT' is of version $clang_format_version."
275+
if [[ "x$clang_format_version" != "x13.0" ]]; then
276+
error_exit "Failed to verify the CLANG-FORMAT installation. Version 13.0 is required. The executable '$CLANG_FORMAT' is version $clang_format_version."
277277
fi
278278
fi
279279

build_support/ci_build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ if [ "$xNEST_BUILD_TYPE" = "STATIC_CODE_ANALYSIS" ]; then
9494
# The names of the static code analysis tools executables.
9595
VERA=vera++
9696
CPPCHECK=cppcheck
97-
CLANG_FORMAT=clang-format-9
97+
CLANG_FORMAT=clang-format
9898
PEP8=pycodestyle
9999
PYCODESTYLE_IGNORES="E121,E123,E126,E226,E24,E704,W503,W504"
100100

build_support/format_all_c_c++_files.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# With this script you can easily format all C/C++ files contained in
44
# any (sub)directory of NEST. Internally it uses clang-format to do
55
# the actual formatting. You can give a different clang-format command,
6-
# e.g. by executing `CLANG_FORMAT=clang-format-10 ./format_all_c_c++_files.sh`.
6+
# e.g. by executing `CLANG_FORMAT=clang-format-14 ./format_all_c_c++_files.sh`.
77
# By default the script starts at the current working directory ($PWD), but
88
# supply a different starting directory as the first argument to the command.
9-
CLANG_FORMAT=${CLANG_FORMAT:-clang-format-9}
9+
CLANG_FORMAT=${CLANG_FORMAT:-clang-format}
1010
CLANG_FORMAT_FILE=${CLANG_FORMAT_FILE:-.clang-format}
1111

1212
# Drop files that should not be checked
@@ -55,8 +55,8 @@ function process_dir {
5555
}
5656

5757
function help_output {
58-
echo "The $CLANG_FORMAT_FILE requires clang-format version 9 or later."
59-
echo "Use like: [CLANG_FORMAT=<clang-format-9>] ./build_support/`basename $0` [start folder, defaults to '$PWD']"
58+
echo "The $CLANG_FORMAT_FILE requires clang-format version 13 or later."
59+
echo "Use like: [CLANG_FORMAT=<clang-format>] ./build_support/`basename $0` [start folder, defaults to '$PWD']"
6060
exit 0
6161
}
6262

doc/htmldoc/developer_space/guidelines/coding_guidelines_check.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The code has to compile without warnings (in the default settings of the build
4141
infrastructure). We restrict ourselves to the C++11 standard for a larger support of
4242
compilers on various cluster systems and supercomputers.
4343

44-
We use clang-format version 9 in our CI.
44+
We use clang-format version 13 in our CI. If your `clang-format` executable is not version 13, you need to specify an executable with version 13 explicitly with the `--clang-format` option to ensure consistency with the NEST CI.
4545

4646
Furthermore, we use `Vera++ <https://bitbucket.org/verateam/vera/wiki/Home>`_, which
4747
'is a programmable tool for verification, analysis and transformation of C++
@@ -118,8 +118,8 @@ checks on all changed files as we do during the Travis CI tasks.
118118
the NEST Travis CI build and test environment.
119119
120120
--clang-format=exe The name of the CLANG-FORMAT executable.
121-
Default: --clang-format=clang-format-9
122-
Note: CLANG-FORMAT version 9 is required.
121+
Default: --clang-format=clang-format
122+
Note: CLANG-FORMAT version 13 is required.
123123
124124
--pep8=exe The name of the PEP8 executable.
125125
Default: --pep8=pep8

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ dependencies:
9191
- pip:
9292
# For testsuite
9393
- junitparser >= 2
94-
- clang-format == 9.0.0
94+
- clang-format == 13.0
9595
# For documentation
9696
- example
9797
- Image

libnestutil/block_vector.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ template < typename value_type_ >
344344
inline BlockVector< value_type_ >::~BlockVector() = default;
345345

346346
template < typename value_type_ >
347-
inline value_type_& BlockVector< value_type_ >::operator[]( const size_t pos )
347+
inline value_type_&
348+
BlockVector< value_type_ >::operator[]( const size_t pos )
348349
{
349350
// Using bitwise operations to efficiently map the index to the
350351
// right block and element.
@@ -354,7 +355,8 @@ inline value_type_& BlockVector< value_type_ >::operator[]( const size_t pos )
354355
}
355356

356357
template < typename value_type_ >
357-
inline const value_type_& BlockVector< value_type_ >::operator[]( const size_t pos ) const
358+
inline const value_type_&
359+
BlockVector< value_type_ >::operator[]( const size_t pos ) const
358360
{
359361
// Using bitwise operations to efficiently map the index to the
360362
// right block and element.
@@ -705,17 +707,17 @@ bv_iterator< value_type_, ref_, ptr_ >::operator--( int )
705707
}
706708

707709
template < typename value_type_, typename ref_, typename ptr_ >
708-
inline
709-
typename bv_iterator< value_type_, ref_, ptr_ >::reference bv_iterator< value_type_, ref_, ptr_ >::operator*() const
710+
inline typename bv_iterator< value_type_, ref_, ptr_ >::reference
711+
bv_iterator< value_type_, ref_, ptr_ >::operator*() const
710712
{
711713
// TODO: Using const_cast to remove the constness isn't the most elegant
712714
// solution. There is probably a better way to do this.
713715
return const_cast< reference >( *block_it_ );
714716
}
715717

716718
template < typename value_type_, typename ref_, typename ptr_ >
717-
inline
718-
typename bv_iterator< value_type_, ref_, ptr_ >::pointer bv_iterator< value_type_, ref_, ptr_ >::operator->() const
719+
inline typename bv_iterator< value_type_, ref_, ptr_ >::pointer
720+
bv_iterator< value_type_, ref_, ptr_ >::operator->() const
719721
{
720722
// TODO: Again, using const_cast to remove the constness isn't the most
721723
// elegant solution. There is probably a better way to do this.
@@ -752,8 +754,8 @@ bv_iterator< value_type_, ref_, ptr_ >::operator=( const iterator& other )
752754
}
753755

754756
template < typename value_type_, typename ref_, typename ptr_ >
755-
inline typename bv_iterator< value_type_, ref_, ptr_ >::reference bv_iterator< value_type_, ref_, ptr_ >::operator[](
756-
difference_type n ) const
757+
inline typename bv_iterator< value_type_, ref_, ptr_ >::reference
758+
bv_iterator< value_type_, ref_, ptr_ >::operator[]( difference_type n ) const
757759
{
758760
return *( *this + n );
759761
}

libnestutil/enum_bitfield.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ operator|( Enum lhs, Enum rhs )
8989
}
9090

9191
template < typename Enum >
92-
typename std::enable_if< EnableBitMaskOperators< Enum >::enable, Enum >::type operator&( Enum lhs, Enum rhs )
92+
typename std::enable_if< EnableBitMaskOperators< Enum >::enable, Enum >::type
93+
operator&( Enum lhs, Enum rhs )
9394
{
9495
using underlying = typename std::underlying_type< Enum >::type;
9596
return static_cast< Enum >( static_cast< underlying >( lhs ) & static_cast< underlying >( rhs ) );

libnestutil/lockptr.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,35 +231,40 @@ class lockPTR
231231
return obj->get();
232232
}
233233

234-
D* operator->() const
234+
D*
235+
operator->() const
235236
{
236237
assert( obj->get() != NULL );
237238

238239
return obj->get();
239240
}
240241

241-
D* operator->()
242+
D*
243+
operator->()
242244
{
243245
assert( obj->get() != NULL );
244246

245247
return obj->get();
246248
}
247249

248-
D& operator*()
250+
D&
251+
operator*()
249252
{
250253
assert( obj->get() != NULL );
251254

252255
return *( obj->get() );
253256
}
254257

255-
const D& operator*() const
258+
const D&
259+
operator*() const
256260
{
257261
assert( obj->get() != NULL );
258262
return *( obj->get() );
259263
}
260264

261265

262-
bool operator not() const //!< returns true if and only if obj->pointee == NULL
266+
bool
267+
operator not() const //!< returns true if and only if obj->pointee == NULL
263268
{
264269
// assert(obj != NULL);
265270

libnestutil/sort.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ template < typename T >
4949
inline size_t
5050
median3_( const BlockVector< T >& vec, const size_t i, const size_t j, const size_t k )
5151
{
52-
return ( ( vec[ i ] < vec[ j ] ) ? ( ( vec[ j ] < vec[ k ] ) ? j : ( vec[ i ] < vec[ k ] ) ? k : i )
53-
: ( ( vec[ k ] < vec[ j ] ) ? j : ( vec[ k ] < vec[ i ] ) ? k : i ) );
52+
return ( ( vec[ i ] < vec[ j ] ) ? ( ( vec[ j ] < vec[ k ] ) ? j
53+
: ( vec[ i ] < vec[ k ] ) ? k
54+
: i )
55+
: ( ( vec[ k ] < vec[ j ] ) ? j
56+
: ( vec[ k ] < vec[ i ] ) ? k
57+
: i ) );
5458
}
5559

5660
/**

0 commit comments

Comments
 (0)