Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Jun 24, 2021

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 tschutter June 24, 2021 23:26
Comment on lines -139 to +143
if os.path.isdir(link_pathname):
if not os.listdir(link_pathname):
print("Removing empty directory '{0}'.".format(link_pathname))
if not args.dryrun:
os.rmdir(link_pathname)
return
if os.path.isdir(link_pathname) and not os.listdir(link_pathname):
print("Removing empty directory '{0}'.".format(link_pathname))
if not args.dryrun:
os.rmdir(link_pathname)
return
Copy link
Author

Choose a reason for hiding this comment

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

Function clean_link refactored with the following changes:

Comment on lines -555 to +559
if output.find("does not exist on channel") != -1:
if args.verbose:
print("Key binding '{0}' already removed.".format(binding))
else:
if output.find("does not exist on channel") == -1:
print("Removing key binding '{0}'.".format(binding))
run_command(args, cmdargs + ["--reset"])

elif args.verbose:
print("Key binding '{0}' already removed.".format(binding))
Copy link
Author

Choose a reason for hiding this comment

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

Function xfwm4_remove_key_binding refactored with the following changes:

Comment on lines -853 to 854
args.is_xwindows = (
exe_in_path("xterm") and
not (args.is_cygwin or args.is_windows)
exe_in_path("xterm") and not args.is_cygwin and not args.is_windows
)

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:

  • Simplify logical expression using De Morgan identities (de-morgan)

"""
pathname = os.path.join(xdg_cache_home, "python", "history")
return pathname
return os.path.join(xdg_cache_home, "python", "history")
Copy link
Author

Choose a reason for hiding this comment

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

Function _history_pathname refactored with the following changes:

return False

return True
return not any(fnmatch.fnmatch(filename, glob) for glob in globs)
Copy link
Author

Choose a reason for hiding this comment

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

Function ignore_file refactored with the following changes:

  • Use any() instead of for loop (use-any)

Comment on lines +73 to -75
elif filename in svnignore_data:
continue
else:
if filename in svnignore_data:
continue
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:

Comment on lines -69 to +76
if arg == "-":
text = sys.stdin.read()
else:
text = open(arg, "rb").read()
text = sys.stdin.read() if arg == "-" else open(arg, "rb").read()
utext = text.decode("utf8")
utext = unicodedata.normalize("NFKD", utext)
utext = utext.translate(XTABLE)
try:
utext.encode("ascii", "strict")
except UnicodeEncodeError as err:
if arg == "-":
errfile = ""
else:
errfile = "In '%s', " % arg
errfile = "" if arg == "-" else "In '%s', " % arg
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:

@sourcery-ai sourcery-ai bot force-pushed the sourcery/master branch from d1178d7 to 69b9be6 Compare June 24, 2021 23:26
@sourcery-ai
Copy link
Author

sourcery-ai bot commented Jun 24, 2021

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 11.89 🙂 11.53 🙂 -0.36 👍
Method Length 81.16 🙂 81.00 🙂 -0.16 👍
Working memory 7.93 🙂 8.01 🙂 0.08 👎
Quality 59.86% 🙂 59.84% 🙂 -0.02% 👎
Other metrics Before After Change
Lines 1203 1191 -12
Changed files Quality Before Quality After Quality Change
install.py 57.41% 🙂 57.66% 🙂 0.25% 👍
pythonstartup.py 92.12% ⭐ 91.83% ⭐ -0.29% 👎
bin/find-non-ascii 51.81% 🙂 49.68% 😞 -2.13% 👎
bin/svn-ignore 73.04% 🙂 74.50% 🙂 1.46% 👍
bin/unicode2ascii 68.72% 🙂 69.44% 🙂 0.72% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
bin/find-non-ascii find_files 58 ⛔ 173 😞 12 😞 25.68% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
install.py make_link 24 😞 196 😞 13 😞 32.95% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
install.py install_fonts 15 🙂 191 😞 13 😞 39.84% 😞 Try splitting into smaller methods. Extract out complex expressions
install.py link_dotfiles 12 🙂 691 ⛔ 8 🙂 42.57% 😞 Try splitting into smaller methods
install.py clean_link 24 😞 137 😞 10 😞 43.79% 😞 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!

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