177 | | For details, see MetricAnalyserMode. |
| 180 | When in metric analyser mode, the Emacs interface of RefactorErl displays the values of changed metrics after a transformation is invoked. The analyser opens up the Metrics Result buffer, and shows the expected and the current values of the measured metrics for all modules that have at least one metric that is out of bounds as shown in Figure 8. |
| 181 | Values of metrics outside the user defined limits (”bad code smells”) can also be queried manually using Show bad smells in the Semantic query menu. Figure 9 shows the output of this query, which is quite similar to Figure 8; the main difference is that Figure 9 shows all bad metric values, while the other displays only those that are affected by the transformation. |
| 182 | }}} |
| 183 | |
| 184 | The metric analyser mode has to be manually enabled. To learn about the commands please visit the following [ErlangShellInterface#Queryingbadsmells page] . |
| 185 | |
| 186 | When metrics mode is turned on, !RefactorErl initializes the internal metrics representation by creating the necessary tables, and loading them with the available module and function nodes. It also calculates the initial values of the metrics. |
| 187 | |
| 188 | The limits of the metrics can currently be configured by editing the file {{{metricmod.defs}}}. An example of the current format of the file is shown below: |
| 189 | {{{#!erlang |
| 190 | {module_metrics, [{line_of_code,{100,1000}}, |
| 191 | {char_of_code,{100,60000}}, {number_of_fun,{0,10}}, ...]}. |
| 192 | {function_metrics, [{line_of_code,{0,20}}, |
| 193 | {char_of_code,{0,600}}, {function_sum,{0,infty}}, ...]}. |
| 194 | }}} |
| 195 | |
| 196 | The file contains two Erlang terms, one for the module level metrics and another for the function level metrics. The metrics analyser system has built-in defaults; any options given here override the defaults. For a given metric, the lower and upper limits can be given, e.g. the limits on the lines of code in the module are overridden in this file so that they are considered correct only if they are between 100 and 1000. |
| 197 | |
| 198 | For example, the module a has 5 lines of code, which does not fit the arbitrary range 10..20, so module a has bad smell which can be queried. |