File indexing completed on 2022-10-04 15:12:36

0001 // This file is generated by 'rules_db_create.py' from 'Rules.md'.
0002 // Please don't edit it
0003 
0004 #include "rules.h"
0005 
0006 #include <QString>
0007 
0008 namespace verapp
0009 {
0010 
0011 namespace rules
0012 {
0013 
0014 void initDb(QString* titles, QString* explanations)
0015 {
0016 
0017 titles[type("F001")] = "Source files should not use the '\\\\r' (CR) character";
0018 explanations[type("F001")] =
0019 "<html>"
0020 "F001: Source files should not use the &apos;\\\\r&apos; (CR) character"
0021 "<hr>"
0022 "As a commonly accepted practice, line breaks are denoted by a single &apos;\\\\n&apos; (LF) character or by two characters &quot;\\\\r\\\\n&quot; (CRLF). A single appearance of &apos;\\\\r&apos; (CR) is discouraged."
0023 "<br><br>"
0024 "<b>Compliance:</b> Boost"
0025 "</html>";
0026 
0027 titles[type("F002")] = "File names should be well-formed";
0028 explanations[type("F002")] =
0029 "<html>"
0030 "F002: File names should be well-formed"
0031 "<hr>"
0032 "The source file names should be well-formed in the sense of their allowed maximum length and directory depth. Directory and file names should start with alphabetic character or underscore. In addition, directory names should not contain dots and file names can have only one dot. <b>Recognized parameters:</b>"
0033 "<pre>"
0034 "    Name                    Default   Description\n"
0035 "    ----------------------- --------- -------------------------------------------------\n"
0036 "    max-directory-depth     8         Maximum depth of the directory structure.\n"
0037 "    max-dirname-length      31        Maximum length of the directory path component.\n"
0038 "    max-filename-length     31        Maximum length of the leaf file name.\n"
0039 "    max-path-length         100       Maximum length of the full path."
0040 "</pre>"
0041 "<b>Compliance:</b> Boost"
0042 "</html>";
0043 
0044 titles[type("L001")] = "No trailing whitespace";
0045 explanations[type("L001")] =
0046 "<html>"
0047 "L001: No trailing whitespace"
0048 "<hr>"
0049 "<i>Trailing whitespace* is any whitespace character (space or tab) that is placed at the end of the source line, after other characters or alone. The presence of *trailing whitespace</i> artificially influences some source code metrics and is therefore discouraged. As a special case, the trailing whitespace in the otherwise empty lines is allowed provided that the amount of whitespace is identical to the indent in the previous line - this exception is more friendly with less smart editors, but can be switched off by setting non-zero value for the `strict-trailing-space` parameter. <b>Recognized parameters:</b>"
0050 "<pre>"
0051 "    Name                      Default   Description\n"
0052 "    ------------------------- --------- --------------------------------------\n"
0053 "    strict-trailing-space     0         Strict mode for trailing whitespace."
0054 "</pre>"
0055 "<b>Compliance:</b> Inspirel"
0056 "</html>";
0057 
0058 titles[type("L002")] = "Don't use tab characters";
0059 explanations[type("L002")] =
0060 "<html>"
0061 "L002: Don&apos;t use tab characters"
0062 "<hr>"
0063 "<i>Horizontal tabs</i> are not consistently handled by editors and tools. Avoiding them ensures that the intended formatting of the code is preserved."
0064 "<br><br>"
0065 "<b>Compliance:</b> HICPP, JSF"
0066 "</html>";
0067 
0068 titles[type("L003")] = "No leading and no trailing empty lines";
0069 explanations[type("L003")] =
0070 "<html>"
0071 "L003: No leading and no trailing empty lines"
0072 "<hr>"
0073 "<i>Leading and trailing empty lines</i> confuse users of various tools (like `head` and `tail`) and artificially influence some source code metrics."
0074 "<br><br>"
0075 "<b>Compliance:</b> Inspirel"
0076 "</html>";
0077 
0078 titles[type("L004")] = "Line cannot be too long";
0079 explanations[type("L004")] =
0080 "<html>"
0081 "L004: Line cannot be too long"
0082 "<hr>"
0083 "The source code line should not exceed some <i>reasonable</i> length. <b>Recognized parameters:</b>"
0084 "<pre>"
0085 "    Name                Default   Description\n"
0086 "    ------------------- --------- -------------------------------------\n"
0087 "    max-line-length     100       Maximum length of source code line."
0088 "</pre>"
0089 "<b>Compliance:</b> Inspirel"
0090 "</html>";
0091 
0092 titles[type("L005")] = "There should not be too many consecutive empty lines";
0093 explanations[type("L005")] =
0094 "<html>"
0095 "L005: There should not be too many consecutive empty lines"
0096 "<hr>"
0097 "The empty lines (if any) help to introduce more &quot;light&quot; in the source code, but they should not be overdosed in the sense that too many consecutive empty lines make the code harder to follow. Lines containing only whitespace are considered to be empty in this context. <b>Recognized parameters:</b>"
0098 "<pre>"
0099 "    Name                            Default   Description\n"
0100 "    ------------------------------- --------- --------------------------------------------\n"
0101 "    max-consecutive-empty-lines     2         Maximum number of consecutive empty lines."
0102 "</pre>"
0103 "<b>Compliance:</b> Inspirel"
0104 "</html>";
0105 
0106 titles[type("L006")] = "Source file should not be too long";
0107 explanations[type("L006")] =
0108 "<html>"
0109 "L006: Source file should not be too long"
0110 "<hr>"
0111 "The source file should not exceed a <i>reasonable</i> length. Long source files can indicate an opportunity for refactoring. <b>Recognized parameters:</b>"
0112 "<pre>"
0113 "    Name                Default   Description\n"
0114 "    ------------------- --------- ------------------------------------\n"
0115 "    max-file-length     2000      Maximum number of lines in a file."
0116 "</pre>"
0117 "<b>Compliance:</b> Inspirel"
0118 "</html>";
0119 
0120 titles[type("T001")] = "One-line comments should not have forced continuation";
0121 explanations[type("T001")] =
0122 "<html>"
0123 "T001: One-line comments should not have forced continuation"
0124 "<hr>"
0125 "The one-line comment is a comment that starts with `//`. The usual intent is to let the comment continue till the end of the line, but the preprocessing rules of the language allow to actually continue the comment in the next line if <i>line-splicing</i> is forced with the backslash at the end of the line:"
0126 "<pre>"
0127 "void foo()\n"
0128 "{\n"
0129 "    // this comment is continued in the next line \\\n"
0130 "    exit(0);\n"
0131 "}"
0132 "</pre>"
0133 "It is not immediately obvious what happens in this example. Moreover, the line-splicing works only if the backslash is really the last character in the line - which is error prone because any white characters that might appear after the backslash will change the meaning of the program without being visible in the code."
0134 "<br><br>"
0135 "<b>Compliance:</b> Inspirel"
0136 "</html>";
0137 
0138 titles[type("T002")] = "Reserved names should not be used for preprocessor macros";
0139 explanations[type("T002")] =
0140 "<html>"
0141 "T002: Reserved names should not be used for preprocessor macros"
0142 "<hr>"
0143 "The C++ Standard reserves some forms of names for language implementations. One of the most frequent violations is a definition of preprocessor macro that begins with underscore followed by a capital letter or containing two consecutive underscores:"
0144 "<pre>"
0145 "#define _MY_MACRO something\n"
0146 "#define MY__MACRO something"
0147 "</pre>"
0148 "Even though the majority of known compilers use more obscure names for internal purposes and the above code is not likely to cause any significant problems, all such names are <i>formally reserved</i> and therefore should not be used. Apart from the use of underscore in macro names, preprocessor macros should not be used to redefine language keywords:"
0149 "<pre>"
0150 "#define private public\n"
0151 "#define const"
0152 "</pre>"
0153 "<b>Compliance:</b> ISO"
0154 "</html>";
0155 
0156 titles[type("T003")] = "Some keywords should be followed by a single space";
0157 explanations[type("T003")] =
0158 "<html>"
0159 "T003: Some keywords should be followed by a single space"
0160 "<hr>"
0161 "Keywords from the following list: -   `case` -   `class` -   `delete` -   `enum` -   `explicit` -   `extern` -   `goto` -   `new` -   `struct` -   `union` -   `using` should be followed by a single space for better readability."
0162 "<br><br>"
0163 "<b>Compliance:</b> Inspirel"
0164 "</html>";
0165 
0166 titles[type("T004")] = "Some keywords should be immediately followed by a colon";
0167 explanations[type("T004")] =
0168 "<html>"
0169 "T004: Some keywords should be immediately followed by a colon"
0170 "<hr>"
0171 "Keywords from the following list: -   `default` -   `private` -   `protected` -   `public` should be immediately followed by a colon, unless used in the list of base classes:"
0172 "<pre>"
0173 "class A : public B, private C\n"
0174 "{\n"
0175 "public:\n"
0176 "     A();\n"
0177 "     ~A();\n"
0178 "protected:\n"
0179 "     // ...\n"
0180 "private:\n"
0181 "     // ...\n"
0182 "};\n"
0183 "void fun(int a)\n"
0184 "{\n"
0185 "     switch (a)\n"
0186 "     {\n"
0187 "     // ...\n"
0188 "     default:\n"
0189 "          exit(0);\n"
0190 "     }\n"
0191 "}"
0192 "</pre>"
0193 "<b>Compliance:</b> Inspirel"
0194 "</html>";
0195 
0196 titles[type("T005")] = "Keywords break and continue should be immediately followed by a semicolon";
0197 explanations[type("T005")] =
0198 "<html>"
0199 "T005: Keywords break and continue should be immediately followed by a semicolon"
0200 "<hr>"
0201 "The `break` and `continue` keywords should be immediately followed by a semicolon, with no other tokens in between:"
0202 "<pre>"
0203 "while (...)\n"
0204 "{\n"
0205 "     if (...)\n"
0206 "     {\n"
0207 "          break;\n"
0208 "     }\n"
0209 "     if (...)\n"
0210 "     {\n"
0211 "          continue;\n"
0212 "     }\n"
0213 "     // ...\n"
0214 "}"
0215 "</pre>"
0216 "<b>Compliance:</b> Inspirel"
0217 "</html>";
0218 
0219 titles[type("T006")] = "Keywords return and throw should be immediately followed by a semicolon or a single space";
0220 explanations[type("T006")] =
0221 "<html>"
0222 "T006: Keywords return and throw should be immediately followed by a semicolon or a single space"
0223 "<hr>"
0224 "The `return` and `throw` keywords should be immediately followed by a semicolon or a single space:"
0225 "<pre>"
0226 "void fun()\n"
0227 "{\n"
0228 "     if (...)\n"
0229 "     {\n"
0230 "          return;\n"
0231 "     }\n"
0232 "     // ...\n"
0233 "}\n"
0234 "int add(int a, int b)\n"
0235 "{\n"
0236 "     return a + b;\n"
0237 "}"
0238 "</pre>"
0239 "An exception to this rule is allowed for exeption specifications:"
0240 "<pre>"
0241 "void fun() throw();"
0242 "</pre>"
0243 "<b>Compliance:</b> Inspirel"
0244 "</html>";
0245 
0246 titles[type("T007")] = "Semicolons should not be isolated by spaces or comments from the rest of the code";
0247 explanations[type("T007")] =
0248 "<html>"
0249 "T007: Semicolons should not be isolated by spaces or comments from the rest of the code"
0250 "<hr>"
0251 "The semicolon should not stand isolated by whitespace or comments from the rest of the code."
0252 "<pre>"
0253 "int a ;     // bad\n"
0254 "int b\n"
0255 ";           // bad\n"
0256 "int c;      // OK"
0257 "</pre>"
0258 "As an exception from this rule, semicolons surrounded by spaces are allowed in `for` loops:"
0259 "<pre>"
0260 "for ( ; ; ) // OK as an exception\n"
0261 "{\n"
0262 "    // ...\n"
0263 "}"
0264 "</pre>"
0265 "<b>Compliance:</b> Inspirel"
0266 "</html>";
0267 
0268 titles[type("T008")] = "Keywords catch, for, if, switch and while should be followed by a single space";
0269 explanations[type("T008")] =
0270 "<html>"
0271 "T008: Keywords catch, for, if, switch and while should be followed by a single space"
0272 "<hr>"
0273 "Keywords `catch`, `for`, `if`, `switch` and `while` should be followed by a single space and then an opening left parenthesis:"
0274 "<pre>"
0275 "catch (...)\n"
0276 "{\n"
0277 "     for (int i = 0; i != 10; ++i)\n"
0278 "     {\n"
0279 "          if (foo(i))\n"
0280 "          {\n"
0281 "               while (getline(cin, line))\n"
0282 "               {\n"
0283 "                    switch (i % 3)\n"
0284 "                    {\n"
0285 "                    case 0:\n"
0286 "                         bar(line);\n"
0287 "                         break;\n"
0288 "                    // ...\n"
0289 "                    }\n"
0290 "               }\n"
0291 "          }\n"
0292 "     }\n"
0293 "}"
0294 "</pre>"
0295 "<b>Compliance:</b> Inspirel"
0296 "</html>";
0297 
0298 titles[type("T009")] = "Comma should not be preceded by whitespace, but should be followed by one";
0299 explanations[type("T009")] =
0300 "<html>"
0301 "T009: Comma should not be preceded by whitespace, but should be followed by one"
0302 "<hr>"
0303 "A comma, whether used as operator or in various lists, should not be preceded by whitespace on its left side, but should be followed by whitespace on its right side:"
0304 "<pre>"
0305 "void fun(int x, int y, int z);\n"
0306 "int a[] = {5, 6, 7};\n"
0307 "class A : public B,\n"
0308 "          public C\n"
0309 "{\n"
0310 "     // ...\n"
0311 "};"
0312 "</pre>"
0313 "An exception to this rule is allowed for `operator,`:"
0314 "<pre>"
0315 "struct A {};\n"
0316 "void operator,(const A &amp;left, const A &amp;right);"
0317 "</pre>"
0318 "<b>Compliance:</b> Inspirel"
0319 "</html>";
0320 
0321 titles[type("T010")] = "Identifiers should not be composed of 'l' and 'O' characters only";
0322 explanations[type("T010")] =
0323 "<html>"
0324 "T010: Identifiers should not be composed of &apos;l&apos; and &apos;O&apos; characters only"
0325 "<hr>"
0326 "The characters &apos;l&apos; (which is lowercase &apos;L&apos;) and &apos;O&apos; (which is uppercase &apos;o&apos;) should not be the only characters used in the identifier, because this would make them visually similar to numeric literals."
0327 "<br><br>"
0328 "<b>Compliance:</b> Inspirel"
0329 "</html>";
0330 
0331 titles[type("T011")] = "Curly brackets from the same pair should be either in the same line or in the same column";
0332 explanations[type("T011")] =
0333 "<html>"
0334 "T011: Curly brackets from the same pair should be either in the same line or in the same column"
0335 "<hr>"
0336 "Corresponding curly brackets should be either in the same line or in the same column. This promotes clarity by emphasising scopes, but allows concise style of one-line definitions and empty blocks:"
0337 "<pre>"
0338 "class MyException {};\n"
0339 "struct MyPair\n"
0340 "{\n"
0341 "    int a;\n"
0342 "    int b;\n"
0343 "};\n"
0344 "enum state { close, open };\n"
0345 "enum colors\n"
0346 "{\n"
0347 "    black,\n"
0348 "    red,\n"
0349 "    green,\n"
0350 "    blue,\n"
0351 "    white\n"
0352 "};"
0353 "</pre>"
0354 "<b>Compliance:</b> Inspirel"
0355 "</html>";
0356 
0357 titles[type("T012")] = "Negation operator should not be used in its short form";
0358 explanations[type("T012")] =
0359 "<html>"
0360 "T012: Negation operator should not be used in its short form"
0361 "<hr>"
0362 "The negation operator (exclamation mark) reduces readability of the code due to its terseness. Prefer explicit logical comparisons or alternative tokens for increased readability:"
0363 "<pre>"
0364 "if (!cond)         // error-prone\n"
0365 "if (cond == false) // better\n"
0366 "if (not cond)      // better (alternative keyword)"
0367 "</pre>"
0368 "<b>Compliance:</b> Inspirel"
0369 "</html>";
0370 
0371 titles[type("T013")] = "Source files should contain the copyright notice";
0372 explanations[type("T013")] =
0373 "<html>"
0374 "T013: Source files should contain the copyright notice"
0375 "<hr>"
0376 "The copyright notice is required by man coding standards and guidelines. In some countries every written artwork has some copyright, even if implicit. Prefer explicit notice to avoid any later confusion. This rule verifies that at least one comment in the source file contains the &quot;copyright&quot; word."
0377 "<br><br>"
0378 "<b>Compliance:</b> Boost"
0379 "</html>";
0380 
0381 titles[type("T014")] = "Source files should refer the Boost Software License";
0382 explanations[type("T014")] =
0383 "<html>"
0384 "T014: Source files should refer the Boost Software License"
0385 "<hr>"
0386 "The Boost Software License should be referenced in the source code. This rule verifies that at least one comment in the source file contains the &quot;Boost Software License&quot; phrase. Note that this rule is very specific to the Boost libraries and those project that choose to use the Boost license. It is therefore not part of the default profile."
0387 "<br><br>"
0388 "<b>Compliance:</b> Boost"
0389 "</html>";
0390 
0391 titles[type("T015")] = "HTML links in comments and string literals should be correct";
0392 explanations[type("T015")] =
0393 "<html>"
0394 "T015: HTML links in comments and string literals should be correct"
0395 "<hr>"
0396 "The links embedded in comments and string literals should have correct form and should reference existing files."
0397 "<br><br>"
0398 "<b>Compliance:</b> Boost"
0399 "</html>";
0400 
0401 titles[type("T016")] = "Calls to min/max should be protected against accidental macro substitution";
0402 explanations[type("T016")] =
0403 "<html>"
0404 "T016: Calls to min/max should be protected against accidental macro substitution"
0405 "<hr>"
0406 "The calls to min and max functions should be protected against accidental macro substitution."
0407 "<pre>"
0408 "x = max(y, z); // wrong, vulnerable to accidental macro substitution\n"
0409 "x = (max)(y, z); // OK\n"
0410 "x = max BOOST_PREVENT_MACRO_SUBSTITUTION (y, z); // OK"
0411 "</pre>"
0412 "<b>Compliance:</b> Boost"
0413 "</html>";
0414 
0415 titles[type("T017")] = "Unnamed namespaces are not allowed in header files";
0416 explanations[type("T017")] =
0417 "<html>"
0418 "T017: Unnamed namespaces are not allowed in header files"
0419 "<hr>"
0420 "Unnamed namespaces are not allowed in header files. The typical use of unnamed namespace is to hide module-internal names from the outside world. Header files are physically concatenated in a single translation unit, which logically merges all namespaces with the same name. Unnamed namespaces are also merged in this process, which effectively undermines their initial purpose. Use named namespaces in header files. Unnamed namespaces are allowed in implementation files only."
0421 "<br><br>"
0422 "<b>Compliance:</b> Boost"
0423 "</html>";
0424 
0425 titles[type("T018")] = "Using namespace is not allowed in header files";
0426 explanations[type("T018")] =
0427 "<html>"
0428 "T018: Using namespace is not allowed in header files"
0429 "<hr>"
0430 "Using namespace directives are not allowed in header files. The using namespace directive imports names from the given namespace and when used in a header file influences the global namespace of all the files that directly or indirectly include this header file. It is imaginable to use the using namespace directive in a limited scope in a header file (for example in a template or inline function definition), but for the sake of consistency this is also discouraged."
0431 "<br><br>"
0432 "<b>Compliance:</b> C++ Coding Standards"
0433 "</html>";
0434 
0435 titles[type("T019")] = "Control structures should have complete curly-braced block of code";
0436 explanations[type("T019")] =
0437 "<html>"
0438 "T019: Control structures should have complete curly-braced block of code"
0439 "<hr>"
0440 "Control structures managed by for, if and while constructs can be associated with a single instruction or with a complex block of code. Standardizing on the curly-braced blocks in all cases allows one to avoid common pitfalls and makes the code visually more uniform."
0441 "<pre>"
0442 "if (x) foo();     // bad style\n"
0443 "if (x) { foo(); } // OK\n"
0444 "if (x)\n"
0445 "    foo();        // again bad style\n"
0446 "if (x)\n"
0447 "{                 // OK\n"
0448 "    foo();\n"
0449 "}\n"
0450 "if (x)\n"
0451 "    while (y)     // bad style\n"
0452 "        foo();    // bad style\n"
0453 "if (x)\n"
0454 "{                 // OK\n"
0455 "    while (y)\n"
0456 "    {             // OK\n"
0457 "        foo();\n"
0458 "    }\n"
0459 "}\n"
0460 "for (int i = 0; i &lt;= 10; ++i);  // oops!\n"
0461 "    cout &lt;&lt; &quot;Hello\\n&quot;;\n"
0462 "for (int i = 0; i &lt;= 10; ++i)   // OK\n"
0463 "{\n"
0464 "    cout &lt;&lt; &quot;Hello\\n&quot;;\n"
0465 "}"
0466 "</pre>"
0467 "<b>Compliance:</b> Inspirel"
0468 "</html>";
0469 
0470 }
0471 
0472 }
0473 
0474 }