How to keep code within coding standards? #384
Replies: 4 comments
-
Hi Ricard, I have some git hooks that are run just before a commit is made. One of them runs the script through the dos2unix utility (https://dos2unix.sourceforge.io/) which standardises all line endings to Unix style (Git can get funny about mixed line endings). Along the way it removes any trailing white space. Thanks |
Beta Was this translation helpful? Give feedback.
-
Hi Ricard (and anyone else who is interested. I have put my hooks here: https://github.com/timschofield/hooks These need to be installed in your .git/hooks folder for every repository you want to use them. All the files need to be given executable permissions. They do depend on the dos2unix utility which I linked to earlier. There are windows versions, and all Linux distros will have it in their repositories. Once they are installed you should find they are run when you issue a commit command. If errorrs are found the commit will abort, otherwise it will continue the commit. There is a script called prepare-commit-msg which produces a formatted commit message that is in a style I like. Feel free to adapt it, and if you don't care just delete it. For some reason when I wrote it I used command line PHP which you will need installed for it to work. Hope this helps, |
Beta Was this translation helpful? Give feedback.
-
Thanks, Tim. Sure it helps! |
Beta Was this translation helpful? Give feedback.
-
After a few hiccups due to Windows, and with the help of Copilot, I got the pre-commit working. Thanks! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi @timschofield:
I realized you manage to remove the trailing spaces at the end of each line, and I keep forgetting them there ;-)
I am testing the prompt "cleanup the code following the standards of https://weberp.org/CodingStandards.html" in VSC Copilot, with inconsistent results.
Do you have a script you can share to perform a “clean up” after editing?
As these days we are checking most of the code now to make it v5-ready, should we update the https://weberp.org/CodingStandards.html so we clean it up at the same time?
Thanks,
R
Beta Was this translation helpful? Give feedback.
All reactions