# help with bogus "pre-commit hook failure"

**URL:** <https://discourse.itk.org/t/help-with-bogus-pre-commit-hook-failure/2350>\
**Category:** Engineering\
**Created:** [October 25, 2019, 7:53pm UTC](https://discourse.itk.org/t/help-with-bogus-pre-commit-hook-failure/2350 "2019-10-25T19:53:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)\
**Post date:** [October 25, 2019, 7:53pm UTC](https://discourse.itk.org/t/help-with-bogus-pre-commit-hook-failure/2350/1 "2019-10-25T19:53:19Z")

</div>

Hi all,

I’m trying to submit a simple one line patch, but committing gives me:

```auto
[attr]our-c-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=KWStyle,clangformat
 not allowed: ./.gitattributes:31
[attr]our-c-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=KWStyle,clangformat
 not allowed: ./.gitattributes:31
Modules/Core/ImageFunction/test/itkSumOfSquaresImageFunctionGTest.cxx:47: error: Unnecessary semicolon
Modules/Core/ImageFunction/test/itkSumOfSquaresImageFunctionGTest.cxx:130: error: Unnecessary semicolon
pre-commit hook failure
```

---

<div class="post-metadata">

**Author:** ![jhlegarreta](https://discourse.itk.org/user_avatar/discourse.itk.org/jhlegarreta/32/476_2.png) [@jhlegarreta](https://discourse.itk.org/u/jhlegarreta)\
**Post date:** [October 25, 2019, 8:08pm UTC](https://discourse.itk.org/t/help-with-bogus-pre-commit-hook-failure/2350/2 "2019-10-25T20:08:34Z")

</div>

Hi @seanm,  
although I have not contributed since it was put in place, a new pre-commit hook that checks the style was [put in place recently](https://discourse.itk.org/t/update-coding-style-for-itk/2055).

May be you will need to configure the tool so that it automatically enforces the adopted style.

---

<div class="post-metadata">

**Author:** ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)\
**Post date:** [October 25, 2019, 8:08pm UTC](https://discourse.itk.org/t/help-with-bogus-pre-commit-hook-failure/2350/3 "2019-10-25T20:08:31Z")

</div>

Strange, it seems to have chopped off half my message. The second half was:

```auto
KWStyle check failed.

Line numbers in the errors shown refer to the file:
Modules/Core/ImageFunction/test/itkSumOfSquaresImageFunctionGTest.cxx.kws

```

If I remove the “unnecessary” semi-colon at line 47 compilation fails.

How do I bypass this?

Thanks,

Sean

---

<div class="post-metadata">

**Author:** ![jhlegarreta](https://discourse.itk.org/user_avatar/discourse.itk.org/jhlegarreta/32/476_2.png) [@jhlegarreta](https://discourse.itk.org/u/jhlegarreta)\
**Post date:** [October 25, 2019, 8:18pm UTC](https://discourse.itk.org/t/help-with-bogus-pre-commit-hook-failure/2350/4 "2019-10-25T20:18:24Z")

</div>

May be the style format document needs to be revisited/does not handle properly this use case?

---

<div class="post-metadata">

**Author:** ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)\
**Post date:** [October 25, 2019, 8:21pm UTC](https://discourse.itk.org/t/help-with-bogus-pre-commit-hook-failure/2350/5 "2019-10-25T20:21:07Z")

</div>

> [@seanm](#):
>
> How do I bypass this?

You should modify this file:

> <https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/ImageFunction/ITKKWStyleOverwrite.txt>

---

<div class="post-metadata">

**Author:** ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)\
**Post date:** [October 25, 2019, 8:27pm UTC](https://discourse.itk.org/t/help-with-bogus-pre-commit-hook-failure/2350/6 "2019-10-25T20:27:43Z")

</div>

Note that the one line I’m trying to change is not the lines it’s complaining about. It complains about 2 different lines that I’ve not touched.

Bradley, what format is that file and how exactly should it be edited in my case?

---

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [October 25, 2019, 8:33pm UTC](https://discourse.itk.org/t/help-with-bogus-pre-commit-hook-failure/2350/7 "2019-10-25T20:33:29Z")

</div>

> [@seanm](#):
>
> If I remove the “unnecessary” semi-colon at line 47 compilation fails.

This is an error can that occur with an older version of `KWStyle` that did not support C++11.

To confirm the `KWStyle` executable used:

```auto
cd ~/src/ITK
git config hooks.KWStyle.path

```

You may find that it is pointing to an older executable.

Next time ITK is built, it will build `KWStyle` and configure Git to use the that version, which is new enough.

Alternatively, disable the KWStyle hook temporarily with:

```auto
git config hook.KWStyle false

```

or skip the pre-commit hooks with:

```auto
git commit -n

```

---

<div class="post-metadata">

**Author:** ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)\
**Post date:** [October 25, 2019, 8:42pm UTC](https://discourse.itk.org/t/help-with-bogus-pre-commit-hook-failure/2350/8 "2019-10-25T20:42:03Z")

</div>

Thanks Matt. Indeed I had some random build of KWStyle. git commit -n did the trick.

---

<div class="post-metadata">

**Author:** ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)\
**Post date:** [October 25, 2019, 10:31pm UTC](https://discourse.itk.org/t/help-with-bogus-pre-commit-hook-failure/2350/9 "2019-10-25T22:31:15Z")

</div>

Matt, I just did a fresh vanilla build of ITK, and commits still fail. Where is the automagical build of KWStyle supposed to be? I doesn’t seem to get created for me.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [October 26, 2019, 1:34pm UTC](https://discourse.itk.org/t/help-with-bogus-pre-commit-hook-failure/2350/10 "2019-10-26T13:34:26Z")

</div>

This should take care of building KWStyle:

> <https://github.com/InsightSoftwareConsortium/ITK/blob/master/Utilities/KWStyle/BuildKWStyle.cmake>

  
and it is included from here:  

> <https://github.com/InsightSoftwareConsortium/ITK/blob/83d92e8c8da27243ed9f6ec3d0e7324c2af80e53/CMakeLists.txt#L293>
