project.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <?xml version="1.0" encoding="iso-8859-5"?>
  2. <!--
  3. Metrix++, Copyright 2009-2013, Metrix++ Project
  4. Link: http://swi.sourceforge.net
  5. This file is part of Metrix++ Tool.
  6. Metrix++ 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. Metrix++ 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 Metrix++. If not, see <http://www.gnu.org/licenses/>.
  15. -->
  16. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  17. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  18. <html xmlns="http://www.w3.org/1999/xhtml">
  19. <head>
  20. <meta http-equiv="cache-control" content="max-age=0" />
  21. <meta http-equiv="cache-control" content="no-cache" />
  22. <meta http-equiv="expires" content="0" />
  23. <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
  24. <meta http-equiv="pragma" content="no-cache" />
  25. <meta http-equiv="content-type" content="text/html; charset=iso-8859-5" />
  26. <title>Metrix++ Project</title>
  27. <link href="style.css" rel="stylesheet" type="text/css" />
  28. </head>
  29. <body>
  30. <table border="0" align="center" cellpadding="0" cellspacing="0" width="800">
  31. <tbody>
  32. <tr>
  33. <td></td>
  34. <td valign="middle"></td>
  35. </tr>
  36. <tr>
  37. <td><img src="logo_project.png" alt="Software Index Project Page" /></td>
  38. <td valign="top">
  39. <div align="right">
  40. <p align="center"><a href="http://sourceforge.net/projects/swi"
  41. class="lowImportance"><img
  42. src="http://sflogo.sourceforge.net/sflogo.php?group_id=275605&amp;type=13"
  43. alt="Get Software Index at SourceForge.net. Fast, secure and Free Open Source software downloads"
  44. border="0" /></a></p>
  45. <p align="center"><script type="text/javascript"
  46. src="http://www.ohloh.net/p/485947/widgets/project_users_logo.js">
  47. </script>
  48. </p>
  49. </div>
  50. </td>
  51. </tr>
  52. <tr>
  53. <td colspan="2"><hr />
  54. </td>
  55. </tr>
  56. <tr>
  57. <td colspan="2" class="highImportance"
  58. style="text-align:center;margin-left:auto;margin-right:0;"><a
  59. href="#Overview">Overview</a> | <a href="#Download">Download</a> | <a
  60. href="#Documentation">Documentation</a> | <a href="#Support">Bur
  61. report</a> | <a href="#Support">Feature request</a> | <a
  62. href="#Createplugin">Create plugin</a></td>
  63. </tr>
  64. <tr>
  65. <td colspan="2"><hr />
  66. </td>
  67. </tr>
  68. <tr>
  69. <td colspan="2" valign="top">
  70. <table width="100%" border="0" cellspacing="0" cellpadding="10">
  71. <tbody>
  72. <tr>
  73. <td valign="top"><h3 id="Overview">Overview</h3>
  74. <p><span class="normalImportance">Metrix++</span> is the
  75. platform to collect and analyse code metrics.</p>
  76. <ul>
  77. <li>It has got plugin based architecture, so it is easy to
  78. add support for new languages and/or define new metrics
  79. and/or create new pre- and post-processing tools.</li>
  80. <li>Every metric has got 'turn-on' and other configuration
  81. options.</li>
  82. <li>There is no predefined thresholds for metrics or rules.
  83. You can choose and configure any limit you want.</li>
  84. <li>It scales well to big code bases. For example initial
  85. parsing of about 10000 files takes 2-3 minutes on average
  86. PC, and ONLY 10-20 seconds for iterative re-run. Reporting
  87. of summary result and exceeded limits is less than 1 - 10
  88. seconds.</li>
  89. <li>It can compare results for 2 code snapshots (collections)
  90. and differentiate added regions (classes, functions, etc.),
  91. modified regions and unchanged regions.</li>
  92. <li>As a result, easy deployment is guaranteed into legacy
  93. software, helping you to deal with legacy code effiently -
  94. either enforce 'leave it not worse than it was before' rule
  95. or motivate re-factoring.</li>
  96. </ul>
  97. <h4>Standard Plugins</h4>
  98. <p>The distributive includes a set of standard plugins:</p>
  99. <ul>
  100. <li><h4>Code parsers</h4>
  101. <ul>
  102. <li><span class="normalImportance">C/C++</span> parser
  103. recognises definition of namespaces, definition of
  104. classes/structs (including enclosed in functions) and
  105. definition of functions/operators </li>
  106. </ul>
  107. </li>
  108. <li><h4>Metrics</h4>
  109. <ul>
  110. <li><span class="normalImportance">cyclomatic
  111. complexity</span> (by McCabe) per function <span
  112. class="lowImportance">[supports C/C++
  113. language]</span></li>
  114. <li><span class="normalImportance">mismatched
  115. brackets</span> '{}'' per file <span
  116. class="lowImportance">[supports C/C++
  117. language]</span></li>
  118. <li><span class="normalImportance">processing time</span>
  119. per file <span class="lowImportance">[supports any
  120. file]</span></li>
  121. </ul>
  122. </li>
  123. <li><h4>Analysis tools</h4>
  124. <ul>
  125. <li><span class="normalImportance">export.py</span> -
  126. exporter to xml, python or plain text of detailed
  127. information per file and/or aggregated information per
  128. file or directory <span
  129. class="lowImportance">[aggregated data includes <span
  130. class="normalImportance">sum</span>, <span
  131. class="normalImportance">maximum</span>, <span
  132. class="normalImportance">minimum</span>, <span
  133. class="normalImportance">average</span> within a subset
  134. of selected files or directories]</span></li>
  135. <li><span class="normalImportance">limit.py</span> - a
  136. tool to report regions exceeding speified thresholds,
  137. which are configurable (output is plain text with
  138. metadata compatible with gcc compiler warning
  139. messages)</li>
  140. </ul>
  141. </li>
  142. </ul>
  143. <h3 id="Download">Download &amp; Installation</h3>
  144. <p>For the installation of the <span
  145. class="normalImportance">Metrix++</span> <a
  146. href="http://sourceforge.net/projects/swi/files/">download</a>
  147. the archive and unpack it to some folder. Also, you have got an
  148. option to get the <a
  149. href="http://swi.svn.sourceforge.net/viewvc/swi/">source
  150. code</a> from the version conrol sytem.</p>
  151. <h4>Prerequisites:</h4>
  152. <p>Python Runtime Environment (version 2.7.0 or later, version
  153. 3.0 has not been tested)</p>
  154. <h4>License:</h4>
  155. <p>This program is free software; you can redistribute it
  156. and/or modify it under the terms of the GNU General Public
  157. License as published by the Free Software Foundation; version 3
  158. of the License.</p>
  159. <p>This program is distributed in the hope that it will be
  160. useful, but WITHOUT ANY WARRANTY; without even the implied
  161. warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  162. PURPOSE. See the GNU General Public License for more
  163. details.</p>
  164. <p>You should have received a copy of the GNU General Public
  165. License along with the <span
  166. class="normalImportance">Metriix++</span>; if not, contact <a
  167. href="mailto:avkonst@users.sourceforge.net">Project
  168. Administrator</a> and write to the Free Software Foundation,
  169. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
  170. USA.</p>
  171. <h3 id="Documentation">Documentation</h3>
  172. <p>Tools are self-descriptive and have got comprehensive
  173. context help. Type in you command line: python
  174. &lt;tool-name&gt;.py --help</p>
  175. <h4>Known Limitations</h4>
  176. <p>Check 'doc/limitations.txt' file distributed with the tool
  177. or browse for recent version <a
  178. href="http://swi.svn.sourceforge.net/viewvc/swi/mainline/doc/limitations.txt">online</a>.</p>
  179. <h4>Basic Workflow</h4>
  180. <p>Assuming that you opened a terminal and your current working
  181. directory is in the root folder of the tool installed.</p>
  182. <p><strong>I.</strong> Start with running a collector tool,
  183. enabling a collection of cyclomatic complexity:</p>
  184. <p><pre>&gt; python <span class="highImportance">collect.py</span> <span class="normalImportance">--std.code.complexity.on</span> -- /path/to/your/project ../../path/to/some/other/project</pre>
  185. </p>
  186. <p>It will generate a database file in working directory with
  187. default name. In order to change the name or location, use
  188. corresponding command line option. Depending on a size of code
  189. base, colection may take seconds or minutes, but it is very
  190. fast in general. In order to achive the highest performance (~
  191. to calculation of crc32) for iterative re-scans, point out to
  192. the dabase file collected for the previous code revision:</p>
  193. <p><pre>&gt; python <span class="highImportance">collect.py</span> --std.code.complexity.on <span class="highImportance normalImportance">--general.db-file-prev=metrixpp-prev.db</span> --
  194. /path/to/your/project</pre>
  195. </p>
  196. <p>Paths are optional. If you do not specify a path, it will
  197. scan files in current working directory. Check other available
  198. options for the tool by executing:</p>
  199. <p><pre>&gt; python <span class="highImportance">collect.py</span> <span class="normalImportance">--help</span></pre>
  200. </p>
  201. <p><strong>II.</strong> Secondly, export data using export
  202. tool.</p>
  203. <p><pre>&gt; python <span class="highImportance">export.py</span> --
  204. <span class="lowImportance">&lt;export&gt;
  205. &lt;data&gt;
  206. &lt;info path="" id="1" /&gt;
  207. &lt;file-data /&gt;
  208. &lt;subfiles&gt;
  209. &lt;/subfiles&gt;
  210. &lt;subdirs&gt;
  211. &lt;subdir&gt;path&lt;/subdir&gt;
  212. &lt;/subdirs&gt;
  213. &lt;aggregated-data&gt;
  214. &lt;<span class="normalImportance">std.code.complexity</span>&gt;
  215. &lt;cyclomatic max="2" total="14.0" avg="0.168674698795" min="0" /&gt;
  216. &lt;/<span class="normalImportance">std.code.complexity</span>&gt;
  217. &lt;<span class="normalImportance">std.code.cpp</span>&gt;
  218. &lt;files max="1" total="4.0" avg="1.0" min="1" /&gt;
  219. &lt;/<span class="normalImportance">std.code.cpp</span>&gt;
  220. &lt;/aggregated-data&gt;
  221. &lt;/data&gt;
  222. &lt;/export&gt;</span>
  223. </pre>
  224. </p>
  225. <p>By default, it exports all aggregated data for all files
  226. scanned in xml format. It is possible to re-configure output
  227. format to python or plain text. In order to narrow the scope,
  228. specify a path to directory or a file. In order to export only
  229. subset of metrics, specify them as well.</p>
  230. <p><pre>&gt; python <span class="highImportance">export.py</span> --general.format=<span class="normalImportance">python</span> --general.namespaces=<span class="normalImportance">std.code.complexity</span> --
  231. <span class="normalImportance">/path/to/your/project/subdir</span>
  232. <span class="lowImportance">&lt;export&gt;
  233. ...
  234. &lt;/export&gt;</span></pre>
  235. </p>
  236. <p>If you have got results collected for previous version,
  237. point out to the file using the corresponding option and the
  238. tool will add diff data.</p>
  239. <p><pre>&gt; python <span class="highImportance">export.py</span> --general.namespaces=<span class="normalImportance">std.code.complexity</span> --general.db-file-prev=<span class="normalImportance">metrixpp-prev.db</span> --
  240. <span class="lowImportance">&lt;export&gt;
  241. &lt;data&gt;
  242. &lt;info path="" id="1" /&gt;
  243. &lt;file-data /&gt;
  244. &lt;subfiles&gt;
  245. &lt;/subfiles&gt;
  246. &lt;subdirs&gt;
  247. &lt;subdir&gt;path&lt;/subdir&gt;
  248. &lt;/subdirs&gt;
  249. &lt;aggregated-data&gt;
  250. &lt;<span class="normalImportance">std.code.complexity</span>&gt;
  251. &lt;cyclomatic max="2" total="14.0" avg="0.168674698795" min="0"&gt;
  252. &lt;<span class="normalImportance">__diff__ max="0" total="0.0" avg="0.0" min="0"</span> /&gt;
  253. &lt;/cyclomatic&gt;
  254. &lt;/<span class="normalImportance">std.code.complexity</span>&gt;
  255. &lt;/aggregated-data&gt;
  256. &lt;/data&gt;
  257. &lt;/export&gt;</span>
  258. </pre>
  259. </p>
  260. <p>Check other available options for the tool by executing:</p>
  261. <p><pre>&gt; python <span class="highImportance">export.py</span> <span class="normalImportance">--help</span></pre>
  262. </p>
  263. <p><strong>III.</strong> Finally, identify code regions which
  264. exceed a specified limit, applying it to all scanned files:</p>
  265. <p><pre>&gt; python <span class="highImportance">limit.py</span> --general.max-limit=<span class="normalImportance">std.code.complexity</span><strong>:</strong><span class="normalImportance">cyclomatic</span><strong>:</strong><span class="normalImportance">7</span><strong> </strong>--
  266. <span class="lowImportance">/path/to/your/project/ui/notifications.cpp:72: warning: Metric '<span class="normalImportance">std.code.complexity</span>/<span class="normalImportance">cyclomatic</span>' for
  267. region 'doFont' exceeds the limit.
  268. Metric name : <span class="normalImportance">std.code.complexity</span>/<span class="normalImportance">cyclomatic</span>
  269. Region name : doFont
  270. Metric value : 10
  271. Modified : None
  272. Change trend : None
  273. Limit : 7
  274. /path/to/your/project/ui/notifications.cpp:144: warning: Metric '<span class="normalImportance">std.code.complexity</span>/<span class="normalImportance">cyclomatic</span>' for
  275. region 'doStyle' exceeds the limit.
  276. Metric name : <span class="normalImportance">std.code.complexity</span>/<span class="normalImportance">cyclomatic</span>
  277. Region name : doStyle
  278. Metric value : 9
  279. Modified : None
  280. Change trend : None
  281. Limit : 7</span></pre>
  282. </p>
  283. <p>You can limit the scope of analysis by defining paths to
  284. directories or files.If you have got results collected for
  285. previous version, point out to the file using the corresponding
  286. option and the tool will notify about change status:</p>
  287. <p><pre>&gt; python <span class="highImportance">limit.py</span> --general.max-limit=std.code.complexity<strong>:</strong>cyclomatic<strong>:</strong>7
  288. --general.db-file-prev=<span class="normalImportance">metrixpp-prev.db</span> --
  289. <span class="lowImportance normalImportance">/path/to/your/project/ui/notifications.cpp:72: warning: Metric 'std.code.complexity/cyclomatic' for
  290. region 'doFont' exceeds the limit.
  291. Metric name : std.code.complexity/cyclomatic
  292. Region name : doFont
  293. Metric value : 10
  294. Modified : <span class="normalImportance">True</span>
  295. Change trend : <span class="normalImportance">0</span>
  296. Limit : 7
  297. /path/to/your/project/ui/notifications.cpp:144: warning: Metric 'std.code.complexity/cyclomatic' for
  298. region 'doStyle' exceeds the limit.
  299. Metric name : std.code.complexity/cyclomatic
  300. Region name : doStyle
  301. Metric value : 9
  302. Modified : <span class="normalImportance">True</span>
  303. Change trend : <span class="normalImportance">+1</span>
  304. Limit : 7</span></pre>
  305. </p>
  306. <p>Another useful option for this tool helps you to <span
  307. class="highImportance">deal with legacy code</span>. It is not
  308. unusual if you have got enormous number of warnings enabling
  309. new thresholds for the code designed in the past, which has not
  310. be profiled/targeted to specific metric limits. By default the
  311. tool warns about all code regions, ignoring their change
  312. status. You can reconfigure it to one of the following:</p>
  313. <ul>
  314. <li>warn only about <span class="normalImportance">new</span>
  315. code regions (functions, classes):</li>
  316. </ul>
  317. <p><pre>&gt; python <span class="highImportance">limit.py</span> --general.max-limit=std.code.complexity<strong>:</strong>cyclomatic<strong>:</strong>7
  318. --general.db-file-prev=metrixpp-prev.db <span class="normalImportance">--general.warn=<strong>new</strong></span> --</pre>
  319. </p>
  320. <ul>
  321. <li>warn about <span class="normalImportance">new</span> code
  322. regions and <span class="normalImportance">modifed regions
  323. <strong>regressing</strong> the metric</span> (enforces the
  324. rule 'leave not worse than it was before'):</li>
  325. </ul>
  326. <p><pre>&gt; python <span class="highImportance">limit.py</span> --general.max-limit=std.code.complexity<strong>:</strong>cyclomatic<strong>:</strong>7
  327. --general.db-file-prev=metrixpp-prev.db <span class="normalImportance">--general.warn=<strong>trend</strong></span> --
  328. <span class="lowImportance normalImportance">/path/to/your/project/ui/notifications.cpp:144: warning: Metric 'std.code.complexity/cyclomatic' for
  329. region 'doStyle' exceeds the limit.
  330. Metric name : std.code.complexity/cyclomatic
  331. Region name : doStyle
  332. Metric value : 9
  333. Modified : <span class="normalImportance">True</span>
  334. Change trend : <span class="normalImportance"><strong>+1</strong></span>
  335. Limit : 7</span></pre>
  336. </p>
  337. <ul>
  338. <li>warn about <span class="normalImportance">new</span> and
  339. <span class="normalImportance">all modified regions</span>
  340. (motivates for refactoring of legacy code): </li>
  341. </ul>
  342. <p><pre>&gt; python <span class="highImportance">limit.py</span> --general.max-limit=std.code.complexity<strong>:</strong>cyclomatic<strong>:</strong>7
  343. --general.db-file-prev=metrixpp-prev.db <span class="normalImportance">--general.warn=<strong>touched</strong></span> --
  344. <span class="lowImportance normalImportance">/path/to/your/project/ui/notifications.cpp:72: warning: Metric 'std.code.complexity/cyclomatic' for
  345. region 'doFont' exceeds the limit.
  346. Metric name : std.code.complexity/cyclomatic
  347. Region name : doFont
  348. Metric value : 10
  349. Modified : <span class="normalImportance"><strong>True</strong></span>
  350. Change trend : <span class="normalImportance">0</span>
  351. Limit : 7
  352. /path/to/your/project/ui/notifications.cpp:144: warning: Metric 'std.code.complexity/cyclomatic' for
  353. region 'doStyle' exceeds the limit.
  354. Metric name : std.code.complexity/cyclomatic
  355. Region name : doStyle
  356. Metric value : 9
  357. Modified : <strong><span class="normalImportance">True</span></strong>
  358. Change trend : <span class="normalImportance">+1</span>
  359. Limit : 7</span></pre>
  360. </p>
  361. <p>Check other available options for the tool by executing:</p>
  362. <p><pre>&gt; python <span class="highImportance">limit.py</span> <span class="normalImportance">--help</span></pre>
  363. </p>
  364. <h3 id="Support">Bug Report &amp; Feature Request</h3>
  365. <p>Any types of enquiries are welcomed by e-mail to <a
  366. href="mailto:avkonst@users.sourceforge.net">project
  367. administrator</a>.</p>
  368. <h3 id="Createplugin">Create Plugin</h3>
  369. <p>Please, consider to join the project and <span
  370. class="normalImportance">contribute to the development</span>
  371. of the engine or <span class="normalImportance">include you
  372. plugins into the standard set</span> of plugins distributed
  373. together with this tool. Contact <a
  374. href="mailto:avkonst@users.sourceforge.net">project
  375. administrator</a> by e-mail.</p>
  376. <h4>New Metric</h4>
  377. <p>Unfortunately, there is no rich documentation at this stage.
  378. Briefly, any new plugin starts with creating 2 new files: 'ini'
  379. and 'py'. You can copy from other avaialble (for example, <a
  380. href="http://swi.svn.sourceforge.net/viewvc/swi/mainline/ext/std/code/complexity.ini">ini</a>
  381. and <a
  382. href="http://swi.svn.sourceforge.net/viewvc/swi/mainline/ext/std/code/complexity.py">py</a>
  383. files for the standard complexity plugin) and impelement the
  384. logic related to the new metric.</p>
  385. <h4>New Analysis Tool</h4>
  386. <p>Unfortunately, there is no rich documentation at this stage.
  387. Briefly, database API (class Loader implemented in '<a
  388. href="http://swi.svn.sourceforge.net/viewvc/swi/mainline/core/db/loader.py">core.db.loader</a>')
  389. is a starting point for any new post-analysis tool. There are 2
  390. standard tools (<a
  391. href="http://swi.svn.sourceforge.net/viewvc/swi/mainline/export.py">export.py</a>
  392. and <a
  393. href="http://swi.svn.sourceforge.net/viewvc/swi/mainline/limit.py">limit.py</a>)
  394. available which use this API.</p>
  395. <h4>New Language Support</h4>
  396. <p>Unfortunately, there is no rich documentation at this stage.
  397. Briefly:</p>
  398. <ul>
  399. <li>a plugin is registered in the same way as a plugin for
  400. new metric</li>
  401. <li>it subscribes to directory reader plugin</li>
  402. <li>parses a file in a callback, called by directory
  403. reader</li>
  404. <li>parser needs to identify markers (like comments, strings,
  405. preprocessor) and regions (like functions, classes, etc.)
  406. and tell about this to file data object passed as an
  407. argument for the callback.</li>
  408. </ul>
  409. <p>Parser for C/C++ language can serve as <a
  410. href="http://swi.svn.sourceforge.net/viewvc/swi/mainline/ext/std/code/cpp.py">an
  411. example</a>.</p>
  412. <p>Finally, if there are any questions or enquires, please,
  413. feel free to contact <a
  414. href="mailto:avkonst@users.sourceforge.net">project
  415. administrator</a> by e-mail.</p>
  416. <h4>Source Code Repository</h4>
  417. <p>Source code is in the Subversion <a
  418. href="http://swi.svn.sourceforge.net/viewvc/swi/mainline/">repository</a>
  419. used by the project.</p>
  420. </td>
  421. </tr>
  422. </tbody>
  423. </table>
  424. <hr />
  425. </td>
  426. </tr>
  427. <tr>
  428. <td colspan="2">
  429. <div align="center">
  430. <p align="right">Copyright <strong>&copy; </strong>2009 - 2013<br />
  431. <a href="mailto:avkonst@users.sourceforge.net"><span
  432. class="normalImportance">Metrix++</span> Project</a></p>
  433. <p align="right">License: <a
  434. href="http://www.gnu.org/licenses/gpl.txt">GPL</a></p>
  435. </div>
  436. </td>
  437. </tr>
  438. </tbody>
  439. </table>
  440. </body>
  441. </html>