Skip to content

Commit b6fc556

Browse files
hjmjohnsonclaude
andcommitted
STYLE: Remove redundant itk:: qualifiers at namespace scope
Add Utilities/Maintenance/fix-redundant-namespace-qualifiers.py that detects and auto-fixes itk::Symbol references inside namespace itk { } blocks where the itk:: prefix is redundant. The script is conservative to avoid false positives: - Only fixes at namespace scope (not inside class/struct bodies) - Skips sub-namespaces (namespace itk::v3, itk::detail, etc.) - Preserves itk:: on macros (itkNewMacro, itkTypeMacro, etc.) - Skips using declarations and namespace aliases - Skips strings, comments, and preprocessor directives Apply the script across the codebase, removing 26 redundant qualifiers. Usage: python fix-redundant-namespace-qualifiers.py --fix file1.cxx file2.h Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 35158b6 commit b6fc556

33 files changed

Lines changed: 381 additions & 62 deletions

File tree

Modules/Core/Common/include/itkEventObject.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,14 @@ operator<<(std::ostream & os, const EventObject & e)
142142
}; \
143143
ITK_MACROEND_NOOP_STATEMENT
144144

145-
#define itkEventMacroDefinition(classname, super) \
146-
classname::classname(const classname & s) \
147-
: super(s) \
148-
{} \
149-
classname::~classname() {} \
150-
const char * classname::GetEventName() const { return #classname; } \
151-
bool classname::CheckEvent(const itk::EventObject * e) const \
152-
{ \
153-
return dynamic_cast<const classname *>(e) != nullptr; \
154-
} \
155-
itk::EventObject * classname::MakeObject() const { return new classname; } \
145+
#define itkEventMacroDefinition(classname, super) \
146+
classname::classname(const classname & s) \
147+
: super(s) \
148+
{} \
149+
classname::~classname() {} \
150+
const char * classname::GetEventName() const { return #classname; } \
151+
bool classname::CheckEvent(const EventObject * e) const { return dynamic_cast<const classname *>(e) != nullptr; } \
152+
EventObject * classname::MakeObject() const { return new classname; } \
156153
ITK_MACROEND_NOOP_STATEMENT
157154

158155
#if !defined(ITK_LEGACY_REMOVE)

Modules/Core/Common/include/itkThreadSupport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ using ITK_THREAD_RETURN_TYPE = void *;
4848
/** @ITKEndGrouping */
4949
constexpr ITK_THREAD_RETURN_TYPE ITK_THREAD_RETURN_DEFAULT_VALUE{ nullptr };
5050
using itk::ITK_THREAD_RETURN_DEFAULT_VALUE; // We need this out of the itk namespace for #define to work below
51-
using ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION = itk::ITK_THREAD_RETURN_TYPE;
51+
using ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION = ITK_THREAD_RETURN_TYPE;
5252
#elif defined(ITK_USE_WIN32_THREADS)
5353

5454
constexpr size_t ITK_MAX_THREADS{ ITK_DEFAULT_MAX_THREADS };
@@ -76,7 +76,7 @@ constexpr ThreadProcessIdType ITK_DEFAULT_THREAD_ID{ 0 };
7676
# endif
7777
using ITK_THREAD_RETURN_TYPE = void;
7878
# define ITK_THREAD_RETURN_DEFAULT_VALUE
79-
using ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION = itk::ITK_THREAD_RETURN_TYPE;
79+
using ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION = ITK_THREAD_RETURN_TYPE;
8080
#endif
8181

8282

Modules/Core/Common/src/itkFloatingPointExceptions.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ ExceptionGlobals * FloatingPointExceptions::m_PimplGlobals;
8080

8181
/** Print enum values */
8282
std::ostream &
83-
operator<<(std::ostream & out, const itk::FloatingPointExceptionsEnums::ExceptionAction value)
83+
operator<<(std::ostream & out, const FloatingPointExceptionsEnums::ExceptionAction value)
8484
{
8585
return out << [value] {
8686
switch (value)

Modules/Core/Common/src/itkRealTimeClock.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ RealTimeClock::GetRealTimeStamp() const
126126
}
127127

128128
void
129-
RealTimeClock::PrintSelf(std::ostream & os, itk::Indent indent) const
129+
RealTimeClock::PrintSelf(std::ostream & os, Indent indent) const
130130
{
131131
Superclass::PrintSelf(os, indent);
132132

Modules/Core/GPUCommon/include/itkGPUImage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class ITK_TEMPLATE_EXPORT GPUImage : public Image<TPixel, VImageDimension>
216216
typename GPUImageDataManager<GPUImage>::Pointer m_DataManager{};
217217
};
218218

219-
class ITK_TEMPLATE_EXPORT GPUImageFactory : public itk::ObjectFactoryBase
219+
class ITK_TEMPLATE_EXPORT GPUImageFactory : public ObjectFactoryBase
220220
{
221221
public:
222222
ITK_DISALLOW_COPY_AND_MOVE(GPUImageFactory);

Modules/Core/GPUCommon/include/itkGPUImageToImageFilter.hxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ GPUImageToImageFilter<TInputImage, TOutputImage, TParentImageFilter>::GenerateDa
5959
template <typename TInputImage, typename TOutputImage, typename TParentImageFilter>
6060
void
6161
GPUImageToImageFilter<TInputImage, TOutputImage, TParentImageFilter>::GraftOutput(
62-
typename itk::GPUTraits<TOutputImage>::Type * output)
62+
typename GPUTraits<TOutputImage>::Type * output)
6363
{
6464
using GPUOutputImage = typename itk::GPUTraits<TOutputImage>::Type;
6565
typename GPUOutputImage::Pointer gpuImage = dynamic_cast<GPUOutputImage *>(this->GetOutput());
@@ -87,8 +87,8 @@ GPUImageToImageFilter<TInputImage, TOutputImage, TParentImageFilter>::GraftOutpu
8787
template <typename TInputImage, typename TOutputImage, typename TParentImageFilter>
8888
void
8989
GPUImageToImageFilter<TInputImage, TOutputImage, TParentImageFilter>::GraftOutput(
90-
const DataObjectIdentifierType & key,
91-
typename itk::GPUTraits<TOutputImage>::Type * output)
90+
const DataObjectIdentifierType & key,
91+
typename GPUTraits<TOutputImage>::Type * output)
9292
{
9393
using GPUOutputImage = typename itk::GPUTraits<TOutputImage>::Type;
9494
typename GPUOutputImage::Pointer gpuImage = dynamic_cast<GPUOutputImage *>(this->ProcessObject::GetOutput(key));

Modules/Core/GPUCommon/include/itkOpenCLUtil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void
9696
GetTypenameInString(const std::type_info & intype, std::ostringstream & ret);
9797

9898
/** Get pixel dimension (number of channels).
99-
* For high-dimensional pixel format, only itk::Vector< type, 2/3 > is acceptable. */
99+
* For high-dimensional pixel format, only Vector< type, 2/3 > is acceptable. */
100100
int
101101
GetPixelDimension(const std::type_info & intype);
102102

Modules/Core/ImageAdaptors/include/itkNthElementPixelAccessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class NthElementPixelAccessor
111111

112112

113113
template <typename TOutputPixelType, typename TPixelType>
114-
class NthElementPixelAccessor<TOutputPixelType, itk::VariableLengthVector<TPixelType>>
114+
class NthElementPixelAccessor<TOutputPixelType, VariableLengthVector<TPixelType>>
115115
: private DefaultVectorPixelAccessor<TPixelType>
116116
{
117117
public:

Modules/Core/ImageFunction/include/itkLabelImageGaussianInterpolateImageFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ namespace itk
6666
*/
6767
template <typename TInputImage,
6868
typename TCoordinate = double,
69-
typename TPixelCompare = std::less<typename itk::NumericTraits<typename TInputImage::PixelType>::RealType>>
69+
typename TPixelCompare = std::less<typename NumericTraits<typename TInputImage::PixelType>::RealType>>
7070
class ITK_TEMPLATE_EXPORT LabelImageGaussianInterpolateImageFunction
7171
: public GaussianInterpolateImageFunction<TInputImage, TCoordinate>
7272
{

Modules/Core/TestKernel/include/itkTestVerifyMetaData.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ namespace itk
2626
/* Used only to avoid duplicate code in itkMetaDictionaryGTest.cxx and itkHDF5ImageIOTest.cxx */
2727
template <typename T>
2828
int
29-
VerifyMetaDataPrivateTestingUtility(const itk::MetaDataDictionary & metaDict,
30-
const std::string & key,
31-
const T & knownValue)
29+
VerifyMetaDataPrivateTestingUtility(const MetaDataDictionary & metaDict, const std::string & key, const T & knownValue)
3230
{
3331
int status = EXIT_SUCCESS;
3432
T exposedValue{};

0 commit comments

Comments
 (0)