At this point, you have two different views of the codebase: one that tells you where the complexity is and one that shows individual change frequencies. We will find potential hotspots where the two views intersect.
To merge the two views, we first save the intermediate files to CSV files:
| | prompt> maat -l maat_evo.log -c git -a revisions > maat_freqs.csv |
| | prompt> cloc ./ --unix --by-file --csv --quiet --report-file=maat_lines.csv |
| | ... |
You should now have two CSV files in your code-maat directory: maat_freqs.csv and maat_lines.csv. Because merging them would be tedious (but straightforward!), we’ll use a Python script available from the Code Maat distribution page.[12]
After you’ve downloaded it, run the included scripts/merge_comp_freqs.py script with your two CSV files as input. And remember to prefix the script with the path to your local copy of scripts/merge_comp_freqs.py:
| | prompt> python scripts/merge_comp_freqs.py maat_freqs.csv maat_lines.csv |
| | module,revisions,code |
| | src/code_maat/analysis/logical_coupling.clj,26,145 |
| | src/code_maat/app/app.clj,25,94 |
| | src/code_maat/core.clj,21,49 |
| | test/code_maat/end_to_end/scenario_tests.clj,20,117 |
| | project.clj,19,17 |
| | ... |
The resulting output is sorted on change frequencies first—the best predictor of problems—and size second. That means we get a prioritized list of suspects immediately; our revisions analysis showed that the logical_coupling.clj module changed often. Now we see that it’s complex, too. You’ve found your first hotspot!