CDash:CodingRules: Difference between revisions
From KitwarePublic
Jump to navigationJump to search
(New page: This page describes the coding style and rules to adopt when developing CDash.) |
David.cole (talk | contribs) (→Date/Time: correct formatting) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
This page describes the coding style and rules to adopt when developing CDash. | 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 ... |
Latest revision as of 14:29, 6 July 2012
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 ...