rec / safer

๐Ÿงท A safer writer ๐Ÿงท
https://rec.github.io/safer/
MIT License
174 stars 10 forks source link

tidy for 3.5, 3.6+ python (Sourcery refactored) #19

Closed sourcery-ai[bot] closed 9 months ago

sourcery-ai[bot] commented 1 year ago

Pull Request #18 refactored by Sourcery.

Since the original Pull Request was opened as a fork in a contributor's repository, we are unable to create a Pull Request branching from it.

To incorporate these changes, you can either:

  1. Merge this Pull Request instead of the original, or

  2. Ask your contributor to locally incorporate these commits and push them to the original Pull Request

    Incorporate changes via command line
    git fetch https://github.com/rec/safer pull/18/head
    git merge --ff-only FETCH_HEAD
    git push

NOTE: As code is pushed to the original Pull Request, Sourcery will re-run and update (force-push) this Pull Request with new refactorings as necessary. If Sourcery finds no refactorings at any point, this Pull Request will be closed automatically.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Help us improve this pull request!

sourcery-ai[bot] commented 1 year ago

Sourcery Code Quality Report

โŒ  Merging this PR will decrease code quality in the affected files by 0.10%.

Quality metrics Before After Change
Complexity 4.93 โญ 4.95 โญ 0.02 ๐Ÿ‘Ž
Method Length 52.38 โญ 52.32 โญ -0.06 ๐Ÿ‘
Working memory 4.85 โญ 4.87 โญ 0.02 ๐Ÿ‘Ž
Quality 77.20% โญ 77.10% โญ -0.10% ๐Ÿ‘Ž
Other metrics Before After Change
Lines 1373 1403 30
Changed files Quality Before Quality After Quality Change
safer.py 55.77% ๐Ÿ™‚ 55.31% ๐Ÿ™‚ -0.46% ๐Ÿ‘Ž
setup.py 87.94% โญ 87.94% โญ 0.00%
test/get_help.py 93.32% โญ 93.32% โญ 0.00%
test/test_doc.py 92.21% โญ 92.29% โญ 0.08% ๐Ÿ‘
test/test_dump.py 89.39% โญ 89.39% โญ 0.00%
test/test_files.py 88.22% โญ 88.20% โญ -0.02% ๐Ÿ‘Ž
test/test_open.py 82.01% โญ 82.01% โญ 0.00%
test/test_printer.py 84.18% โญ 84.18% โญ 0.00%
test/test_writer.py 89.08% โญ 89.12% โญ 0.04% ๐Ÿ‘

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

File Function Complexity Length Working Memory Quality Recommendation
safer.py open 32 ๐Ÿ˜ž 329 โ›” 16.74% โ›” Refactor to reduce nesting. Try splitting into smaller methods
safer.py writer 28 ๐Ÿ˜ž 230 โ›” 14 ๐Ÿ˜ž 26.91% ๐Ÿ˜ž Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
safer.py dump 24 ๐Ÿ˜ž 183 ๐Ÿ˜ž 9 ๐Ÿ™‚ 41.27% ๐Ÿ˜ž Refactor to reduce nesting. Try splitting into smaller methods
test/test_open.py TestSafer.test_two_errors 5 โญ 222 โ›” 8 ๐Ÿ™‚ 56.18% ๐Ÿ™‚ Try splitting into smaller methods
safer.py _FileCloser._make_stream 7 โญ 137 ๐Ÿ˜ž 8 ๐Ÿ™‚ 61.72% ๐Ÿ™‚ Try splitting into smaller methods

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!