btclib-org / btclib

btclib: a python3 library for 'bitcoin cryptography'
https://btclib.org
MIT License
97 stars 42 forks source link

exported names per module, improved typing, refactored GitHub actions #82

Closed fametrano closed 1 year ago

fametrano commented 1 year ago
sourcery-ai[bot] commented 1 year ago

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.35%.

Quality metrics Before After Change
Complexity 4.44 ⭐ 4.29 ⭐ -0.15 👍
Method Length 99.71 🙂 95.84 🙂 -3.87 👍
Working memory 8.84 🙂 9.13 🙂 0.29 👎
Quality 63.94% 🙂 64.29% 🙂 0.35% 👍
Other metrics Before After Change
Lines 17692 14727 -2965
Changed files Quality Before Quality After Quality Change
setup.py 75.22% ⭐ 74.73% 🙂 -0.49% 👎
btclib/alias.py 76.12% ⭐ 75.39% ⭐ -0.73% 👎
btclib/b32.py 72.64% 🙂 72.96% 🙂 0.32% 👍
btclib/b58.py 85.03% ⭐ 85.03% ⭐ 0.00%
btclib/base58.py 77.28% ⭐ 77.85% ⭐ 0.57% 👍
btclib/bech32.py 75.64% ⭐ 75.87% ⭐ 0.23% 👍
btclib/hashes.py 86.27% ⭐ 86.22% ⭐ -0.05% 👎
btclib/network.py 73.19% 🙂 72.56% 🙂 -0.63% 👎
btclib/to_prv_key.py 59.09% 🙂 61.98% 🙂 2.89% 👍
btclib/to_pub_key.py 67.49% 🙂 70.80% 🙂 3.31% 👍
btclib/utils.py 82.03% ⭐ 82.00% ⭐ -0.03% 👎
btclib/bip32/__init__.py % 73.91% 🙂 %
btclib/bip32/bip32.py 61.34% 🙂 65.53% 🙂 4.19% 👍
btclib/bip32/der_path.py 80.11% ⭐ 79.93% ⭐ -0.18% 👎
btclib/bip32/slip132.py 82.22% ⭐ 81.89% ⭐ -0.33% 👎
btclib/ecc/__init__.py % 99.17% ⭐ %
btclib/ecc/bms.py 62.98% 🙂 62.99% 🙂 0.01% 👍
btclib/ecc/borromean.py 40.56% 😞 40.53% 😞 -0.03% 👎
btclib/ecc/dh.py 67.59% 🙂 67.59% 🙂 0.00%
btclib/ecc/dsa.py 64.55% 🙂 66.98% 🙂 2.43% 👍
btclib/ecc/pedersen.py 81.79% ⭐ 81.79% ⭐ 0.00%
btclib/ecc/rfc6979.py 57.55% 🙂 57.55% 🙂 0.00%
btclib/ecc/sign_to_contract.py 74.67% 🙂 74.67% 🙂 0.00%
btclib/ecc/ssa.py 66.86% 🙂 67.76% 🙂 0.90% 👍
btclib/mnemonic/__init__.py % 67.67% 🙂 %
btclib/mnemonic/bip39.py 81.43% ⭐ 81.39% ⭐ -0.04% 👎
btclib/mnemonic/electrum.py 74.48% 🙂 74.46% 🙂 -0.02% 👎
btclib/mnemonic/entropy.py 62.82% 🙂 62.69% 🙂 -0.13% 👎
btclib/mnemonic/mnemonic.py 76.85% ⭐ 81.95% ⭐ 5.10% 👍
btclib/psbt/__init__.py % 80.59% ⭐ %
btclib/psbt/psbt.py 60.47% 🙂 60.33% 🙂 -0.14% 👎
btclib/psbt/psbt_in.py 57.36% 🙂 57.40% 🙂 0.04% 👍
btclib/psbt/psbt_out.py 75.62% ⭐ 75.64% ⭐ 0.02% 👍
btclib/psbt/psbt_utils.py 82.76% ⭐ 82.76% ⭐ 0.00%
btclib/script/__init__.py % 53.98% 🙂 %
btclib/script/script.py 64.74% 🙂 65.67% 🙂 0.93% 👍
btclib/script/script_pub_key.py 77.92% ⭐ 77.97% ⭐ 0.05% 👍
btclib/script/sig_hash.py 44.39% 😞 48.74% 😞 4.35% 👍
btclib/script/taproot.py 61.72% 🙂 65.00% 🙂 3.28% 👍
btclib/tx/__init__.py % 94.23% ⭐ %
btclib/tx/tx.py 80.89% ⭐ 80.89% ⭐ 0.00%
btclib/tx/tx_in.py 88.00% ⭐ 88.00% ⭐ 0.00%
tests/test_amount.py 78.45% ⭐ 78.97% ⭐ 0.52% 👍
tests/test_b32.py 80.10% ⭐ 80.08% ⭐ -0.02% 👎
tests/test_b58.py 69.42% 🙂 69.38% 🙂 -0.04% 👎
tests/test_bech32.py 74.10% 🙂 73.46% 🙂 -0.64% 👎
tests/test_network.py 87.70% ⭐ 87.66% ⭐ -0.04% 👎
tests/test_to_key.py 28.04% 😞 28.04% 😞 0.00%
tests/test_to_prv_key.py 47.54% 😞 47.54% 😞 0.00%
tests/test_to_pub_key.py 43.25% 😞 43.25% 😞 0.00%
tests/test_utils.py 80.16% ⭐ 80.12% ⭐ -0.04% 👎
tests/bip32/test_bip32.py 66.69% 🙂 66.69% 🙂 0.00%
tests/bip32/test_der_path.py 73.75% 🙂 73.74% 🙂 -0.01% 👎
tests/bip32/test_key_origin.py 68.85% 🙂 68.85% 🙂 0.00%
tests/ecc/test_bms.py 55.01% 🙂 55.00% 🙂 -0.01% 👎
tests/ecc/test_borromean.py 60.07% 🙂 60.07% 🙂 0.00%
tests/ecc/test_der.py 62.88% 🙂 62.89% 🙂 0.01% 👍
tests/ecc/test_dh.py 57.09% 🙂 57.09% 🙂 0.00%
tests/ecc/test_dsa.py 55.40% 🙂 55.37% 🙂 -0.03% 👎
tests/ecc/test_pedersen.py 75.05% ⭐ 74.94% 🙂 -0.11% 👎
tests/ecc/test_rfc6979.py 63.41% 🙂 63.42% 🙂 0.01% 👍
tests/ecc/test_sign_to_contract.py 62.50% 🙂 62.47% 🙂 -0.03% 👎
tests/ecc/test_ssa.py 30.34% 😞 30.98% 😞 0.64% 👍
tests/mnemonic/test_bip39.py 76.78% ⭐ 76.73% ⭐ -0.05% 👎
tests/mnemonic/test_entropy.py 62.81% 🙂 62.65% 🙂 -0.16% 👎
tests/mnemonic/test_mnemonic.py 84.40% ⭐ 84.46% ⭐ 0.06% 👍
tests/psbt/test_psbt.py 73.99% 🙂 74.01% 🙂 0.02% 👍
tests/psbt/test_psbt_in.py 80.73% ⭐ 80.68% ⭐ -0.05% 👎
tests/psbt/test_psbt_out.py 77.52% ⭐ 77.49% ⭐ -0.03% 👎
tests/psbt/test_psbt_utils.py 98.63% ⭐ 98.71% ⭐ 0.08% 👍
tests/script/test_script.py 83.21% ⭐ 83.24% ⭐ 0.03% 👍
tests/script/test_script_pub_key.py 69.32% 🙂 69.32% 🙂 0.00%
tests/script/test_sig_hash_legacy.py 73.66% 🙂 73.66% 🙂 0.00%
tests/script/test_sig_hash_segwitv0.py 74.40% 🙂 74.40% 🙂 0.00%
tests/script/test_sig_hash_taproot.py 56.57% 🙂 56.62% 🙂 0.05% 👍
tests/script/test_taproot.py 75.21% ⭐ 75.47% ⭐ 0.26% 👍
tests/script/test_witness.py 76.88% ⭐ 76.89% ⭐ 0.01% 👍
tests/tx/test_out_point.py 76.53% ⭐ 76.50% ⭐ -0.03% 👎
tests/tx/test_tx.py 60.25% 🙂 60.25% 🙂 0.00%
tests/tx/test_tx_in.py 59.55% 🙂 59.68% 🙂 0.13% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
tests/ecc/test_ssa.py test_threshold 31 😞 1871 ⛔ 33 ⛔ 9.52% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
btclib/ecc/borromean.py sign 18 🙂 361 ⛔ 20 ⛔ 22.96% ⛔ Try splitting into smaller methods. Extract out complex expressions
btclib/psbt/psbt_in.py PsbtIn.parse 16 🙂 280 ⛔ 32 ⛔ 23.29% ⛔ Try splitting into smaller methods. Extract out complex expressions
btclib/script/sig_hash.py taproot 13 🙂 314 ⛔ 18 ⛔ 29.54% 😞 Try splitting into smaller methods. Extract out complex expressions
tests/ecc/test_ssa.py test_low_cardinality 23 😞 248 ⛔ 13 😞 30.25% 😞 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:

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!