From 2ef643132cc85728af59ce3b8effc9f890468aea Mon Sep 17 00:00:00 2001
From: Chuck Atkins <chuck.atkins@kitware.com>
Date: Mon, 3 Apr 2017 12:02:59 -0400
Subject: [PATCH] Fix misc. clang-tidy issues

---
 include/core/Method.h             |  6 ++---
 include/core/Support.h            |  2 +-
 include/core/Transform.h          |  6 ++---
 include/core/Transport.h          |  6 ++---
 include/engine/bp/BPFileReader.h  | 11 ++++-----
 include/transport/file/FStream.h  |  4 ++--
 source/core/Method.cpp            | 20 +++++++++++-----
 source/core/Support.cpp           |  9 ++++----
 source/core/Transform.cpp         | 15 ++++++------
 source/core/Transport.cpp         | 19 ++++++++++------
 source/engine/bp/BPFileReader.cpp | 38 ++++++++++++++++++-------------
 source/transport/file/FStream.cpp | 19 +++++++++++-----
 12 files changed, 89 insertions(+), 66 deletions(-)

diff --git a/include/core/Method.h b/include/core/Method.h
index 686391f96..f213022eb 100644
--- a/include/core/Method.h
+++ b/include/core/Method.h
@@ -58,9 +58,9 @@ public:
    * @param name is a label that can be used in the config file to set up the
    * method at runtime
    */
-  Method(const std::string name, const bool debugMode = false);
+  Method(std::string name, bool debugMode = false);
 
-  ~Method();
+  ~Method() = default;
 
   /** Check if the method was defined by the user in the config file.
    * @return true if the method was user-defined, false otherwise when method is
@@ -135,6 +135,6 @@ private:
                               const std::vector<std::string> &parameters);
 };
 
-} // end namespace
+} // end namespace adios
 
 #endif /* METHOD_H_ */
diff --git a/include/core/Support.h b/include/core/Support.h
index 481f8fb41..bb9b451e8 100644
--- a/include/core/Support.h
+++ b/include/core/Support.h
@@ -51,6 +51,6 @@ struct Support
   };
 };
 
-} // end namespace
+} // end namespace adios
 
 #endif /* SUPPORT_H_ */
diff --git a/include/core/Transform.h b/include/core/Transform.h
index 190541dac..a6a6dc75a 100644
--- a/include/core/Transform.h
+++ b/include/core/Transform.h
@@ -33,9 +33,9 @@ public:
    * Initialize parent method
    * @param method zlib, bzip2, szip
    */
-  Transform(const std::string method);
+  Transform(std::string method);
 
-  virtual ~Transform();
+  virtual ~Transform() = default;
 
   virtual void Compress(const std::vector<char> &bufferIn,
                         std::vector<char> &bufferOut);
@@ -44,5 +44,5 @@ public:
                           std::vector<char> &bufferOut);
 };
 
-} // end namespace
+} // end namespace adios
 #endif /* TRANSFORM_H_ */
diff --git a/include/core/Transport.h b/include/core/Transport.h
index 8b768825a..0851a9b74 100644
--- a/include/core/Transport.h
+++ b/include/core/Transport.h
@@ -44,9 +44,9 @@ public:
    * @param mpiComm passed to m_MPIComm
    * @param debugMode passed to m_DebugMode
    */
-  Transport(const std::string type, MPI_Comm mpiComm, const bool debugMode);
+  Transport(std::string type, MPI_Comm mpiComm, bool debugMode);
 
-  virtual ~Transport(); ///< empty destructor, using STL for memory management
+  virtual ~Transport() = default;
 
   /**
    * Open Output file accesing a mode
@@ -82,6 +82,6 @@ protected:
   const bool m_DebugMode = false; ///< if true: additional checks and exceptions
 };
 
-} // end namespace
+} // end namespace adios
 
 #endif /* TRANSPORT_H_ */
diff --git a/include/engine/bp/BPFileReader.h b/include/engine/bp/BPFileReader.h
index 3613ef283..4f4c45153 100644
--- a/include/engine/bp/BPFileReader.h
+++ b/include/engine/bp/BPFileReader.h
@@ -35,13 +35,12 @@ public:
    * @param debugMode
    * @param hostLanguage
    */
-  BPFileReader(ADIOS &adios, const std::string name,
-               const std::string accessMode, MPI_Comm mpiComm,
-               const Method &method, const IOMode iomode,
-               const float timeout_sec, const bool debugMode = false,
-               const unsigned int nthreads = 1);
+  BPFileReader(ADIOS &adios, std::string name, std::string accessMode,
+               MPI_Comm mpiComm, const Method &method, IOMode iomode,
+               float timeout_sec, bool debugMode = false,
+               unsigned int nthreads = 1);
 
-  ~BPFileReader();
+  virtual ~BPFileReader() = default;
 
   Variable<void> *InquireVariable(const std::string name,
                                   const bool readIn = true);
diff --git a/include/transport/file/FStream.h b/include/transport/file/FStream.h
index 163b96478..8553c3598 100644
--- a/include/transport/file/FStream.h
+++ b/include/transport/file/FStream.h
@@ -31,7 +31,7 @@ class FStream : public Transport
 public:
   FStream(MPI_Comm mpiComm, const bool debugMode);
 
-  ~FStream();
+  virtual ~FStream() = default;
 
   void Open(const std::string name, const std::string accessMode);
 
@@ -48,6 +48,6 @@ private:
 };
 
 } // end namespace transport
-} // end namespace
+} // end namespace adios
 
 #endif /* FSTREAM_H_ */
diff --git a/source/core/Method.cpp b/source/core/Method.cpp
index a97f101fc..905b04f9e 100644
--- a/source/core/Method.cpp
+++ b/source/core/Method.cpp
@@ -8,24 +8,24 @@
  *      Author: wfg
  */
 
+#include <utility>
+
 #include "core/Method.h"
 #include "functions/adiosFunctions.h"
 
 namespace adios
 {
 
-Method::Method(const std::string name, const bool debugMode)
-: m_Name{name}, m_DebugMode{debugMode}
+Method::Method(std::string name, bool debugMode)
+: m_Name{std::move(name)}, m_DebugMode{debugMode}
 {
   // m_Type can stay empty (forcing the choice of the default engine)
   m_nThreads = 1;
 }
 
-Method::~Method() {}
-
 bool Method::isUserDefined()
 {
-  return false; // TODO: check if XML has the method defined
+  return false; // TODO(wfg): check if XML has the method defined
 }
 
 void Method::SetEngine(const std::string type) { m_Type = type; }
@@ -33,9 +33,13 @@ void Method::SetEngine(const std::string type) { m_Type = type; }
 void Method::AllowThreads(const int nThreads)
 {
   if (nThreads > 1)
+  {
     m_nThreads = nThreads;
+  }
   else
+  {
     m_nThreads = 1;
+  }
 }
 
 // PRIVATE Functions
@@ -45,8 +49,10 @@ void Method::AddTransportParameters(const std::string type,
   if (m_DebugMode == true)
   {
     if (type.empty() || type.find("=") != type.npos)
+    {
       throw std::invalid_argument("ERROR: first argument in AddTransport must "
                                   "be a single word for transport\n");
+    }
   }
 
   std::map<std::string, std::string> mapParameters =
@@ -54,13 +60,15 @@ void Method::AddTransportParameters(const std::string type,
   if (m_DebugMode == true)
   {
     if (mapParameters.count("transport") == 1)
+    {
       std::invalid_argument(
           "ERROR: transport can't be redefined with \"transport=type\", "
           "type must be the first argument\n");
+    }
   }
 
   mapParameters["transport"] = type;
   m_TransportParameters.push_back(mapParameters);
 }
 
-} // end namespace
+} // end namespace adios
diff --git a/source/core/Support.cpp b/source/core/Support.cpp
index 02be66d86..65cac135a 100644
--- a/source/core/Support.cpp
+++ b/source/core/Support.cpp
@@ -19,10 +19,9 @@ const std::string Support::Version{"2.00"};
 const std::set<std::string> Support::HostLanguages{{"C++", "C", "Fortran"}};
 
 const std::set<std::string> Support::Transports{
-    {"NULL", "POSIX", "FStream",
-     "MdtmMan"} // "MPI", "MPI_LUSTRE", "MPI_AGGREGATE", "DATASPACES", "DIMES",
-                // "FLEXPATH", "PHDF5", "NC4", "ICEE" }
-};
+    {"NULL", "POSIX", "FStream", "MdtmMan"}};
+// TODO(chuckatkins): Add transports MPI, MPI_LUSTRE, MPI_AGGREGATE,
+//                    DATASPACES, DIMES, FLEXPATH, PHDF5, NC4, ICEE
 
 const std::set<std::string> Support::Transforms{
     {"none", "identity", "bzip2", "isobar", "szip", "zlib"}};
@@ -90,4 +89,4 @@ const std::map<std::string, std::set<std::string>> Support::DatatypesAliases{
 const std::set<std::string> Support::FileTransports{
     {"POSIX", "File", "FStream", "MPIFile"}};
 
-} // end namespace
+} // end namespace adios
diff --git a/source/core/Transform.cpp b/source/core/Transform.cpp
index 0b719ccc8..7549342b2 100644
--- a/source/core/Transform.cpp
+++ b/source/core/Transform.cpp
@@ -7,24 +7,23 @@
  *  Created on: Dec 5, 2016
  *      Author: wfg
  */
+#include <utility>
 
 #include "core/Transform.h"
 
 namespace adios
 {
 
-Transform::Transform(const std::string method) : m_Method(method) {}
+Transform::Transform(std::string method) : m_Method(std::move(method)) {}
 
-Transform::~Transform() {}
-
-void Transform::Compress(const std::vector<char> &bufferIn,
-                         std::vector<char> &bufferOut)
+void Transform::Compress(const std::vector<char> & /*bufferIn*/,
+                         std::vector<char> & /*bufferOut*/)
 {
 }
 
-void Transform::Decompress(const std::vector<char> &bufferIn,
-                           std::vector<char> &bufferOut)
+void Transform::Decompress(const std::vector<char> & /*bufferIn*/,
+                           std::vector<char> & /*bufferOut*/)
 {
 }
 
-} // end namespace
+} // end namespace adios
diff --git a/source/core/Transport.cpp b/source/core/Transport.cpp
index 3f3fd7728..29fbc773e 100644
--- a/source/core/Transport.cpp
+++ b/source/core/Transport.cpp
@@ -8,22 +8,21 @@
  *      Author: wfg
  */
 
+#include <utility>
+
 #include "core/Transport.h"
 
 namespace adios
 {
 
-Transport::Transport(const std::string type, MPI_Comm mpiComm,
-                     const bool debugMode)
-: m_Type{type}, m_MPIComm{mpiComm}, m_DebugMode{debugMode}
+Transport::Transport(std::string type, MPI_Comm mpiComm, bool debugMode)
+: m_Type{std::move(type)}, m_MPIComm{mpiComm}, m_DebugMode{debugMode}
 {
   MPI_Comm_rank(m_MPIComm, &m_RankMPI);
   MPI_Comm_size(m_MPIComm, &m_SizeMPI);
 }
 
-Transport::~Transport() {}
-
-void Transport::SetBuffer(char *buffer, size_t size) {}
+void Transport::SetBuffer(char * /*buffer*/, size_t /*size*/) {}
 
 void Transport::Flush() {}
 
@@ -35,13 +34,19 @@ void Transport::InitProfiler(const std::string accessMode,
   m_Profiler.m_Timers.emplace_back("open", Support::Resolutions::mus);
 
   if (accessMode == "w" || accessMode == "write")
+  {
     m_Profiler.m_Timers.emplace_back("write", resolution);
+  }
 
   else if (accessMode == "a" || accessMode == "append")
+  {
     m_Profiler.m_Timers.emplace_back("append", resolution);
+  }
 
   else if (accessMode == "r" || accessMode == "read")
+  {
     m_Profiler.m_Timers.emplace_back("read", resolution);
+  }
 
   m_Profiler.m_Timers.emplace_back("close", Support::Resolutions::mus);
 
@@ -49,4 +54,4 @@ void Transport::InitProfiler(const std::string accessMode,
   m_Profiler.m_IsActive = true;
 }
 
-} // end namespace
+} // end namespace adios
diff --git a/source/engine/bp/BPFileReader.cpp b/source/engine/bp/BPFileReader.cpp
index 406c752d3..e658e5580 100644
--- a/source/engine/bp/BPFileReader.cpp
+++ b/source/engine/bp/BPFileReader.cpp
@@ -21,24 +21,23 @@
 namespace adios
 {
 
-BPFileReader::BPFileReader(ADIOS &adios, const std::string name,
-                           const std::string accessMode, MPI_Comm mpiComm,
-                           const Method &method, const IOMode iomode,
-                           const float timeout_sec, const bool debugMode,
-                           const unsigned int nthreads)
-: Engine(adios, "BPFileReader", name, accessMode, mpiComm, method, debugMode,
-         nthreads, " BPFileReader constructor (or call to ADIOS Open).\n"),
+BPFileReader::BPFileReader(ADIOS &adios, std::string name,
+                           std::string accessMode, MPI_Comm mpiComm,
+                           const Method &method, IOMode /*iomode*/,
+                           float /*timeout_sec*/, bool debugMode,
+                           unsigned int nthreads)
+: Engine(adios, "BPFileReader", std::move(name), std::move(accessMode), mpiComm,
+         method, debugMode, nthreads,
+         " BPFileReader constructor (or call to ADIOS Open).\n"),
   m_Buffer(accessMode, m_RankMPI, m_DebugMode)
 {
   Init();
 }
 
-BPFileReader::~BPFileReader() {}
-
-Variable<void> *
-BPFileReader::InquireVariable(const std::string name,
-                              const bool readIn) // not yet implemented
+Variable<void> *BPFileReader::InquireVariable(const std::string /*name*/,
+                                              const bool /*readIn*/)
 {
+  // not yet implemented
   return nullptr;
 }
 
@@ -138,13 +137,14 @@ BPFileReader::InquireVariableCLDouble(const std::string name, const bool readIn)
   return InquireVariableCommon<std::complex<long double>>(name, readIn);
 }
 
-VariableCompound *BPFileReader::InquireVariableCompound(const std::string name,
-                                                        const bool readIn)
+VariableCompound *
+BPFileReader::InquireVariableCompound(const std::string /*name*/,
+                                      const bool /*readIn*/)
 {
   return nullptr;
 }
 
-void BPFileReader::Close(const int transportIndex) {}
+void BPFileReader::Close(const int /*transportIndex*/) {}
 
 // PRIVATE
 void BPFileReader::Init()
@@ -152,9 +152,11 @@ void BPFileReader::Init()
   if (m_DebugMode == true)
   {
     if (m_AccessMode != "r" && m_AccessMode != "read")
+    {
       throw std::invalid_argument(
           "ERROR: BPFileReader doesn't support access mode " + m_AccessMode +
           ", in call to ADIOS Open or BPFileReader constructor\n");
+    }
   }
 
   InitCapsules();
@@ -214,19 +216,23 @@ void BPFileReader::InitTransports() // maybe move this?
       else
       {
         if (m_DebugMode == true)
+        {
           throw std::invalid_argument(
               "ERROR: file transport library " + itLibrary->second +
               " not supported, in " + m_Name + m_EndMessage);
+        }
       }
     }
     else
     {
       if (m_DebugMode == true)
+      {
         throw std::invalid_argument("ERROR: transport " + itTransport->second +
                                     " (you mean File?) not supported, in " +
                                     m_Name + m_EndMessage);
+      }
     }
   }
 }
 
-} // end namespace
+} // end namespace adios
diff --git a/source/transport/file/FStream.cpp b/source/transport/file/FStream.cpp
index 15bf60b58..2a404ae6a 100644
--- a/source/transport/file/FStream.cpp
+++ b/source/transport/file/FStream.cpp
@@ -9,6 +9,7 @@
  */
 
 /// \cond EXCLUDED_FROM_DOXYGEN
+#include <ios> // std::ios_base::failure
 #include <stdexcept>
 /// \endcond
 
@@ -19,33 +20,37 @@ namespace adios
 namespace transport
 {
 
-FStream::FStream(MPI_Comm mpiComm, const bool debugMode)
+FStream::FStream(MPI_Comm mpiComm, bool debugMode)
 : Transport("fstream", mpiComm, debugMode)
 {
 }
 
-FStream::~FStream() {}
-
 void FStream::Open(const std::string name, const std::string accessMode)
 {
   m_Name = name;
   m_AccessMode = accessMode;
 
   if (accessMode == "w" || accessMode == "write")
+  {
     m_FStream.open(name, std::fstream::out);
-
+  }
   else if (accessMode == "a" || accessMode == "append")
+  {
     m_FStream.open(name, std::fstream::out | std::fstream::app);
-
+  }
   else if (accessMode == "r" || accessMode == "read")
+  {
     m_FStream.open(name, std::fstream::in);
+  }
 
   if (m_DebugMode == true)
   {
     if (!m_FStream)
+    {
       throw std::ios_base::failure(
           "ERROR: couldn't open file " + name +
           ", in call to Open from FStream transport\n");
+    }
   }
 }
 
@@ -61,8 +66,10 @@ void FStream::Write(const char *buffer, std::size_t size)
   if (m_DebugMode == true)
   {
     if (!m_FStream)
+    {
       throw std::ios_base::failure("ERROR: couldn't write to file " + m_Name +
                                    ", in call to FStream write\n");
+    }
   }
 }
 
@@ -71,4 +78,4 @@ void FStream::Flush() { m_FStream.flush(); }
 void FStream::Close() { m_FStream.close(); }
 
 } // end namespace transport
-} // end namespace
+} // end namespace adios
-- 
GitLab