From ed42e0b614d8e905dc21ecbf509ddb1615ca2c63 Mon Sep 17 00:00:00 2001
From: Oliver Sander <oliver.sander@tu-dresden.de>
Date: Sun, 8 Jan 2023 07:40:08 +0100
Subject: [PATCH] Add CI pipeline running the codespell tool

And fix all spelling errors that codespell currently finds.
---
 .gitlab-ci.yml                      | 10 ++++++++++
 CHANGELOG.md                        |  2 +-
 cmake/modules/FindARPACK.cmake      |  6 +++---
 cmake/modules/FindARPACKPP.cmake    |  6 +++---
 doc/istl.tex                        |  2 +-
 dune/istl/bcrsmatrix.hh             |  4 ++--
 dune/istl/novlpschwarz.hh           |  4 ++--
 dune/istl/paamg/aggregates.hh       | 16 ++++++++--------
 dune/istl/paamg/test/anisotropic.hh |  2 +-
 dune/istl/paamg/test/fastamg.cc     |  4 ++--
 dune/istl/scalarproducts.hh         |  2 +-
 dune/python/istl/bvector.hh         |  6 +++---
 12 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4b7d68699..7f6736cc8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -49,6 +49,16 @@ ubuntu:18.04 clang-5-17:
     DUNECI_CMAKE_FLAGS: "-DDUNE_ENABLE_PYTHONBINDINGS=OFF"
   tags: [duneci]
 
+# Check for spelling mistakes in text
+code-spelling-check:
+  stage: .pre
+  # Avoid the global 'before_script'
+  before_script: ""
+  image: registry.dune-project.org/docker/ci/debian:11
+  tags: [duneci]
+  script:
+  - codespell
+
 reuse:
   stage: .pre
   image:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c82dc1e26..03e3c8487 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -210,4 +210,4 @@ SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
 
 - The solver infrastructure was updated to support SIMD data types (see
   current changes in `dune-common`). This allows to solve multiple systems
-  simultaniously using vectorization.
+  simultaneously using vectorization.
diff --git a/cmake/modules/FindARPACK.cmake b/cmake/modules/FindARPACK.cmake
index e50a2d094..5986749ad 100644
--- a/cmake/modules/FindARPACK.cmake
+++ b/cmake/modules/FindARPACK.cmake
@@ -71,14 +71,14 @@ if(ARPACK_FOUND)
   set(ARPACK_LIBRARIES ${ARPACK_LIBRARY})
   # log result
   file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
-    "Determing location of ARPACK succeeded:\n"
+    "Determining location of ARPACK succeeded:\n"
     "Libraries to link against: ${ARPACK_LIBRARIES}\n\n")
   set(ARPACK_DUNE_LIBRARIES ${ARPACK_LIBRARIES}
     CACHE STRING "Libraries used by DUNE when linking ARPACK programs")
 else()
-  # log errornous result
+  # log erroneous result
   file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
-    "Determing location of ARPACK failed:\n"
+    "Determining location of ARPACK failed:\n"
     "Libraries to link against: ${ARPACK_LIBRARIES}\n\n")
 endif()
 
diff --git a/cmake/modules/FindARPACKPP.cmake b/cmake/modules/FindARPACKPP.cmake
index 1b6f89602..d920d6eea 100644
--- a/cmake/modules/FindARPACKPP.cmake
+++ b/cmake/modules/FindARPACKPP.cmake
@@ -100,7 +100,7 @@ if(ARPACKPP_FOUND)
   endif(ARPACKPP_LIBRARY)
   # log result
   file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
-    "Determing location of ARPACK++ succeeded:\n"
+    "Determining location of ARPACK++ succeeded:\n"
     "Include directory: ${ARPACKPP_INCLUDE_DIRS}\n"
     "Libraries to link against: ${ARPACKPP_LIBRARIES}\n\n")
 
@@ -116,9 +116,9 @@ if(ARPACKPP_FOUND)
   set(ARPACKPP_DUNE_LIBRARIES ${ARPACKPP_LIBRARIES}
     CACHE STRING "Libraries used by DUNE when linking ARPACK++ programs")
 else()
-  # log errornous result
+  # log erroneous result
   file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
-    "Determing location of ARPACK++ failed:\n"
+    "Determining location of ARPACK++ failed:\n"
     "Include directory: ${ARPACKPP_INCLUDE_DIRS}\n"
     "Libraries to link against: ${ARPACKPP_LIBRARIES}\n\n")
 endif()
diff --git a/doc/istl.tex b/doc/istl.tex
index 8f3b9ba1f..1407455d5 100644
--- a/doc/istl.tex
+++ b/doc/istl.tex
@@ -649,7 +649,7 @@ contains the computed update to
 the current guess, i.~e. $\vec v = M^{-1} \vec
 d$ where $M$ is the approximate inverse of the operator $A$
 characterizing the preconditioner. The method \lstinline!void post(X& x)!
-should be called after all computations to give the precondtioner the
+should be called after all computations to give the preconditioner the
 chance to clean allocated resources. 
 
 See Table \ref{tab:precond} for a list of available
diff --git a/dune/istl/bcrsmatrix.hh b/dune/istl/bcrsmatrix.hh
index b84dd833e..c7943726c 100644
--- a/dune/istl/bcrsmatrix.hh
+++ b/dune/istl/bcrsmatrix.hh
@@ -408,8 +408,8 @@ namespace Dune {
      The compress() method returns a value of type Dune::CompressionStatistics, which
      you can inspect to tune the construction parameters `_avg` and `compressionBufferSize`.
 
-     Use of copy constructor, assignment operator and matrix vector arithmetics
-     are not supported until the matrix is fully built.
+     Use of copy constructor, assignment operator and matrix vector arithmetic
+     is not supported until the matrix is fully built.
 
      The following sample code constructs a \f$ 10 \times 10\f$ matrix, with an expected
      number of two entries per matrix row.  The compression buffer size is set to 0.4.
diff --git a/dune/istl/novlpschwarz.hh b/dune/istl/novlpschwarz.hh
index 1e5a2714b..a0c74f8af 100644
--- a/dune/istl/novlpschwarz.hh
+++ b/dune/istl/novlpschwarz.hh
@@ -265,8 +265,8 @@ namespace Dune {
   /**
    * @brief Nonoverlapping parallel preconditioner.
    *
-   * This is essentially a wrapper that take a sequential
-   * preconditoner. In each step the sequential preconditioner
+   * This is essentially a wrapper that takes a sequential
+   * preconditioner. In each step the sequential preconditioner
    * is applied and then all owner data points are updated on
    * all other processes.
    */
diff --git a/dune/istl/paamg/aggregates.hh b/dune/istl/paamg/aggregates.hh
index f7a855889..a71a29e18 100644
--- a/dune/istl/paamg/aggregates.hh
+++ b/dune/istl/paamg/aggregates.hh
@@ -746,7 +746,7 @@ namespace Dune
     private:
       /** @brief Prevent copying. */
       AggregatesMap(const AggregatesMap<V>&) = delete;
-      /** @brief Prevent assingment. */
+      /** @brief Prevent assignment. */
       AggregatesMap<V>& operator=(const AggregatesMap<V>&) = delete;
 
       /**
@@ -827,7 +827,7 @@ namespace Dune
       /**
        * @brief Reconstruct the aggregat from an seed node.
        *
-       * Will determine all vertices of the same agggregate
+       * Will determine all vertices of the same aggregate
        * and reference those.
        */
       void reconstruct(const Vertex& vertex);
@@ -853,7 +853,7 @@ namespace Dune
        */
       typename VertexSet::size_type size();
       /**
-       * @brief Get tne number of connections to other aggregates.
+       * @brief Get the number of connections to other aggregates.
        */
       typename VertexSet::size_type connectSize();
 
@@ -1244,7 +1244,7 @@ namespace Dune
       /**
        * @brief Counts the edges depending on the dependency.
        *
-       * If the inluence flag of the edge is set the counter is
+       * If the influence flag of the edge is set the counter is
        * increased and/or if the depends flag is set it is
        * incremented, too.
        */
@@ -1294,7 +1294,7 @@ namespace Dune
        * @brief counts the dependency between a vertex and unaggregated
        * neighbours.
        *
-       * If the inluence flag of the edge is set the counter is
+       * If the influence flag of the edge is set the counter is
        * increased and/or if the depends flag is set it is
        * incremented, too.
        *
@@ -1326,7 +1326,7 @@ namespace Dune
        * @brief Counts the number of neighbours belonging to an aggregate.
        *
        *
-       * If the inluence flag of the edge is set the counter is
+       * If the influence flag of the edge is set the counter is
        * increased and/or if the depends flag is set it is
        * incremented, too.
        *
@@ -1341,7 +1341,7 @@ namespace Dune
       int aggregateNeighbours(const Vertex& vertex, const AggregateDescriptor& aggregate, const AggregatesMap<Vertex>& aggregates) const;
 
       /**
-       * @brief Checks wether a vertex is admisible to be added to an aggregate.
+       * @brief Checks whether a vertex is admissible to be added to an aggregate.
        *
        * @param vertex The vertex whose admissibility id to be checked.
        * @param aggregate The id of the aggregate.
@@ -1457,7 +1457,7 @@ namespace Dune
         return;
       }
       real_type eji = norm_(*opposite_entry);
-      // skip positve offdiagonals if norm preserves sign of them.
+      // skip positive offdiagonals if norm preserves sign of them.
       if(!N::is_sign_preserving || (eij<0 || eji<0))
         if(eji / norm_(matrix_->operator[](edge.target())[edge.target()]) *
            eij/ diagonal_ > alpha() * maxValue_) {
diff --git a/dune/istl/paamg/test/anisotropic.hh b/dune/istl/paamg/test/anisotropic.hh
index c5cb53d2f..01883ae7a 100644
--- a/dune/istl/paamg/test/anisotropic.hh
+++ b/dune/istl/paamg/test/anisotropic.hh
@@ -56,7 +56,7 @@ void setupPattern(int N, M& mat, Dune::ParallelIndexSet<G,L,s>& indices, int ove
         iter.insert(iter.index()-1);
 
       if(i < overlapEnd-1)
-        // We have a rigt neighbour
+        // We have a right neighbour
         iter.insert(iter.index()+1);
 
       // j direction
diff --git a/dune/istl/paamg/test/fastamg.cc b/dune/istl/paamg/test/fastamg.cc
index 8431792fd..861e9f1b1 100644
--- a/dune/istl/paamg/test/fastamg.cc
+++ b/dune/istl/paamg/test/fastamg.cc
@@ -90,9 +90,9 @@ void testAMG(int N, int coarsenTarget, int ml)
 
   Dune::SeqScalarProduct<Vector> sp;
   typedef Dune::Amg::FastAMG<Operator,Vector> AMG;
-  Dune::Amg::Parameters parms;
+  Dune::Amg::Parameters params;
 
-  AMG amg(fop, criterion, parms);
+  AMG amg(fop, criterion, params);
 
   // check if recalculation of matrix hierarchy works
   amg.recalculateHierarchy();
diff --git a/dune/istl/scalarproducts.hh b/dune/istl/scalarproducts.hh
index ecbff5bc6..16682a5df 100644
--- a/dune/istl/scalarproducts.hh
+++ b/dune/istl/scalarproducts.hh
@@ -210,7 +210,7 @@ namespace Dune {
   /** @} end documentation */
 
   /**
-   * \brief Choose the approriate scalar product for a solver category.
+   * \brief Choose the appropriate scalar product for a solver category.
    *
    * \todo this helper function should be replaced by a proper factory
    *
diff --git a/dune/python/istl/bvector.hh b/dune/python/istl/bvector.hh
index 742d9583b..81184b80b 100644
--- a/dune/python/istl/bvector.hh
+++ b/dune/python/istl/bvector.hh
@@ -179,12 +179,12 @@ namespace Dune
 
 
 
-    // registserBlockVector
+    // registerBlockVector
     // --------------------
 
     //for the new bindings and arbitrary block size haven't
-    //the generator acutally takes the scope into account which is why we do nothing with it here
-    //so when doing a dune.istl blockvector it doesn't actually define any of the rest ofthe bindings
+    //the generator actually takes the scope into account which is why we do nothing with it here
+    //so when doing a dune.istl blockvector it doesn't actually define any of the rest of the bindings
     template< class BlockVector, class ... options >
     void registerBlockVector ( pybind11::handle scope, pybind11::class_<BlockVector, options ... > cls )
     {
-- 
GitLab