Skip to content

Conversation

@orientalperil
Copy link

This can go wrong if you use a list to store validators. With shallow copy the validators list is maintained even if a new request is being processed. The result is that the validators list grows larger with every request. This is especially bad with UniqueValidator because old sessions get stuck in the list and you will get SQLAlchemy transaction errors like sqlalchemy.exc.StatementError: (sqlalchemy.exc.InvalidRequestError) Can't reconnect until invalid transaction is rolled back

@sourcery-ai
Copy link

sourcery-ai bot commented Apr 30, 2021

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.01%.

Quality metrics Before After Change
Complexity 8.23 ⭐ 8.23 ⭐ 0.00
Method Length 58.00 ⭐ 58.02 ⭐ 0.02 👎
Working memory 10.55 😞 10.55 😞 0.00
Quality 64.46% 🙂 64.45% 🙂 -0.01% 👎
Other metrics Before After Change
Lines 784 784 0
Changed files Quality Before Quality After Quality Change
rest_witchcraft/serializers.py 64.46% 🙂 64.45% 🙂 -0.01% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
rest_witchcraft/serializers.py ModelSerializer.perform_update 43 ⛔ 190 😞 17 ⛔ 20.57% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
rest_witchcraft/serializers.py ModelSerializer.get_field_names 17 🙂 191 😞 13 😞 38.24% 😞 Try splitting into smaller methods. Extract out complex expressions
rest_witchcraft/serializers.py BaseSerializer.build_standard_field_kwargs 11 🙂 140 😞 19 ⛔ 41.78% 😞 Try splitting into smaller methods. Extract out complex expressions
rest_witchcraft/serializers.py ModelSerializer.build_nested_field 6 ⭐ 145 😞 14 😞 50.91% 🙂 Try splitting into smaller methods. Extract out complex expressions
rest_witchcraft/serializers.py ExpandableModelSerializer.to_representation 4 ⭐ 91 🙂 22 ⛔ 52.92% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

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.

1 participant