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

Sourcery refactored master branch #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Oct 6, 2022

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

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

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from synodriver October 6, 2022 05:37
if (msg == constants.UCM_NEEDPASSWORD or
msg == constants.UCM_NEEDPASSWORDW):
if msg in [constants.UCM_NEEDPASSWORD, constants.UCM_NEEDPASSWORDW]:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _ReadIntoMemory._callback refactored with the following changes:

Comment on lines -172 to -177
rarinfo = self._read_header(handle)
while rarinfo:
while rarinfo := self._read_header(handle):
self.filelist.append(rarinfo)
self.NameToInfo[rarinfo.filename] = rarinfo
self._process_current(handle, constants.RAR_SKIP)
rarinfo = self._read_header(handle)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RarFile._load_metadata refactored with the following changes:

Comment on lines -239 to +236
raise BadRarFile("Bad RAR archive data: %s" % str(e))
raise BadRarFile(f"Bad RAR archive data: {str(e)}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RarFile.open refactored with the following changes:

Comment on lines -255 to +252
names = []
for member in self.filelist:
names.append(member.filename)
return names
return [member.filename for member in self.filelist]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RarFile.namelist refactored with the following changes:

Comment on lines -359 to +353
raise BadRarFile("Bad RAR archive data: %s" % str(e))
raise BadRarFile(f"Bad RAR archive data: {str(e)}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RarFile._extract_members refactored with the following changes:

Comment on lines -389 to +383
err = rf.testrar()
if err:
if err := rf.testrar():
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

lib_path = lib_path or find_library("unrar.dll")
if lib_path:
if lib_path := lib_path or find_library("unrar.dll"):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 44-67 refactored with the following changes:

Comment on lines -152 to +150
res.append('%s=%s' % (field[0], field_value))
return self.__class__.__name__ + '(' + ','.join(res) + ')'
res.append(f'{field[0]}={field_value}')
return f'{self.__class__.__name__}(' + ','.join(res) + ')'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _Structure.__repr__ refactored with the following changes:

rar = RarFile(rar_filename)
return rar
return RarFile(rar_filename)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TestRarFile._open_rarfile refactored with the following changes:

Comment on lines -119 to +118
rar = RarFile(rar_filename, pwd='password')
return rar
return RarFile(rar_filename, pwd='password')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TestPasswordRarFile._open_rarfile refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Oct 6, 2022

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 5.15 ⭐ 5.14 ⭐ -0.01 👍
Method Length 49.25 ⭐ 48.93 ⭐ -0.32 👍
Working memory 7.28 🙂 7.38 🙂 0.10 👎
Quality 73.85% 🙂 73.66% 🙂 -0.19% 👎
Other metrics Before After Change
Lines 708 696 -12
Changed files Quality Before Quality After Quality Change
unrar/rarfile.py 72.74% 🙂 72.25% 🙂 -0.49% 👎
unrar/unrarlib.py 61.49% 🙂 61.75% 🙂 0.26% 👍
unrar/tests/test_rarfile.py 94.77% ⭐ 94.74% ⭐ -0.03% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
unrar/unrarlib.py _check_readheader_result 17 🙂 172 😞 19 ⛔ 33.47% 😞 Try splitting into smaller methods. Extract out complex expressions
unrar/unrarlib.py _check_process_result 17 🙂 172 😞 19 ⛔ 33.47% 😞 Try splitting into smaller methods. Extract out complex expressions
unrar/rarfile.py RarFile.open 16 🙂 203 😞 9 🙂 45.37% 😞 Try splitting into smaller methods
unrar/rarfile.py main 10 🙂 145 😞 9 🙂 55.81% 🙂 Try splitting into smaller methods
unrar/rarfile.py RarFile._extract_members 10 🙂 143 😞 8 🙂 58.24% 🙂 Try splitting into smaller methods

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!

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.

0 participants