tonybaloney / wily

A Python application for tracking, reporting on timing and complexity in Python code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: Measure metrics on a sub-file basis.

Chris-May opened this issue · comments

Thank you so much for this tool! It's a great idea! You had such a great idea accumulating stats over git commits.

I want to open a discussion to have metrics measured on a finer scale.

After working with some team members to refactor code in a file, several of our wily metrics worsened. This surprised us, so I ran the file through Radon with its function-level reporting, and we could see that while some aggregated file-level metrics were worse, the individual functions were a dramatic improvement.

I've debated requesting this, as I'm sure it adds significant complexity, but I thought the increased resolution into our code bases would help us make better decisions.

Thanks for the feature request!

What metrics would you be interested in having per-function reporting on? Good news is I already have code for collecting per-function metrics with wily, adding support for Halstead and Raw.

There's an example of more granular metrics and a web visualization here: https://devdanzin.github.io/black/annotated_src.black.comments.py.html (click "Toggle" to cycle between per-function Cyclomatic, Halstead and Raw metrics).

IIRC, there's no text output for these per-function metrics yet (I think I only added output to the web view), but it should be easy to implement. I haven't touched this code in a while, but I'd be glad to finish it and land the feature you need.

I can't promise this will be done quickly, as I'm swamped with work, but I should be able to give you some code for testing right before or during the weekend.

Thanks for your reply!

That's a nice concept for per-function metrics. Could I use that in a user group to help explain these metrics?

Not being an expert on the material, there are four metrics I gravitate to and would like to see on a per-function basis:

  • cyclomatic complexity
  • difficulty
  • effort
  • maintainability index