Skip to content

Conversation

@calebe-bertoluci
Copy link

@calebe-bertoluci calebe-bertoluci commented Nov 19, 2024

Hello!
I would like to contribute to TinyDB by reducing the cyclomatic complexity of one of its methods.

I used the Codalyze Tool to statically analyze the code, and after extracting the result from all the software, it turns out that the freeze method has the highest cyclomatic complexity in TinyDB.
After the refactoring, it was possible to obtain a score of 6, for 3 points, on a scale of 0 to 10.

I hope you'll consider this change, and I'm excited to contribute to TinyDB.

Codalyze Tool: https://github.com/selcukusta/codalyze-rest-api
Method Tests Passing 100% ✅

@msiemens
Copy link
Owner

msiemens commented Dec 3, 2024

Hey @calebe-bertoluci, thanks for your PR! To be honest, to me the original looks cleaner even though it might have a higher cyclomatic complexity score. It is a simple if-else and not a Python dict that is used as a dispatch table (which is then immediately thrown away). Sure, the disptach table you're proposing has less conditionals, but I'd argue it's harder to understand it compared to the original (it requires recognizing the code pattern in the first place, whereas the if-else is very easy to understand). What do you think?

@msiemens
Copy link
Owner

Closing due to inactivity.

@msiemens msiemens closed this Dec 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants