Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script interpreter #83

Merged
merged 38 commits into from Jul 7, 2023
Merged

Script interpreter #83

merged 38 commits into from Jul 7, 2023

Conversation

giacomocaironi
Copy link
Member

Draft pull request to add a bitcoin script interpreter to btclib

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 1, 2023

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 3.56 ⭐ 4.31 ⭐ 0.75 👎
Method Length 85.56 🙂 85.25 🙂 -0.31 👍
Working memory 7.73 🙂 8.30 🙂 0.57 👎
Quality 68.91% 🙂 67.68% 🙂 -1.23% 👎
Other metrics Before After Change
Lines 5306 5808 502
Changed files Quality Before Quality After Quality Change
setup.py 75.22% ⭐ 75.22% ⭐ 0.00%
btclib/alias.py 76.12% ⭐ 71.75% 🙂 -4.37% 👎
btclib/hashes.py 86.27% ⭐ 86.92% ⭐ 0.65% 👍
btclib/ecc/der.py 71.88% 🙂 70.80% 🙂 -1.08% 👎
btclib/ecc/libsecp256k1.py 96.02% ⭐ 96.02% ⭐ 0.00%
btclib/psbt/psbt.py 60.47% 🙂 60.43% 🙂 -0.04% 👎
btclib/psbt/psbt_in.py 57.36% 🙂 49.27% 😞 -8.09% 👎
btclib/psbt/psbt_out.py 75.62% ⭐ 64.77% 🙂 -10.85% 👎
btclib/psbt/psbt_utils.py 82.76% ⭐ 84.31% ⭐ 1.55% 👍
btclib/script/script.py 64.74% 🙂 65.08% 🙂 0.34% 👍
btclib/script/script_pub_key.py 77.92% ⭐ 78.13% ⭐ 0.21% 👍
btclib/script/sig_hash.py 44.39% 😞 42.89% 😞 -1.50% 👎
btclib/script/taproot.py 61.72% 🙂 52.96% 🙂 -8.76% 👎
btclib/tx/tx.py 80.89% ⭐ 75.96% ⭐ -4.93% 👎
tests/test_b32.py 80.10% ⭐ 80.10% ⭐ 0.00%
tests/test_b58.py 69.42% 🙂 69.41% 🙂 -0.01% 👎
tests/psbt/test_psbt.py 73.99% 🙂 73.37% 🙂 -0.62% 👎
tests/script/test_script.py 83.21% ⭐ 82.66% ⭐ -0.55% 👎
tests/script/test_script_pub_key.py 69.32% 🙂 69.32% 🙂 0.00%
tests/script/test_sig_hash_taproot.py 56.57% 🙂 56.57% 🙂 0.00%
tests/script/test_taproot.py 75.21% ⭐ 78.70% ⭐ 3.49% 👍
tests/tx/test_tx.py 60.25% 🙂 60.00% 🙂 -0.25% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
btclib/psbt/psbt_in.py PsbtIn.parse 22 😞 395 ⛔ 45 ⛔ 15.52% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
btclib/script/taproot.py parse 33 ⛔ 186 😞 14 😞 27.66% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
btclib/script/sig_hash.py taproot 13 🙂 333 ⛔ 18 ⛔ 29.04% 😞 Try splitting into smaller methods. Extract out complex expressions
btclib/script/script.py parse 27 😞 155 😞 14 😞 33.47% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
btclib/script/sig_hash.py legacy 19 😞 257 ⛔ 12 😞 34.12% 😞 Refactor to reduce nesting. Try splitting into smaller methods. 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!

Help us improve this quality report!

@giacomocaironi giacomocaironi force-pushed the script_engine branch 2 times, most recently from 28de763 to cfa289c Compare June 30, 2023 16:06
@giacomocaironi giacomocaironi force-pushed the script_engine branch 4 times, most recently from 3519fae to c4c85d0 Compare July 1, 2023 10:27
@fametrano fametrano marked this pull request as ready for review July 7, 2023 19:24
@fametrano fametrano marked this pull request as draft July 7, 2023 23:00
@fametrano fametrano marked this pull request as ready for review July 7, 2023 23:01
@fametrano fametrano merged commit 9670368 into master Jul 7, 2023
48 checks passed
@fametrano fametrano deleted the script_engine branch July 7, 2023 23:58
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.

None yet

2 participants