swi_config_sample.xml 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  1. <!--
  2. Software Index, Copyright 2010, Software Index Project Team
  3. Link: http://swi.sourceforge.net
  4. This file is part of Software Index Tool.
  5. Software Index is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, version 3 of the License.
  8. Software Index is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with Software Index. If not, see <http://www.gnu.org/licenses/>.
  14. -->
  15. <!--
  16. Configuration file is formed in XML format.
  17. Use this file as a 'configration file description' and
  18. create new configs using this file as a baseline.
  19. Comments below provides with the description for all options.
  20. Commented XML sections make patterns for your specific extensions.
  21. Some of them demostrates usage examples.
  22. -->
  23. <?xml version="1.0" encoding="utf-8"?>
  24. <!-- Root node 'swi:configuration' is mandatory. It's name is hardcoded. -->
  25. <swi:configuration>
  26. <!-- Section 'swi:info' is used for descriptive purposes. -->
  27. <swi:info>
  28. <!--
  29. Option 'swi:version' should be equal to 1.
  30. It is reserved for further extensions.
  31. -->
  32. <swi:version>1</swi:version>
  33. <!--
  34. Option 'swi:project/swi:name' is used in the final report.
  35. All objects are references in the following format:
  36. YOUR_PROJECT_NAME/YOUR_MODULE_NAME/FILE/FUNCTION_NAME
  37. Changes in this sections automatically reflected in the report.
  38. -->
  39. <swi:project>
  40. <!-- Modify this option in order to refer to the actual name of your solution -->
  41. <swi:name>YOUR_PROJECT_NAME</swi:name>
  42. </swi:project>
  43. <!--
  44. This section for tracing purposes.
  45. If you workflow assumes history records in project files,
  46. this is the place to keep your records
  47. -->
  48. <swi:history>
  49. <!-- Section 'swi:revision' can be repeated several times -->
  50. <swi:revision>
  51. <swi:name>ALFA</swi:name>
  52. <swi:user>USER</swi:user>
  53. <swi:comment>Sample configuration with the description created</swi:comment>
  54. </swi:revision>
  55. <!--
  56. Add here the next 'swi:revision' section, for example:
  57. <swi:revision>
  58. <swi:name>BETA</swi:name>
  59. <swi:user>USER</swi:user>
  60. <swi:comment>Description of the next update</swi:comment>
  61. </swi:revision>
  62. -->
  63. </swi:history>
  64. </swi:info>
  65. <!-- Section 'swi:modules' define where to get sources and how to process them. -->
  66. <swi:modules>
  67. <!-- Section 'swi:module' can be repeated several times -->
  68. <swi:module>
  69. <!--
  70. Option 'swi:name' is used in the final report.
  71. All objects are references in the following format:
  72. YOUR_PROJECT_NAME/YOUR_MODULE_NAME/FILE/FUNCTION_NAME
  73. Changes in this sections automatically reflected in the report.
  74. Modify this option in order to refer to the actual name of your module
  75. -->
  76. <swi:name>YOUR_MODULE_NAME</swi:name>
  77. <!--
  78. This is a full path to the directory where module's source files are stored
  79. It can be relative or full path (recommended).
  80. If it is relative path, you need to run Software Index tool from the relatively correct folder.
  81. -->
  82. <swi:location>/path/to/my/module</swi:location>
  83. <!-- Section 'swi:files' which files to process and which to miss -->
  84. <swi:files>
  85. <!--
  86. This option is a regular expression.
  87. If file name (in module's location) is mathced by this expression,
  88. it is included to the list for processing.
  89. Otherwise, it is missed and not touched by Software Index tool.
  90. The example below matches files with the following extensions:
  91. .c, .h, .cpp, .hpp
  92. -->
  93. <swi:include>^.*[.][chCH]([pP][pP])?$</swi:include>
  94. <!--
  95. This option is a regular expression.
  96. If file name (in module's location) is mathced by this expression,
  97. it is excluded from the list for processing
  98. (even if it was previously mathced by the previous option).
  99. The example below matches files with the following extensions:
  100. .gz.c, .gz.h, .gz.cpp, .gz.hpp
  101. -->
  102. <swi:exclude>^.*[.][gG][zZ][.][chCH]([pP][pP])?$</swi:exclude>
  103. </swi:files>
  104. <!--
  105. The Software Index does not parse 'preprocessor' statements, like a C/C++ compiler.
  106. It just removes lines with preprocessor defines, includes, conditions and so on.
  107. As a result a code may include unfolded preprocessor strings
  108. which are normally replaced/removed by a compiler.
  109. For example, the initial code
  110. line 1: #define MAXIMUM_NUMBER (100)
  111. line 2: #ifdef DEBUG
  112. line 3: if (currentNumber < MAXIMUM_NUMBER) {
  113. line 4: printf("New overflow detected: %d\n", currentNumber);
  114. line 5: count++;
  115. line 6: }
  116. line 7: #else
  117. line 8: if (currentNumber < MAXIMUM_NUMBER) {
  118. line 9: count++;
  119. line 10: }
  120. line 11: #endif
  121. is converted to:
  122. line 1:
  123. line 2:
  124. line 3: if (currentNumber < MAXIMUM_NUMBER) {
  125. line 4: printf("New overflow detected: %d\n", currentNumber);
  126. line 5: count++;
  127. line 6: }
  128. line 7:
  129. line 8: if (currentNumber < MAXIMUM_NUMBER) {
  130. line 9: count++;
  131. line 10: }
  132. line 11:
  133. In the last example, the final code is parsable.
  134. If all your preprocessor statements are in the similar style and does not
  135. corrupt the structure of block start/end delimeters as in the example above,
  136. you do not need to bother about preprocessor stuff.
  137. However, if the initial code includes lines like these:
  138. line 1: #define MAXIMUM_NUMBER (100)
  139. line 2: if (currentNumber < MAXIMUM_NUMBER) {
  140. line 3: #ifdef DEBUG
  141. line 4: printf("New overflow detected: %d\n", currentNumber);
  142. line 5: count++;
  143. line 6: }
  144. line 7: #else
  145. line 8: count++;
  146. line 9: }
  147. line 10: #endif
  148. it is not parsable, because brackets mismatch is detected after preprocessing
  149. (see lines 6 and 9 below):
  150. line 1:
  151. line 2: if (currentNumber < MAXIMUM_NUMBER) {
  152. line 3:
  153. line 4: printf("New overflow detected: %d\n", currentNumber);
  154. line 5: count++;
  155. line 6: }
  156. line 7:
  157. line 8: count++;
  158. line 9: }
  159. line 10:
  160. Thus, in order to use Software Index tool it is necessary to refactor places,
  161. like in the example above.
  162. The section 'swi:preprocessor' is useful in other cases.
  163. For example, if the initial code includes the following lines:
  164. line 1: #define DECLARE_HANDLER(handlerName) \
  165. line 2: int handlerName(unsigned int stateId, \
  166. line 3: unsigned int eventId, \
  167. line 4: struct EVENT_DATA_TYPE eventData)
  168. line 5:
  169. line 6: DECLARE_HANDLER(leftButtonClick);
  170. line 7: DECLARE_HANDLER(rightButtonClick);
  171. line 8:
  172. line 9: DECLARE_HANDLER(leftButtonClick)
  173. line 10: {
  174. line 11: /* This function is called when left mouse button is clicked */
  175. line 12: ...
  176. line 13: }
  177. line 14:
  178. line 15: DECLARE_HANDLER(rightButtonClick)
  179. line 16: {
  180. line 17: /* This function is called when right mouse button is clicked */
  181. line 18: ...
  182. line 19: }
  183. line 20:
  184. Software Index tool detects function DECLARE_HANDLER twice. As a result, they will be named:
  185. 'DECLARE_HANDLER' and 'DECLARE_HANDLER:1' accordingly.
  186. The better solution is to preprocess these strings using the preprocessor feature.
  187. For this particular example, it is recommended to define the rule which replaces the string:
  188. lines 6,7,9,15: DECLARE_HANDLER(_xxx_)
  189. by
  190. lines 6,7,9,15: int _xxx_(unsigned int stateId, unsigned int eventId, struct EVENT_DATA_TYPE eventData)
  191. where
  192. _xxx_ is the actual function name.
  193. In other words, the 'swi:preprocessor' section should include the following XML tags:
  194. <swi:rule>
  195. <swi:filepattern>your_regexp_file_pattern</swi:filepattern>
  196. <swi:searchpattern>([^_a-zA-Z0-9])DECLARE_HANDLER\(([^_a-zA-Z0-9])\)</swi:searchpattern>
  197. <swi:replacepattern>${1}int ${2}(unsigned int stateId, unsigned int eventId, struct EVENT_DATA_TYPE eventData)</swi:replacepattern>
  198. </swi:rule>
  199. As a result, the functions will be detected with the correct names:
  200. 'leftButtonClick' and 'rightButtonClick' accordingly.
  201. -->
  202. <swi:preprocessor>
  203. <!-- Section 'swi:rule' can be repeated several times -->
  204. <swi:rule>
  205. <!--
  206. This option is a regular expression.
  207. If name of file which is under processing is mathced by this expression,
  208. it is preprocessed according to the rule definitions.
  209. Otherwise, it is missed and not touched by the internal preprocessor tool.
  210. The example below matches files with the following extensions:
  211. .h, .hpp
  212. -->
  213. <swi:filepattern>^.*[.][hH]([pP][pP])?$</swi:filepattern>
  214. <!--
  215. Options 'swi:searchpattern' and 'swi:replacepattern' are regular expressions.
  216. Preprocessor searches the code by the 'swi:searchpattern' pattern.
  217. If it is found it is replaced by 'swi:replacepattern' string,
  218. which is interpolated before: variables ${1}, ${2}, ... are replaced by actual strings
  219. from 'swi:searchpattern' regexp hooks.
  220. -->
  221. <swi:searchpattern>([^_a-zA-Z0-9])DECLARE_HANDLER\(([^_a-zA-Z0-9])\)</swi:searchpattern>
  222. <swi:replacepattern>${1}int ${2}(unsigned int stateId, unsigned int eventId, struct EVENT_DATA_TYPE eventData)</swi:replacepattern>
  223. </swi:rule>
  224. <!--
  225. Add here the next 'swi:rule' section, for example:
  226. <swi:rule>
  227. <swi:filepattern>.*</swi:filepattern>
  228. <swi:searchpattern>(\s+)(union\s*)({)</swi:searchpattern>
  229. <swi:replacepattern>$1$2 _noname_ $3</swi:replacepattern>
  230. </swi:rule>
  231. -->
  232. </swi:preprocessor>
  233. <!--
  234. Scaner tool is used for global searching and violation reporting.
  235. If the scaner finds something, it reports the message which is also configured
  236. and increases the exit code from the Software Index Tool.
  237. For example, if you codding style requires to open the block begging from the new line:
  238. line 1:
  239. line 2: if (currentNumber < MAXIMUM_NUMBER)
  240. line 3: {
  241. line 4: count++;
  242. line 5: }
  243. line 6:
  244. it is possible to check it by scaner defining the 'swi:searchpattern' in the following way:
  245. [\n][^{][{]
  246. This regular expression matches the code which is 'badly' formated:
  247. line 1:
  248. line 2: if (currentNumber < MAXIMUM_NUMBER) {
  249. line 3: count++;
  250. line 4: }
  251. line 5:
  252. More examples. If you codding style does not allow to have noname structures, enums or unions:
  253. line 1:
  254. line 2: typedef struct _NAME_HERE_IS_MANDATORY_
  255. line 3: {
  256. line 4: int a;
  257. line 5: } my_type;
  258. line 6:
  259. it is possible to check it by scaner defining the 'swi:searchpattern' in the following way:
  260. (\s+)((union)|(enum)|(struct))(\s*{)
  261. This regular expression matches the code which is 'wrongly' written:
  262. line 1:
  263. line 2: typedef struct // noname here
  264. line 3: {
  265. line 4: int a;
  266. line 5: } my_type;
  267. line 6:
  268. And if the 'swi:messagepattern' equals to:
  269. Noname '$2' detected.
  270. the error report looks like this:
  271. file.c:2: warning: Noname 'struct' detected.
  272. -->
  273. <swi:scanner>
  274. <!-- Section 'swi:rule' can be repeated several times -->
  275. <swi:rule>
  276. <!--
  277. This option is a regular expression.
  278. If name of file which is under processing is mathced by this expression,
  279. it is scaned according to the rule definitions.
  280. Otherwise, it is missed and not touched by the internal scaner tool.
  281. The example below matches all files.
  282. -->
  283. <swi:filepattern>.*</swi:filepattern>
  284. <!--
  285. Options 'swi:searchpattern' and 'swi:messagepattern' are regular expressions.
  286. Scaner searches the code by the 'swi:searchpattern' pattern.
  287. If it is found the 'swi:messagepattern' string is printed to STDERR,
  288. 'swi:messagepattern' string is interpolated: variables ${1}, ${2}, ... are replaced by actual strings
  289. from 'swi:searchpattern' regexp hooks.
  290. -->
  291. <swi:searchpattern>(\s+)((union)|(enum)|(struct))(\s*{)</swi:searchpattern>
  292. <swi:messagepattern>Noname '$2' detected.</swi:messagepattern>
  293. <!--
  294. The 'swi:codecontent' option defines the content for scanner, it can be:
  295. initial - the initial source content
  296. code - the initial code (without comments)
  297. comments - comments only (no code)
  298. nopreprocessor - preprocessor strings excluded (without comments and preprocessor)
  299. nostrings - strings excluded (without comments and strings)
  300. purified - strings and preprocessor excluded (without comments, strings and preprocessor)
  301. commentheader - comments before function's header
  302. functionname - name of a function
  303. functionhead - purified function's header, no body
  304. functionbody - purified function's body, no header
  305. By default, the 'purified' code is scanned
  306. -->
  307. <swi:codecontent>purified</swi:codecontent>
  308. </swi:rule>
  309. <!--
  310. Add here the next 'swi:rule' section, for example:
  311. <swi:rule>
  312. <swi:filepattern>.*</swi:filepattern>
  313. <swi:searchpattern>#define\s*([_a-zA-Z0-9]+)\s*[\(]?([0-9]+)[\)]?</swi:searchpattern>
  314. <swi:messagepattern>Define '${1}' of the number '${2}'
  315. should be replaced by 'static const int ${1} = ${2};'</swi:messagepattern>
  316. <swi:codecontent>nostrings</swi:codecontent>
  317. </swi:rule>
  318. -->
  319. </swi:scanner>
  320. <!--
  321. Indexer measures common software statistics per functions, files, modules and project.
  322. They are:
  323. STATICTIC-GROUP / STATISTIC-NAME - DESCRIPTION
  324. =============== / ================== - ============================
  325. swi:length / swi:source - total number of symbols
  326. swi:length / swi:blank - number of space symbols
  327. swi:length / swi:executable - number of executable symbols
  328. swi:length / swi:comment - number of symbols inside comments
  329. swi:length / swi:function:name - number of symbols in name of a function
  330. swi:lines / swi:comment:header - number of lines in a comment before a function/file
  331. swi:lines / swi:source - total number of lines
  332. swi:lines / swi:blank - number of empty lines
  333. swi:lines / swi:executable - number of executable lines
  334. swi:lines / swi:comment - number of lines with comments
  335. swi:complexity / swi:blocks - number of blocks
  336. swi:complexity / swi:cyclomatic - McCabe's (Mayer's) Cyclomatic complexity metric
  337. swi:complexity / swi:maxdepth - Maximum indent level
  338. swi:count / swi:functions - Number of functions
  339. swi:count / swi:files - Number of files
  340. swi:count / swi:modules - Number of modules
  341. swi:checksum / swi:source - Checksum for the source code (compare purposes)
  342. Every statistic is reported incombination with the following types:
  343. STATICTIC-TYPE - DESCRIPTION
  344. =============== - ============================
  345. swi:exact - exact value
  346. swi:average - average value within a distribution
  347. swi:min - minimum value within a distribution
  348. swi:max - maximum value within a distribution
  349. swi:total - sum of values within a distribution
  350. Cumulative types (swi:average, swi:min, swi:max and swi:total) are reported if they are applicable.
  351. -->
  352. <swi:indexer:common>
  353. <!-- No settings currently available -->
  354. </swi:indexer:common>
  355. <!--
  356. Duplication indexer searches for identical code fragments, calculates total number of symbols
  357. in continues duplicated fragments per function, file, module and project.
  358. Note: blank symbols (spaces, tabulations, newlines) are ignored when strings are compared.
  359. The duplciation statistic is reported by reference 'swi:duplication/swi:symbols':
  360. STATICTIC-GROUP / STATISTIC-NAME - DESCRIPTION
  361. =============== / ================== - ============================
  362. swi:duplication / swi:symbols - Number of duplicated symbols
  363. The statistic is reported incombination with the following types:
  364. STATICTIC-TYPE - DESCRIPTION
  365. =============== - ============================
  366. swi:exact - exact value
  367. swi:average - average value within a distribution
  368. swi:min - minimum value within a distribution
  369. swi:max - maximum value within a distribution
  370. swi:total - sum of values within a distribution
  371. Cumulative types (swi:average, swi:min, swi:max and swi:total) are reported if they are applicable.
  372. This internal tool also collects pointers to duplicated fragments and prints them.
  373. Also, they can be easily extracted from the final report for other needs.
  374. -->
  375. <swi:indexer:dup>
  376. <!--
  377. The 'swi:codecontent' option defines the content for the duplicatiion searcher, it can be:
  378. initial - the initial source content
  379. code - the initial code (without comments)
  380. comments - comments only (no code)
  381. nopreprocessor - preprocessor strings excluded (without comments and preprocessor)
  382. nostrings - strings excluded (without comments and strings)
  383. purified - strings and preprocessor excluded (without comments, strings and preprocessor)
  384. commentheader - comments before function's header
  385. functionname - name of a function
  386. functionhead - purified function's header, no body
  387. functionbody - purified function's body, no header
  388. By default, the 'purified' content is used.
  389. Recomendation: if Software Index tool detects a log of duplicated fragments
  390. which are within function's header (declarations), usually it is the case when
  391. where are overloaded functions with a huge list of arguments, it is recommended
  392. to set 'swi:codecontent' option to 'functionbody' value.
  393. -->
  394. <swi:codecontent>purified</swi:codecontent>
  395. <!--
  396. The 'swi:enabled' option activates/deativates the calculation of the duplication index:
  397. on - the search tool is launched and the statistic is calculated
  398. off - the search tool is not started, the statistic is reported by zeros
  399. By default, the this is not enabled
  400. -->
  401. <swi:enabled>on</swi:enabled>
  402. <!--
  403. The 'swi:minlength' option defines the minimal length of the duplicated fragment.
  404. In other words, if the duplicated fragment is found it is at least 'swi:minlength' in length
  405. Too small value, for example 10, results in excessive growth of the total duplication index
  406. Too large value may cause the empty search result.
  407. -->
  408. <swi:minlength>100</swi:minlength>
  409. <!--
  410. The 'swi:proximity' option allows to report two code fragments as duplicated
  411. even if they are not matched exactly till the end.
  412. It helps to search 'almost' duplicated code fragments instead of 'exactly' duplicated.
  413. This option is a value from 1 till 100.
  414. For example, if there is found group of duplicated code fragments
  415. which are 100 symbols in length and 'swi:proximity' is equal to 80,
  416. this group will be extended by other found code fragments
  417. which have 80 or more the same symbols.
  418. -->
  419. <swi:proximity>100</swi:proximity>
  420. <!--
  421. All code fragments are related to some function.
  422. Except global defines, declarations, class definitions and so on.
  423. Software Index attaches global code to the 'dummy' function with name '>>>GLOBAL<<<'.
  424. The 'swi:globalcode' configures whether the global code should be included
  425. to the scope of search for duplication.
  426. on - global code is scaned for duplication
  427. off - global code is missed
  428. By default, the this option is 'off'.
  429. -->
  430. <swi:globalcode>on</swi:globalcode>
  431. </swi:indexer:dup>
  432. </swi:module>
  433. <!--
  434. Add here the next 'swi:module' section.
  435. -->
  436. </swi:modules>
  437. <!--
  438. The 'swi:report' section defines the location for reports and output settings.
  439. -->
  440. <swi:report>
  441. <!--
  442. This is a full path to the directory where report files should be stored
  443. It can be relative or full path (recommended).
  444. If it is relative path, you need to run Software Index tool from the relatively correct folder.
  445. -->
  446. <swi:destination>/path/to/the/destination/folder</swi:destination>
  447. <!--
  448. The main report is generated to XML format.
  449. Other files are created from the XML file by converters.
  450. -->
  451. <swi:xml>
  452. <!-- Name of final XML file in 'swi:destination' directory. -->
  453. <swi:name>swi_report_sample.xml</swi:name>
  454. <!--
  455. Software Index process software modules independantly from their versions.
  456. However, if it is executed with a reference to a report generated by
  457. Software Index tool for the baseline versions of your modules
  458. (baseline version - previous version of the product, the state of product
  459. before the time when changes and updates and/or additions applied)
  460. it has additional information and can report the modification status
  461. for every statistic (increased/decreased) and for every
  462. function, file and module (added, removed, modified, cloned or unmodified).
  463. Description of modification statuses:
  464. added - there was no object in the baseline version
  465. and it was added to the current version
  466. removed - there was object in the baseline version
  467. and it was removed from the current version
  468. modified - there was object in the baseline version
  469. and it was changed/updated
  470. cloned - there was object in the baseline version,
  471. it was not changed/updated in the new version,
  472. but duplication index (swi:duplication/swi:executable)
  473. was decreased or increased
  474. unmodified - the object was now touched
  475. In addition to the extra info, it helps to filter the output information.
  476. For example, it is possible to print limit overheads for added and
  477. modified functions only (missing analogues messages for untouched objects).
  478. As a result, Software Index tool can be deployed to the software development
  479. process without extra work and remakes in your old sources.
  480. You can always start to measure/control the characteristics of
  481. objectes (functions) which are affected by your recent updates only,
  482. improving the total quality step-by-step (version-by-version).
  483. See 'Example 1' in the next section for examples.
  484. The 'swi:baseline' option points out to the report for the baseline version.
  485. It should be stored in 'swi:destination' directory.
  486. If it is not defined,
  487. it is considered that all objects (functions, files and so on) were added.
  488. -->
  489. <swi:baseline>swi_report_sample.xml</swi:baseline>
  490. </swi:xml>
  491. <!--
  492. Notifications are prinited to file and to stderr stream.
  493. They highlight exceeded limitations of indexes/statistics
  494. and other notices, warnings and errors.
  495. -->
  496. <swi:notifications>
  497. <!-- Name of log file in 'swi:destination' directory. -->
  498. <swi:name>swi_report_sample.log</swi:name>
  499. <!--
  500. Flags in XML sub-tags in 'swi:error' section
  501. activate/deactivate counter of errors/notifications.
  502. If the object with the corresponding modification status
  503. has some notification (exceeded limit, for example),
  504. the error counter is increased.
  505. The final value of the error counter is returned
  506. to the operation system as exit code.
  507. Thus, if there are no notifications/errors, exit code is zero.
  508. Options should be equal to some value from the list below:
  509. on - counter is increased
  510. off - counter is not increased
  511. Example 1: 'easy deployment of the tool'
  512. added - 'on'
  513. removed - 'on' or 'off'
  514. modified - 'on'
  515. cloned - 'on' or 'off'
  516. unmodified - 'off'
  517. Example 2: 'global control'
  518. added - 'on'
  519. removed - 'on'
  520. modified - 'on'
  521. cloned - 'on'
  522. unmodified - 'on'
  523. Example 3: 'always success (zero exit code)'
  524. added - 'off'
  525. removed - 'off'
  526. modified - 'off'
  527. cloned - 'off'
  528. unmodified - 'off'
  529. -->
  530. <swi:error>
  531. <swi:added>on</swi:added>
  532. <swi:removed>on</swi:removed>
  533. <swi:modified>on</swi:modified>
  534. <swi:cloned>on</swi:cloned>
  535. <swi:unmodified>on</swi:unmodified>
  536. </swi:error>
  537. <!--
  538. The 'swi:print' section defines which messages should be printed
  539. to the log and to stderr stream. By analogy with the previous
  540. configuration section, the flags are defined per modification status.
  541. There are three types of messages which are configred by
  542. 'swi:failures', 'swi:modifications' and 'swi:duplications' options.
  543. (*) 'swi:failures' - notifications about broken limits
  544. 'swi:modifications' - notes about added/modified/cloned/removed objects
  545. 'swi:duplications' - pointers to the duplicated regions in files
  546. (*) 'swi:scanmessages' - messages collected by the internal scaner tool
  547. (see 'swi:scaner' section above)
  548. (*) marks types of messages which affect the exit code (see 'swi:error' section above).
  549. -->
  550. <swi:print>
  551. <swi:added>
  552. <swi:failures>on</swi:failures>
  553. <swi:modifications>off</swi:modifications>
  554. <swi:duplications>on</swi:duplications>
  555. <swi:scanmessages>on</swi:scanmessages>
  556. </swi:added>
  557. <swi:removed>
  558. <swi:failures>on</swi:failures>
  559. <swi:modifications>off</swi:modifications>
  560. <swi:duplications>on</swi:duplications>
  561. <swi:scanmessages>on</swi:scanmessages>
  562. </swi:removed>
  563. <swi:modified>
  564. <swi:failures>on</swi:failures>
  565. <swi:modifications>off</swi:modifications>
  566. <swi:duplications>on</swi:duplications>
  567. <swi:scanmessages>on</swi:scanmessages>
  568. </swi:modified>
  569. <swi:cloned>
  570. <swi:failures>on</swi:failures>
  571. <swi:modifications>off</swi:modifications>
  572. <swi:duplications>on</swi:duplications>
  573. <swi:scanmessages>on</swi:scanmessages>
  574. </swi:cloned>
  575. <swi:unmodified>
  576. <swi:failures>on</swi:failures>
  577. <swi:modifications>off</swi:modifications>
  578. <swi:duplications>on</swi:duplications>
  579. <swi:scanmessages>on</swi:scanmessages>
  580. </swi:unmodified>
  581. </swi:print>
  582. </swi:notifications>
  583. </swi:report>
  584. <!--
  585. Software Index tool is able to validate
  586. that the particular statistic is in the acceptable range.
  587. Limits should be defined per:
  588. STATISTIC-GROUP / STATISTIC-NAME / STATISTIC-TYPE
  589. (See sections 'swi:indexer:common' and 'swi:indexer:dup' above)
  590. -->
  591. <swi:limits>
  592. <!--
  593. For example, if it is required to have proper (not too short)
  594. comment header, it is necessary to limit the statistic:
  595. 'swi:lines/swi:comment:header/swi:exact'
  596. It is demonstarted in the following section:
  597. -->
  598. <!-- STATISTIC-GROUP -->
  599. <swi:lines>
  600. <!-- STATISTIC-NAME -->
  601. <swi:comment:header>
  602. <!-- STATISTIC-TYPE -->
  603. <swi:exact>
  604. <!--
  605. After that, actual limits should be defined for three levels:
  606. info, notice, warning
  607. The common rule is that options should be in order:
  608. 'swi:info' < 'swi:notice' < 'swi:warning'
  609. OR:
  610. 'swi:info' > 'swi:notice' > 'swi:warning'
  611. Note: limits can be negative, in this case they do not have any sense.
  612. In the example below, no messages are printed for a function
  613. if comment header before includes 5 lines at least.
  614. If it is so, the 'regular' level is attached to this function.
  615. If comment has 3-4 lines, level 'info' is assigned.
  616. If comment has 1-2 lines, level 'notice' is assigned.
  617. If ther� is no comments at all (0 lines), level 'warning' is assigned.
  618. -->
  619. <swi:info>5</swi:info>
  620. <swi:notice>3</swi:notice>
  621. <swi:warning>1</swi:warning>
  622. <!--
  623. If some object is evaluated in non-regular level (info/notice/warning)
  624. and you consider that it is too excessive to fix it
  625. (or just there are no needs/benefits to do it),
  626. it is possible to define the exception and suppress the notification
  627. in the 'swi:suppress' section below.
  628. The exception should be defined in combination with 'swi:level' option.
  629. If there is notification for the object:
  630. MY_PROJECT/MY_MODULE/my_file.c/myFunction
  631. with 'notice' level, the 'swi:level' should be equal to 'notice'.
  632. Otherwise, the notification will be still printed.
  633. In other words, severity of the message and suppress level should be equal.
  634. Also, one rule can suppress several objects. An object is considered as
  635. suppressed if it is matched by regular expression in 'swi:pattern' option.
  636. For example, the regexp pattern
  637. MY_PROJECT/MY_MODULE/my_file.c/.*
  638. suppresses all functions in my_file.c in scope of
  639. MY_MODULE module in MY_PROJECT project.
  640. However, it it NOT recommended to use multiple suppressing,
  641. due to possible missmatch in severity of messages:
  642. For example, if there are two functions:
  643. MY_PROJECT/MY_MODULE/my_file.c/myFunction1
  644. MY_PROJECT/MY_MODULE/my_file.c/myFunction2
  645. and one of them is reported by the message with 'notice' level
  646. but the second is evaluated in 'regular' level,
  647. the 'swi:pattern' rule:
  648. MY_PROJECT/MY_MODULE/my_file.c/.*
  649. will always result in the unsuppressable message,
  650. either for the first or for the second function.
  651. It is better to suppress all objects by their full reference.
  652. For example (see the previous example for prehistory)
  653. <swi:pattern swi:level="notice">^MY_PROJECT/MY_MODULE/my_file.c/myFunction1$</swi:pattern>
  654. Symbols '^' and '$' are special regexp modifiers. They require immidiate borders in the name.
  655. -->
  656. <swi:suppress>
  657. <!-- Section 'swi:pattern' can be repeated several times -->
  658. <swi:pattern swi:level="notice">^MY_PROJECT/MY_MODULE/my_file.c/myFunction1$</swi:pattern>
  659. <!--
  660. Add here the next 'swi:pattern' section, for example:
  661. <swi:pattern swi:level="warning">^.*/.*/file2.c/operator new[]$</swi:pattern>
  662. -->
  663. </swi:suppress>
  664. </swi:exact>
  665. </swi:comment:header>
  666. <!-- STATISTIC-NAME -->
  667. <swi:comment>
  668. <!--
  669. This is the next example of a limit for statistic.
  670. It demonstrates how to limit the relative values.
  671. For example, it is required to have at least 30% of comments per every function.
  672. This is defined by the relation:
  673. 'swi:lines/swi:comment/swi:exact' / 'swi:lines/swi:executable/swi:exact' * 100%.
  674. In this case it is necessary to limit 'swi:lines/swi:comment/swi:exact'
  675. (what we do here) in the relation with 'swi:lines/swi:executable/swi:exact'.
  676. -->
  677. <swi:exact swi:relation="swi:lines/swi:executable/swi:exact">
  678. <!-- 0.3 is 30% -->
  679. <swi:info>0.3</swi:info>
  680. <!-- 0.25 is 25% -->
  681. <swi:notice>0.25</swi:notice>
  682. <!-- 0.2 is 20% -->
  683. <swi:warning>0.2</swi:warning>
  684. <!--
  685. Add here suppress section, if it is needed. For example:
  686. <swi:suppress>
  687. <swi:pattern swi:level="notice">^MY_PROJECT/MY_MODULE/my_file.c/myFunction1$</swi:pattern>
  688. <swi:pattern swi:level="info">^MY_PROJECT/MY_MODULE/my_file.c/myFunction2$</swi:pattern>
  689. </swi:suppress>
  690. -->
  691. </swi:exact>
  692. </swi:comment>
  693. <!-- STATISTIC-NAME -->
  694. <swi:executable>
  695. <!--
  696. The previous examples require to limit the low bound of exact value.
  697. This sample demonstrates the limitation for total upper value.
  698. For example, sometimes it is useful to require to have short files,
  699. because they are easily maintainable in most cases.
  700. The settings in this sections allows to do it:
  701. no messages are printed for a file
  702. if total number of executable lines less than or equal to 1000.
  703. -->
  704. <swi:total>
  705. <swi:info>1000</swi:info>
  706. <swi:notice>1500</swi:notice>
  707. <swi:warning>2000</swi:warning>
  708. <!--
  709. Most likely that you will need to suppress messages for modules,
  710. because total value of lines in a module is a sum of lines in all files.
  711. -->
  712. <swi:suppress>
  713. <!-- Section 'swi:pattern' can be repeated several times -->
  714. <swi:pattern swi:level="warning">^MY_PROJECT/MY_MODULE$</swi:pattern>
  715. <!--
  716. Add here the next 'swi:pattern' section, for example:
  717. <swi:pattern swi:level="warning">^MY_PROJECT/MY_MODULE$</swi:pattern>
  718. -->
  719. </swi:suppress>
  720. </swi:total>
  721. </swi:executable>
  722. <!-- STATISTIC-NAME -->
  723. <swi:source>
  724. <!--
  725. This example is an extension for the previous.
  726. Here the limitation is applied for total values of files, modules and project
  727. at the same time.
  728. The settings in this sections allows to do it:
  729. a) no messages (info) are printed for a file
  730. if total number of source lines less than or equal to 1000.
  731. b) no messages (notices) are printed for a module
  732. if total number of source lines less than or equal to 10000.
  733. c) no messages (notices) are printed for a project
  734. if total number of source lines less than or equal to 100000.
  735. -->
  736. <swi:total>
  737. <!-- Limit for files -->
  738. <swi:info>1000</swi:info>
  739. <!-- Limit for modules -->
  740. <swi:notice>10000</swi:notice>
  741. <!-- Limit for the project -->
  742. <swi:warning>100000</swi:warning>
  743. <!--
  744. Most likely that you will need to suppress info messages for modules and
  745. notice messages for the project,
  746. because total value of lines in a module is a sum of lines in all files,
  747. and total value of lines in project is a sum of lines in all modules.
  748. -->
  749. <swi:suppress>
  750. <!-- Section 'swi:pattern' can be repeated several times -->
  751. <swi:pattern swi:level="info">^MY_PROJECT/MY_MODULE$</swi:pattern>
  752. <swi:pattern swi:level="notice">^MY_PROJECT$</swi:pattern>
  753. <!--
  754. Add here the next 'swi:pattern' section, for example:
  755. <swi:pattern swi:level="info">^MY_PROJECT/MY_MODULE$</swi:pattern>
  756. -->
  757. </swi:suppress>
  758. </swi:total>
  759. </swi:source>
  760. </swi:lines>
  761. <!-- STATISTIC-GROUP -->
  762. <swi:complexity>
  763. <!-- STATISTIC-NAME -->
  764. <swi:cyclomatic>
  765. <!-- STATISTIC-TYPE -->
  766. <swi:exact>
  767. <!--
  768. In the example below, no messages are printed for a function
  769. if cyclomatic complexity index less than or equal to 7.
  770. It indicates about proper (low) level of logical
  771. branching in a subroutine. Low level of this index
  772. more or less grants decreased costs for mainteinability
  773. and further development, minimal probability of bad fixes,
  774. better and easier understanding of a logical part of SW.
  775. -->
  776. <swi:info>7</swi:info>
  777. <swi:notice>10</swi:notice>
  778. <swi:warning>15</swi:warning>
  779. <!--
  780. Add here suppress section, if it is needed. For example:
  781. <swi:suppress>
  782. <swi:pattern swi:level="notice">^MY_PROJECT/MY_MODULE/my_file.c/myFunction1$</swi:pattern>
  783. <swi:pattern swi:level="info">^MY_PROJECT/MY_MODULE/my_file.c/myFunction2$</swi:pattern>
  784. </swi:suppress>
  785. -->
  786. </swi:exact>
  787. </swi:cyclomatic>
  788. </swi:complexity>
  789. <!--
  790. The following section defines the limitation for duplication index.
  791. In the example, it is required to control exact relative
  792. duplication index for functions and total relative
  793. duplication index for files, modules and project.
  794. -->
  795. <!-- STATISTIC-GROUP -->
  796. <swi:duplication>
  797. <!-- STATISTIC-NAME -->
  798. <swi:symbols>
  799. <!-- STATISTIC-TYPE -->
  800. <swi:exact swi:relation="swi:length/swi:executable/swi:exact">
  801. <swi:info>0.30</swi:info>
  802. <swi:notice>0.40</swi:notice>
  803. <swi:warning>0.60</swi:warning>
  804. <!--
  805. Add here suppress section, if it is needed. For example:
  806. <swi:suppress>
  807. <swi:pattern swi:level="notice">^MY_PROJECT/MY_MODULE/my_file.c/myFunction1$</swi:pattern>
  808. <swi:pattern swi:level="info">^MY_PROJECT/MY_MODULE/my_file.c/myFunction2$</swi:pattern>
  809. </swi:suppress>
  810. -->
  811. </swi:exact>
  812. <!-- STATISTIC-TYPE -->
  813. <swi:total swi:relation="swi:length/swi:executable/swi:total">
  814. <swi:info>0.30</swi:info>
  815. <swi:notice>0.40</swi:notice>
  816. <swi:warning>0.60</swi:warning>
  817. <!--
  818. Add here suppress section, if it is needed. For example:
  819. <swi:suppress>
  820. <swi:pattern swi:level="warning">^MY_PROJECT/MY_MODULE/my_file.c$</swi:pattern>
  821. <swi:pattern swi:level="notice">^MY_PROJECT/MY_MODULE$</swi:pattern>
  822. <swi:pattern swi:level="info">^MY_PROJECT$</swi:pattern>
  823. </swi:suppress>
  824. -->
  825. </swi:total>
  826. </swi:symbols>
  827. </swi:duplication>
  828. <!--
  829. Add here more sections with definition of limits if it is needed.
  830. -->
  831. </swi:limits>
  832. </swi:configuration>