Personal tools
You are here: Home Projects PNP4Nagios Coding Style

Coding Style

by Herbert Straub last modified 2008-06-05 06:43

Coding Style Informations and transform plan

Problem description

The PNP source code containing mixed indent forms: with spaces and tabs. I think a reformating will lead to a much better readability.

Coding Style

See the K&R style in - Wikipedia Indent style and 4 space indents and no tabs

VIM Setup

Add the following line at the end of the source file:

    vim: set ai tabstop=4 shiftwidth=4 expandtab:

This should be a comment line. For C ist should be:

    /* vim: set ai tabstop=4 shiftwidth=4 expandtab: */

For Perl:

    # vim: set ai tabstop=4 shiftwidth=4 expandtab:

References

Transformation

The transformation process should be encapsulated in a miner version step. For example 0.4.9 to 0.4.10.

Tools

C, C++

We can use the GNU indent tool with the following options:

      indent -nbad -bap -bbo -nbc -br -brs -c33 \
      -cd33 -ncdb -ce -ci4 -cli0 -cp33 -cs -d0 \
      -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 -lp \
      -npcs -nprs -npsl -saf -sai -saw -nsc \
      -nsob -nss -nut file.c  -o file1.c

Perl

We can use perltidy:

      perltidy  -q process_perfdata.pl.in  \
      --logfile -o process_perfdata1.pl

PHP

We can use phStylelist :

      php phpStylist.php function.inc.php  \
      --indent_size 4 --line_before_function \
      --space_after_if --space_around_assignment \
      --space_around_comparison --space_around_arithmetic \
      --space_around_logical --space_around_colon_question \
      --space_inside_parentheses

Javascript

We can use Beautify Javascript - need work

Document Actions