Skip to content

Commit

Permalink
Merge pull request #5125 from seanm/cppcheck2.16.0-part2
Browse files Browse the repository at this point in the history
  • Loading branch information
dzenanz authored Jan 9, 2025
2 parents 78f14df + 1ef2d1c commit 9ba9e28
Show file tree
Hide file tree
Showing 25 changed files with 33 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ class HistogramWriter
HistogramToImageFilterPointer m_Filter;
HistogramFileWriterPointer m_HistogramFileWriter;
// Software Guide : EndCodeSnippet
std::string m_OutputFile;
};

// Command - observer invoked after every iteration of the optimizer
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/test/itkFixedArrayTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Set_c_Array(int x[3])
}

void
Print_Array(itk::FixedArray<int, 3> x, std::ostream & os)
Print_Array(const itk::FixedArray<int, 3> & x, std::ostream & os)
{
os << '{' << x[0] << ',' << x[1] << ',' << x[2] << '}' << std::endl;
}
Expand All @@ -43,7 +43,7 @@ Print_c_ArrayConst(const int x[3], std::ostream & os)
}

void
Print_Array5(itk::FixedArray<int, 5> x, std::ostream & os)
Print_Array5(const itk::FixedArray<int, 5> & x, std::ostream & os)
{
os << '{' << x[0] << ',' << x[1] << ',' << x[2] << ',' << x[3] << ',' << x[4] << '}' << std::endl;
}
Expand Down
3 changes: 2 additions & 1 deletion Modules/Core/Common/test/itkMathRoundTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
*=========================================================================*/

#include <iostream>
#include <string_view>
#include "itkIndex.h"

bool
math_test_helper(std::string str, bool test)
math_test_helper(const std::string_view str, bool test)
{
if (!test)
{
Expand Down
3 changes: 2 additions & 1 deletion Modules/Core/Mesh/test/itkCellInterfaceTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*=========================================================================*/

#include <iostream>
#include <string_view>

#include "itkMesh.h"
#include "itkPolyLineCell.h"
Expand Down Expand Up @@ -44,7 +45,7 @@ using CellAutoPointer = CellType::CellAutoPointer;

template <typename TCell>
int
TestCellInterface(std::string name, TCell * aCell)
TestCellInterface(const std::string_view name, TCell * aCell)
{
const CellAutoPointer cell(aCell, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*=========================================================================*/

#include <iostream>
#include <string_view>

#include "itkQuadEdgeMesh.h"

Expand Down Expand Up @@ -66,7 +67,7 @@ class CustomQEPolyVisitor
// Test the cell interface
template <typename TCell>
int
TestCellInterface(std::string name, TCell * aCell)
TestCellInterface(const std::string_view name, TCell * aCell)
{

const CellAutoPointer cell(aCell, true);
Expand Down Expand Up @@ -174,7 +175,7 @@ TestCellInterface(std::string name, TCell * aCell)

template <typename TCell>
int
TestQECellInterface(std::string name, TCell * aCell)
TestQECellInterface(const std::string_view name, TCell * aCell)
{
std::cout << "-------- " << name << '(' << aCell->GetNameOfClass() << ')' << std::endl;

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/TestKernel/include/itkTestDriverInclude.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ RegressionTestImage(const char * testImageFilename,
double directionTolerance = 1.0e-6);

extern int
HashTestImage(const char * testImageFilename, const std::string md5hash);
HashTestImage(const char * testImageFilename, const std::string & md5hash);


extern std::map<std::string, int>
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Transform/test/itkEuler2DTransformTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
namespace
{
bool
CheckEqual(itk::Point<double, 2> p1, itk::Point<double, 2> p2)
CheckEqual(const itk::Point<double, 2> & p1, const itk::Point<double, 2> & p2)
{
constexpr double epsilon = 1e-5;

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Transform/test/itkRigid2DTransformTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
namespace
{
bool
CheckEqual(itk::Point<double, 2> p1, itk::Point<double, 2> p2)
CheckEqual(const itk::Point<double, 2> & p1, const itk::Point<double, 2> & p2)
{
constexpr double epsilon = 1e-10;
for (unsigned int i = 0; i < 2; ++i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace
{
bool
CheckEqual(itk::Point<double, 2> p1, itk::Point<double, 2> p2)
CheckEqual(const itk::Point<double, 2> & p1, const itk::Point<double, 2> & p2)
{
constexpr double epsilon = 1e-10;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Convert(std::string optionString)

template <typename TValue>
std::vector<TValue>
ConvertVector(std::string optionString)
ConvertVector(const std::string & optionString)
{
std::vector<TValue> values;
std::string::size_type crosspos = optionString.find('x', 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class SymmetricEigenAnalysisImageFilterHelper : public SymmetricEigenAnalysisIma
itkNewMacro(Self);

static int
Exercise(itk::EigenValueOrderEnum order, std::string outputFilename)
Exercise(itk::EigenValueOrderEnum order, const std::string & outputFilename)
{

using SymmetricEigenAnalysisImageFilterType = SymmetricEigenAnalysisImageFilter<InputImageType, InternalImageType>;
Expand Down Expand Up @@ -202,7 +202,7 @@ class SymmetricEigenAnalysisFixedDimensionImageFilterHelper
itkNewMacro(Self);

static int
Exercise(itk::EigenValueOrderEnum order, std::string outputFilename)
Exercise(itk::EigenValueOrderEnum order, const std::string & outputFilename)
{

using SymmetricEigenAnalysisFixedDimensionImageFilterType =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ static itkContourExtractor2DImageFilterTestNamespace::MyVertexListList expected_

void
ShowExtractorAsVariables(itkContourExtractor2DImageFilterTestNamespace::ExtractorType::Pointer extractor,
std::string name)
const std::string & name)
{
for (unsigned long i = 0; i < extractor->GetNumberOfIndexedOutputs(); ++i)
{
Expand Down
2 changes: 1 addition & 1 deletion Modules/IO/CSV/include/itkCSVFileReaderBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class ITKIOCSV_EXPORT CSVFileReaderBase : public LightProcessObject
*/
template <typename TData>
TData
ConvertStringToValueType(const std::string str)
ConvertStringToValueType(const std::string & str)
{
TData value;
std::istringstream isstream(str);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ SameImage(std::string testImageFileName, ImagePointer baselineImage)
}

bool
ActualTest(std::string inputFileName,
std::string outputFileNameBase,
std::string outputFileNameExtension,
ActualTest(const std::string & inputFileName,
const std::string & outputFileNameBase,
const std::string & outputFileNameExtension,
bool streamWriting,
bool pasteWriting,
bool compressWriting,
Expand Down
2 changes: 1 addition & 1 deletion Modules/IO/Meta/test/testMetaImage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

template <typename PixelType, unsigned int Dimension>
int
ReadWriteCompare(PixelType value, std::string type)
ReadWriteCompare(PixelType value, const std::string & type)
{
std::cout << "Testing: " << type << std::endl;
using ImageType = itk::Image<PixelType, 3>;
Expand Down
2 changes: 1 addition & 1 deletion Modules/IO/NRRD/test/itkNrrdImageIOTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ itkNrrdImageIOTestGenerateRandomImage(unsigned int size)

template <typename TPixelType, unsigned int VImageDimension>
int
itkNrrdImageIOTestReadWriteTest(std::string fn, unsigned int size, std::string inputFile, bool compression = false)
itkNrrdImageIOTestReadWriteTest(const std::string & fn, unsigned int size, const std::string & inputFile, bool compression = false)
{
using ImageType = itk::Image<TPixelType, VImageDimension>;

Expand Down
2 changes: 1 addition & 1 deletion Modules/IO/TIFF/test/itkTIFFImageIOTestPalette.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

template <typename T>
void
printPalette(std::vector<T> palette)
printPalette(const std::vector<T> & palette)
{
for (unsigned int i = 0; i < palette.size(); ++i)
{
Expand Down
4 changes: 2 additions & 2 deletions Modules/IO/TransformHDF5/test/itkIOTransformHDF5Test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

template <typename TParametersValueType, typename DisplacementTransformType>
static int
ReadWriteTest(const std::string fileName, const bool isRealDisplacementField, const bool useCompression)
ReadWriteTest(const std::string & fileName, const bool isRealDisplacementField, const bool useCompression)
{
// First make a DisplacementField with known values
constexpr double aNumberThatCanNotBeRepresentedInFloatingPoint = 1e-5 + 1e-7 + 1e-9 + 1e-13;
Expand Down Expand Up @@ -177,7 +177,7 @@ ReadWriteTest(const std::string fileName, const bool isRealDisplacementField, co

template <typename TParametersValueType>
static int
oneTest(const std::string goodname, const std::string badname, const bool useCompression)
oneTest(const std::string & goodname, const std::string badname, const bool useCompression)
{
using AffineTransformType = typename itk::AffineTransform<TParametersValueType, 4>;
using AffineTransformTypeNotRegistered = typename itk::AffineTransform<TParametersValueType, 10>;
Expand Down
2 changes: 1 addition & 1 deletion Modules/IO/VTK/test/itkVTKImageIO2Test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class VTKImageIOTester

template <typename TScalar>
int
Test1AsciiBinary(std::string filePrefix, std::string outputPath, std::string typeName, bool ascii, bool read = true)
Test1AsciiBinary(std::string filePrefix, std::string outputPath, const std::string & typeName, bool ascii, bool read = true)
{
std::string ab;
if (ascii)
Expand Down
2 changes: 1 addition & 1 deletion Modules/IO/VTK/test/itkVTKImageIOFileReadTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

template <class TImage>
int
ReadImage(const std::string fileName, typename TImage::Pointer image)
ReadImage(const std::string & fileName, typename TImage::Pointer image)
{

using IOType = itk::VTKImageIO;
Expand Down
2 changes: 1 addition & 1 deletion Modules/IO/XML/src/itkDOMNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ DOMNode::Find(const std::string & path)
if (pos != std::string::npos)
{
const std::string s2 = s.substr(pos + 1);
s = s.substr(0, pos);
s.resize(pos);
std::istringstream iss(s2);
IdentifierType i = 0;
iss >> i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ template <typename TMovingTransform>
int
itkAutoScaledGradientDescentRegistrationOnVectorTestTemplated(int numberOfIterations,
double shiftOfStep,
std::string scalesOption)
const std::string & scalesOption)
{
const unsigned int Dimension = TMovingTransform::SpaceDimension;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ template <typename TMovingTransform>
int
itkAutoScaledGradientDescentRegistrationTestTemplated(int numberOfIterations,
double shiftOfStep,
std::string scalesOption,
const std::string & scalesOption,
bool usePhysicalSpaceForShift,
bool estimateLearningRateOnce,
bool estimateLearningRateAtEachIteration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ template <typename TMovingTransform>
int
itkQuasiNewtonOptimizerv4TestTemplated(int numberOfIterations,
double shiftOfStep,
std::string scalesOption,
const std::string & scalesOption,
bool usePhysicalSpaceForShift = true)
{
const unsigned int Dimension = TMovingTransform::SpaceDimension;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

template <typename TPixel>
int
DoIt(int argc, char * argv[], const std::string pixelType)
DoIt(int argc, char * argv[], const std::string & pixelType)
{
if (argc < 2)
{
Expand Down

0 comments on commit 9ba9e28

Please sign in to comment.