CDash:CodingRules

From KitwarePublic
Revision as of 14:29, 6 July 2012 by David.cole (talk | contribs) (→‎Date/Time: correct formatting)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

This page describes the coding style and rules to adopt when developing CDash.

Coding Style

Indentation

  • Tabs are not allowed. Tabs should be replaced by two spaces
  • Indentation of curly braces should be as follow:
 if($test == $test2)
   {
   }

Date/Time

In order to support MySQL and PostGreSQL the date and time should use the following defined variables:

 define("FMT_TIME", "H:i:s");  // time
 define("FMT_DATE", "Y-m-d");  // date
 define("FMT_DATETIME", "Y-m-d\TH:i:s");  // date and time
 define("FMT_DATETIMETZ", "Y-m-d\TH:i:s T");  // date and time with time zone
 define("FMT_DATETIMEMS", "Y-m-d\TH:i:s.u");  // date and time with milliseconds

Count(*) queries

 SELECT count(*) FROM ...

is used, then a column named "count(*)" is expected to contain the result. This is not portable and the following query should be used instead:

 SELECT count(*) AS num FROM ...