Skip to content

Commit 37ecb8b

Browse files
committed
STYLE: Prefer explicit const designation
Implements detection of local variables which could be declared as const but are not. Declaring variables as const is recommended by many coding guidelines, such as: ES.25 from the C++ Core Guidelines. cd ${BLDDIR} run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,misc-const-correctness -header-filter=.* -fix
1 parent 6746ae4 commit 37ecb8b

File tree

2,478 files changed

+14989
-14794
lines changed

Some content is hidden

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

2,478 files changed

+14989
-14794
lines changed

Examples/DataRepresentation/Image/Image2.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ main(int, char * argv[])
137137
// Software Guide : EndLatex
138138

139139
// Software Guide : BeginCodeSnippet
140-
ImageType::Pointer image = reader->GetOutput();
140+
const ImageType::Pointer image = reader->GetOutput();
141141
// Software Guide : EndCodeSnippet
142142

143143
// Software Guide : BeginLatex

Examples/DataRepresentation/Image/Image3.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ main(int, char *[])
9999
// Software Guide : EndLatex
100100

101101
// Software Guide : BeginCodeSnippet
102-
ImageType::PixelType pixelValue = image->GetPixel(pixelIndex);
102+
const ImageType::PixelType pixelValue = image->GetPixel(pixelIndex);
103103
// Software Guide : EndCodeSnippet
104104

105105
// Software Guide : BeginLatex

Examples/DataRepresentation/Image/Image4.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ main(int, char *[])
459459
LeftEyeIndexVector[1] = LeftEyeIndex[1];
460460
LeftEyeIndexVector[2] = LeftEyeIndex[2];
461461

462-
ImageType::PointType LeftEyePointByHand =
462+
const ImageType::PointType LeftEyePointByHand =
463463
ImageOrigin + ImageDirectionCosines * SpacingMatrix * LeftEyeIndexVector;
464464
// Software Guide : EndCodeSnippet
465465

Examples/DataRepresentation/Image/ImageAdaptor1.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ main(int argc, char * argv[])
162162
it.GoToBegin();
163163
while (!it.IsAtEnd())
164164
{
165-
float value = it.Get();
165+
const float value = it.Get();
166166
sum += value;
167167
++it;
168168
}

Examples/DataRepresentation/Image/RGBImage.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ main(int, char * argv[])
8888
reader->SetFileName(filename);
8989
reader->Update();
9090

91-
ImageType::Pointer image = reader->GetOutput();
91+
const ImageType::Pointer image = reader->GetOutput();
9292
const ImageType::IndexType pixelIndex = { { 25, 35, 0 } };
9393

9494
// Software Guide : BeginLatex

Examples/DataRepresentation/Image/VectorImage.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ main(int, char *[])
127127

128128
// The GetPixel method can also be used to read Vectors
129129
// pixels from the image
130-
ImageType::PixelType value = image->GetPixel(pixelIndex);
130+
const ImageType::PixelType value = image->GetPixel(pixelIndex);
131131

132132
std::cout << value << std::endl;
133133

Examples/DataRepresentation/Mesh/AutomaticMesh.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ main(int, char *[])
200200
//
201201
// Software Guide : EndLatex
202202

203-
MeshType::Pointer mesh = meshSource->GetOutput();
203+
const MeshType::Pointer mesh = meshSource->GetOutput();
204204
std::cout << mesh << std::endl;
205205

206206
// Software Guide : BeginLatex

Examples/DataRepresentation/Mesh/Mesh1.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,12 @@ main(int, char *[])
218218
// Software Guide : EndLatex
219219

220220
// Software Guide : BeginCodeSnippet
221-
PointsIterator end = mesh->GetPoints()->End();
221+
const PointsIterator end = mesh->GetPoints()->End();
222222
while (pointIterator != end)
223223
{
224-
MeshType::PointType p = pointIterator.Value(); // access the point
225-
std::cout << p << std::endl; // print the point
226-
++pointIterator; // advance to next point
224+
const MeshType::PointType p = pointIterator.Value(); // access the point
225+
std::cout << p << std::endl; // print the point
226+
++pointIterator; // advance to next point
227227
}
228228
// Software Guide : EndCodeSnippet
229229

Examples/DataRepresentation/Mesh/Mesh2.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ main(int, char *[])
294294
// Software Guide : EndLatex
295295

296296
// Software Guide : BeginCodeSnippet
297-
CellIterator cellIterator = mesh->GetCells()->Begin();
298-
CellIterator end = mesh->GetCells()->End();
297+
CellIterator cellIterator = mesh->GetCells()->Begin();
298+
const CellIterator end = mesh->GetCells()->End();
299299
// Software Guide : EndCodeSnippet
300300

301301

Examples/DataRepresentation/Mesh/Mesh3.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ main(int, char *[])
218218
// Software Guide : EndLatex
219219

220220
// Software Guide : BeginCodeSnippet
221-
CellDataIterator cellDataIterator = mesh->GetCellData()->Begin();
222-
CellDataIterator end = mesh->GetCellData()->End();
221+
CellDataIterator cellDataIterator = mesh->GetCellData()->Begin();
222+
const CellDataIterator end = mesh->GetCellData()->End();
223223
// Software Guide : EndCodeSnippet
224224

225225

@@ -238,7 +238,7 @@ main(int, char *[])
238238
// Software Guide : BeginCodeSnippet
239239
while (cellDataIterator != end)
240240
{
241-
PixelType cellValue = cellDataIterator.Value();
241+
const PixelType cellValue = cellDataIterator.Value();
242242
std::cout << cellValue << std::endl;
243243
++cellDataIterator;
244244
}

0 commit comments

Comments
 (0)