coova / coova-chilli

CoovaChilli is an open-source software access controller for captive portal hotspots.
Other
516 stars 258 forks source link

Coding Standard #90

Closed Spomky closed 7 years ago

Spomky commented 9 years ago

Hi,

It seems that the community is giving a new breath of this project and this is a very good news.

But the code does not seems to follow conventions and coding standards. Contributions proposed by the community may also follow differents conventions. The project will be very difficult to manage and may be a turn-off for some contributors.

It will be great if this project adopts some conventions and coding standards. I know nothing about the good practices in C++ and tools to continously verify the quality of the source code, but I found this interesting guide.

jobezic commented 9 years ago

Yes, we need some sort of refactoring..

click commented 9 years ago

I've come to love the development-mantra that NASA follows, according to Lifehacker: http://lifehacker.com/nasas-rules-for-writing-mission-critical-code-1719276064 Might be overkill for coova-chilli, although readability and function-understanding would become a lot less vague.

With regards to testingtools, there's a few simple tools that can be utilized, and SHOULD be utilized as well (Valgrind, Helgrind), and possibly also an offsite analyzer like https://scan.coverity.com/ to catch possible memoryleaks/incorrect declarations and the likes.

wlanmac commented 8 years ago

For the most part, emacs "mode: c; c-basic-offset: 2" is used throughout. (a recent commit fixed formatting in a couple places). Agreed, we should be more script on coding style and start to integrate testing into the build process.

gbaligh commented 8 years ago

Do not forget to add modelines for VIM user like me ;)

sevan commented 8 years ago

Perhaps we could use indent(1) or clang-format which could tie in as a hook so it would be irrelevant what editor you're using?

gbaligh commented 8 years ago

:+1:

gbaligh commented 8 years ago

what about indent:

indent -nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 -d0 -di1 -nfc1 -i2 -ip0 -l80 -lp -npcs -nprs -npsl -sai -saf -saw -ncs -nsc -sob -nfca -cp33 -ss -ts2 -il1 -nut
sevan commented 8 years ago

most of those are gnu specific and not available everywhere, like hnl bbo nprs sai saf saw ncs I stopped trying after that

ynezz commented 8 years ago

As I see it, we've two options here:

  1. Create CODINGSTYLE.md based on @wlanmac preferences (2 spaces indent level) and modify some existing CodingStyle to have some solid source for the remaining stuff like braces, long lines, variable namings etc. Then create some supporting scripts which would help reformat our code base, add Git commit hook script and some automatic Travis checking for PRs.
  2. Steal^Wborrow some existing CODINGSTYLE.md with all supporting scripts and checks to not reinvent the wheel, then reformat complete codebase with those script and start using it.

@wlanmac is probably the one to make this tough decision :)