[CI] Add uncrustify script and action#1532
Conversation
|
So after some trial and error I managed to get an uncrustify configuration that somewhat matches the existing code style. It did find some inconsistencies, whitespaces at line ends etc., but overall I'm still not completely sure about this. I see the following problems:
What do you think @StevenCellist? |
|
I'd very, very much dislike having to do this. I'm a Windows user most of the time and it sounds terrible to have to do that every time. Let alone for those users that only want to commit a missing state assert and just learned to file an issue. My personal preference would be to have it e.g. run as part of the release CI. |
|
It's killing some alignment choices in places where we added some extra whitespace. Which is a minor inconvenience. And probably have it ignore the firmware images? |
That is indeed a solution, we can run this on release (and also occasionaly by manual trigger).
Could you point out where exactly? Like I said I wasn't able to fully match the existing style
I don't expect any changes there, so I actually don't really care how the firmware-only headers are formatted. Also there's no readability required there. |
StevenCellist
left a comment
There was a problem hiding this comment.
Marked a couple of yours and one of mine as an example.
| this->preambleDetLength = maxDetLen >= 32 ? RADIOLIB_SX126X_GFSK_PREAMBLE_DETECT_32 : | ||
| maxDetLen >= 24 ? RADIOLIB_SX126X_GFSK_PREAMBLE_DETECT_24 : | ||
| maxDetLen >= 16 ? RADIOLIB_SX126X_GFSK_PREAMBLE_DETECT_16 : | ||
| maxDetLen > 0 ? RADIOLIB_SX126X_GFSK_PREAMBLE_DETECT_8 : |
| uint16_t pos = 0; | ||
| uint16_t st_idx = 0; | ||
| uint16_t st_idx_init = 0; | ||
| int16_t bits_left = nb_bits; |
| this->rev = LoRaWANNode::ntoh<uint8_t>(&this->bufferSession[RADIOLIB_LORAWAN_SESSION_VERSION]); | ||
| this->lwClass = LoRaWANNode::ntoh<uint8_t>(&this->bufferSession[RADIOLIB_LORAWAN_SESSION_CLASS]); | ||
| this->homeNetId = LoRaWANNode::ntoh<uint32_t>(&this->bufferSession[RADIOLIB_LORAWAN_SESSION_HOMENET_ID]); | ||
| this->aFCntDown = LoRaWANNode::ntoh<uint32_t>(&this->bufferSession[RADIOLIB_LORAWAN_SESSION_A_FCNT_DOWN]); | ||
| this->nFCntDown = LoRaWANNode::ntoh<uint32_t>(&this->bufferSession[RADIOLIB_LORAWAN_SESSION_N_FCNT_DOWN]); | ||
| this->confFCntUp = LoRaWANNode::ntoh<uint32_t>(&this->bufferSession[RADIOLIB_LORAWAN_SESSION_CONF_FCNT_UP]); | ||
| this->rev = LoRaWANNode::ntoh<uint8_t>(&this->bufferSession[RADIOLIB_LORAWAN_SESSION_VERSION]); | ||
| this->lwClass = LoRaWANNode::ntoh<uint8_t>(&this->bufferSession[RADIOLIB_LORAWAN_SESSION_CLASS]); | ||
| this->homeNetId = LoRaWANNode::ntoh<uint32_t>(&this->bufferSession[RADIOLIB_LORAWAN_SESSION_HOMENET_ID]); | ||
| this->aFCntDown = LoRaWANNode::ntoh<uint32_t>(&this->bufferSession[RADIOLIB_LORAWAN_SESSION_A_FCNT_DOWN]); | ||
| this->nFCntDown = LoRaWANNode::ntoh<uint32_t>(&this->bufferSession[RADIOLIB_LORAWAN_SESSION_N_FCNT_DOWN]); | ||
| this->confFCntUp = LoRaWANNode::ntoh<uint32_t>(&this->bufferSession[RADIOLIB_LORAWAN_SESSION_CONF_FCNT_UP]); | ||
| this->confFCntDown = LoRaWANNode::ntoh<uint32_t>(&this->bufferSession[RADIOLIB_LORAWAN_SESSION_CONF_FCNT_DOWN]); | ||
| this->adrFCnt = LoRaWANNode::ntoh<uint32_t>(&this->bufferSession[RADIOLIB_LORAWAN_SESSION_ADR_FCNT]); | ||
| this->fCntUp = LoRaWANNode::ntoh<uint32_t>(&this->bufferSession[RADIOLIB_LORAWAN_SESSION_FCNT_UP]); |
This PR adds script to perform uncrustify formatting check and fix. Result of the script is a
.patchfile which can be applied to fix the issues.A GitHub action is also added to trigger this on every push to master and every PR.