hashtopolis / server

Hashtopolis - distributed password cracking with Hashcat
GNU General Public License v3.0
1.46k stars 222 forks source link

Collect coding styleguide and prinicples #1100

Open ObsidianOracle opened 1 month ago

ObsidianOracle commented 1 month ago

This should be an issue for you, to agree on standards you want to have when it comes to collaborate coding:

Coding Styleguides? Describing? Testing?

festanie commented 1 month ago

I was looking quickly at existing coding style guides for PHP. Maybe this could be a good starting point to create ours: https://gist.github.com/ryansechrest/8138375

There are also some PHP standards recommendations like these ones: https://www.php-fig.org/psr/psr-12/, https://www.php-fig.org/psr/psr-1/

jessevz commented 1 month ago

I agree that its good to follow php standards like psr-1 and psr-12. When i Googled around I found PHP codesniffer (https://github.com/squizlabs/PHP_CodeSniffer) which can check for these standards and has integration in visual studio code and PHP-storm. Its probably a good idea if everyone configure this so that we can all easily follow the same standards.

Another big point we discussed was about commenting styles. A common style is PHPDoc-style which has good integration within IDE's and some of the code is already documented this way so I think its good to stick with that. For complex code its also nice to add concise inline comments to explain the logic. These are my main suggestions, let me know what you guys think about this.

gluafamichl commented 1 month ago

Following PHP standards and using IDEs internal checks is a good starting point. For long term we could think about adding pre-commit hooks (git commit will fail, if linting, sniffing and so on fails, code style issues can be corrected automatically) or we could add build pipelines to do such checks after pushing the code. We are using such mechanisms for our python projects (there you can even check, if doc style for comments is correct), I think there will something similar for PHP. It will be much more accepted, if we do a lot of things automatically in the background.

s3inlc commented 1 month ago

I agree that its good to follow php standards like psr-1 and psr-12. When i Googled around I found PHP codesniffer (https://github.com/squizlabs/PHP_CodeSniffer) which can check for these standards and has integration in visual studio code and PHP-storm. Its probably a good idea if everyone configure this so that we can all easily follow the same standards.

A small note regarding CodeSniffer, apparently they seem to have moved the repository here: https://github.com/PHPCSStandards/PHP_CodeSniffer But for me that also looks quite something which we could use. Maybe at the beginning on a manual basis (as we probably will have a lot of violations, especially regarding the documentation of functions. Later we can put that into git commit hooks, to enforce to keep it maintained with that level.