swi_config_sample.xml 45 KB

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