-
Notifications
You must be signed in to change notification settings - Fork 1
Sourcery refactored master branch #3
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
base: master
Are you sure you want to change the base?
Conversation
| 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 |
There was a problem hiding this comment.
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:
- Merge nested if conditions (
merge-nested-ifs)
| 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)) |
There was a problem hiding this comment.
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:
- Swap if/else branches (
swap-if-else-branches) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif)
| 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 | ||
| ) | ||
|
|
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| return False | ||
|
|
||
| return True | ||
| return not any(fnmatch.fnmatch(filename, glob) for glob in globs) |
There was a problem hiding this comment.
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)
| elif filename in svnignore_data: | ||
| continue | ||
| else: | ||
| if filename in svnignore_data: | ||
| continue |
There was a problem hiding this comment.
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:
- Lift code into else after jump in control flow (
reintroduce-else) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif)
| 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 |
There was a problem hiding this comment.
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:
- Replace if statement with if expression (
assign-if-exp)
d1178d7 to
69b9be6
Compare
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.02%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe 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! |
Branch
masterrefactored 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
masterbranch, then run:Help us improve this pull request!