Skip to content

Commit 0426540

Browse files
docs: writeup cc for solve_constraints (#11)
1 parent d29a436 commit 0426540

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

report.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,26 @@ for each project, along with reason(s) why you changed to a different one.
3232
4. Are exceptions taken into account in the given measurements?
3333
5. Is the documentation clear w.r.t. all the possible outcomes?
3434

35+
### `solve_constraints@mypy/solve.py`
36+
Lizard's output for `solve_constraints` in `mypy/solve.py` is as follows:
37+
```
38+
NLOC CCN token PARAM length location
39+
------------------------------------------------
40+
57 30 423 5 86 solve_constraints@41-126@mypy/solve.py
41+
```
42+
43+
By manually counting the number of `if`, `for` and `else` statements we got a CC of **18**, not matching the 30 reported by Lizard. The difference lies in logical clauses and list comprehensions, which were initially overlooked.
44+
45+
With counting each logical clause (e.g., `and`, `or`) as well as the `for` and `if` statements inside of comprehensions, we arrive at a CC of **30**, matching Lizard's output.
46+
47+
This function in particular is just complex, but not aggressively long. Although 57 lines of code is at the upper end of what should be considered acceptable. Further this function in particular clearly has a lot of different responsibilities (handling three separate boolean flags), which could be a sign that it is possible to reduce its complexity by refactoring those out as separate handlers.
48+
49+
The purpose of the function in to solve type constraints for type variables in the checked program. Which is a core part of the type checking process.
50+
51+
There are no exceptions raised in this function, so they are not taken into account.
52+
53+
The documentation for the function is not very clear. The code is somewhat descriptive but lacks a lot of comments given its complexity and the docstring only gives a very high-level overview. I also feel that the naming of a lot of stuff may be a little to generic, there is a lot of `solve_x`.
54+
3555
## Refactoring
3656

3757
Plan for refactoring complex code:

0 commit comments

Comments
 (0)