#Halstead

David Anthonytheactivistuk
2024-06-22
danzindanzin
2024-01-05

So I've created a report for one thousand Black (the Python formatter) commits.

You can see that there was a huge (and complex), 7k lines __init__.py that got broken up around May 2021.

There's a trend of increasing LOC and complexity.

This report shows me there's a lot to improve in wily's code. Hopefully I'm back at that.

@hugovk @ambv

devdanzin.github.io/black/

danzindanzin
2023-10-29

Adding JSON support for : now the results of diff, index, rank and report can be output as JSON.

If you can help with code review or tips on how to improve the output, I'm open to all suggestions.

Wily is a CLI application for tracking, reporting on complexity of Python code. It uses git to go through each revision and run complexity and code-analysis metrics over the code.

github.com/tonybaloney/wily/pu

danzindanzin
2023-09-21

Mike Driscoll: Learning About Code Metrics in with Radon

Nice introduction to :

"""
You can use Radon to help you find complex code in your code base.
[...]
Here are the four commands that radon currently can use:

cc: compute
raw: compute raw metrics
mi: compute Index
hal: compute complexity metrics
[...]
"""

blog.pythonlibrary.org/2023/09

danzindanzin
2023-09-02

At last, submitted a proposal for a source code annotator for , by @tonybaloney.

It allows inline visualization of code metrics in source code, inspired by @coveragepy

Uses to calculate and metrics, then adds color coded metric values to a highlighted source listing and allows changing the metrics for visualization.

The code works, there are screenshots and an example in the linked issue.

github.com/tonybaloney/wily/is

danzindanzin
2023-08-24

Today I wrote some trivial code to convert .gitignore rules to exclude/ignore patterns. It turns out it was completely unnecessary for our project (), because we already pass a tight list of targets for radon to scan.

But it might be useful for upstream radon users, as an option to gather exclude/ignore rules from .gitignore. So I'll propose that as a new feature and see how it goes.

github.com/rubik/radon

danzindanzin
2023-08-22

Proposed 2 simple PRs to , adding class names to method names in Halstead reports. A third is in the works, adding line numbers to metrics.

"Radon is a tool that computes various metrics from the source code. Radon can compute:

's complexity, i.e.

raw metrics (these include SLOC, comment lines, blank lines, &c.)

Halstead metrics (all of them)

Index (the one used in Visual Studio)"

github.com/rubik/radon

danzindanzin
2023-08-20

Working on a source code annotator for , which uses to calculate and metrics. It adds metric values to a highlighted source listing and allows changing the metrics for visualization.

Because radon doesn't record line numbers for Halstead metrics, we do a little song and dance to add them. Will probably offer a patch to include them upstream.

🐍

devdanzin.github.io/wily/annot

danzindanzin
2023-08-09

Some more code quality visualization improvements for : it's now possible to annotate source code with metrics ( was already working) and select which one to display and use to color code blocks.

See a sample report here: devdanzin.github.io/wily/ (click the filenames for the annotated source code).

Code for the annotator currently lives at github.com/devdanzin/wily/tree, I hope to submit it for upstreaming soon-ish.

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst