Thomas Stibor replied to the topic 'INDI Code Style' in the forum. 1 year ago

Hi Jasem,

I think it should work and one could integrate it into the github CI process. It actually works as follows:
For demonstration I ill-formatted:

diff --git a/examples/tutorial_one/simpledevice.cpp b/examples/tutorial_one/simpledevice.cpp
index cbb68f65e..82e5d76eb 100644
--- a/examples/tutorial_one/simpledevice.cpp
+++ b/examples/tutorial_one/simpledevice.cpp
@@ -30,15 +30,14 @@ std::unique_ptr<SimpleDevice> simpleDevice(new SimpleDevice());
 ***************************************************************************************/
 bool SimpleDevice::Connect()
 {
-    IDMessage(getDeviceName(), "Simple device connected successfully!");
-    return true;
+IDMessage(getDeviceName(), "Simple device connected successfully!");
+return true;
 }
 
 /**************************************************************************************
 ** Client is asking us to terminate connection to the device
 ***************************************************************************************/
-bool SimpleDevice::Disconnect()
-{
+bool SimpleDevice::Disconnect() {
     IDMessage(getDeviceName(), "Simple device disconnected successfully!");
     return true;
 }
diff --git a/examples/tutorial_one/simpledevice.h b/examples/tutorial_one/simpledevice.h
index 0b0dbf709..b02ac03c0 100644
--- a/examples/tutorial_one/simpledevice.h
+++ b/examples/tutorial_one/simpledevice.h
@@ -25,7 +25,7 @@
 
 class SimpleDevice : public INDI::DefaultDevice
 {
-    public:
+public:
         SimpleDevice() = default;
 
     protected:

Once the the PR is fetched on github one could integrate into the CI the bash command and script:
$ for f in `git diff --name-only origin/master`; do .circleci/check-codestyle.sh "${f}"; done
***************************************************************************************/
 bool SimpleDevice::Connect()
 {
[STYLE WARNING]     IDMessage(getDeviceName(), "Simple device connected successfully!");
[STYLE WARNING]     return true;
 }
 
 /**************************************************************************************
 ** Client is asking us to terminate connection to the device
 ***************************************************************************************/
[STYLE WARNING] bool SimpleDevice::Disconnect()
[STYLE WARNING] {
     IDMessage(getDeviceName(), "Simple device disconnected successfully!");
     return true;
 }
File examples/tutorial_one/simpledevice.cpp has style warning(s), see https://github.com/indilib/indi/blob/master/README.md
 class SimpleDevice : public INDI::DefaultDevice
 {
[STYLE WARNING]     public:
         SimpleDevice() = default;
 
     protected:
File examples/tutorial_one/simpledevice.h has style warning(s), see https://github.com/indilib/indi/blob/master/README.md

I will try that out and send a PR when it works

Cheers
Thomas

Read More...