(sheldon): crash when trying to reformat a header not in an include/ folder
Summary
When trying to apply sheldon -f
to a file whose full path does not contain an include/
folder, it crashes. For instance on the file XXXX\Utilities\breathing\bulletVolumeMeshConverter\src\helpers\helpers.hpp
:
************************************************************************************************************************
* [Sheldon] Files to process :
* [Sheldon] - Bundles/io/ioCsv/src/ioCsv/SCsvWriter.cpp
* [Sheldon] - Bundles/io/ioCsv/src/ioCsv/SPipeLoader.cpp
* [Sheldon] - Bundles/op/opPostureRegistration/CMakeLists.txt
* [Sheldon] - Bundles/op/opTensorflow/CMakeLists.txt
* [Sheldon] - Bundles/ui/uiBiopsy/src/uiBiopsy/io/SBiopsyWriter.cpp
* [Sheldon] - Bundles/video/videoLive/CMakeLists.txt
* [Sheldon] - SrcLib/odilServer/src/odilServer/OdilSCP.cpp
* [Sheldon] - SrcLib/registration/cArmRegistration3D/src/cArmRegistration3D/Debug.cpp
* [Sheldon] - Utilities/breathing/bulletVolumeMeshConverter/src/helpers/helpers.hpp
* [Sheldon] - Utilities/extractFromActivitySeries/CMakeLists.txt
* [Sheldon] - Utilities/trakSTARServer/CMakeLists.txt
* [Sheldon]
* [Sheldon] Enabled hooks: crlf, tab, filesize, oslmlog, digraphs, codingstyle, doxygen, badwords, check_xml, check_commit, check_xml_dependencies, check_glsl_version, glslang_validator, lgpl
************************************************************************************************************************
* [Sheldon] Beautifier phase :
* [Sheldon] Using uncrustify: C:\Dev\tools\uncrustify-sheldon-1.0-win32\uncrustify.exe
* [Warning] Failed to parse includes in file C:/Dev/sight/src/XXXX\SrcLib/registration/cArmRegistration3D/src/cArmRegistration3D/Debug.cpp, includes sort is skipped. Maybe there is a #ifdef ? This may be handled in a future version.
*
* [Warning] Failed to parse includes in file C:/Dev/sight/src/XXXX\Utilities/breathing/bulletVolumeMeshConverter/src/helpers/helpers.hpp, includes sort is skipped. Maybe there is a #ifdef ? This may be handled in a future version.
*
Traceback (most recent call last):
File "C:\Dev\tools\sight-git\hooks\sheldon", line 205, in <module>
check_commits_date)
File "C:\Dev\tools\sight-git\hooks\codingstyle.py", line 176, in codingstyle
sort_includes, f.status, check_commits_date)
File "C:\Dev\tools\sight-git\hooks\codingstyle.py", line 218, in format_file
ret.add(fix_header_guard(source_file, enable_reformat))
File "C:\Dev\tools\sight-git\hooks\codingstyle.py", line 494, in fix_header_guard
if len(re.findall("HXX", expected_guard[1], re.DOTALL)) != 0:
IndexError: list index out of range
Steps to reproduce
- Run
sheldon -f
onsight-XXXXX\Utilities\breathing\bulletVolumeMeshConverter\src\helpers\helpers.hpp
Dev environment
- OS: Windows
- Commit: dev
Edited by Flavien BRIDAULT