Monday, May 22, 2017

RBTLIB v0.3 Update (Part 2)

In RBTLIB v0.3 Update (Part 1) I discussed some plans for posting review requests to a Review Board instance using RBTLIB. During the development I added a complexity measure to the project.  I was intrigued by how complexity measures were used in a talk by Sandi Metz.  Sandi's talk is on Ruby.  I'm using Python.

I found two Python modules: radon and xenon that compute cyclomatic complexity. Radon computes several measures and xenon provides a way to add complexity measures to a continuous integration.

To measure the entire project, including test code from the project's root directory:
radon cc -e "ven/*" -as .
The core abstraction in RBTLIB at this point is still the Composite design pattern.
This component has the highest complexity:

rbtlib/resource/composite.py
    M 41:4 Composite.href_component - B (6)
    M 63:4 Composite.component - B (6)
    C 31:0 Composite - A (4)
    M 53:4 Composite.list_component - A (4)
    M 34:4 Composite.__init__ - A (1)

From the radon documents:

M - Module
C - Class

A - low - simple block
B - low - well structured and stable block

Overall complexity of the project thus far:

72 blocks (classes, functions, methods) analyzed.
Average complexity: A (1.88888888889)

So far, complexity doesn't appear to be a problem.

No comments:

Post a Comment