Skip to content

Sourcery refactored main branch#1

Open
sourcery-ai[bot] wants to merge 1 commit intomainfrom
sourcery/main
Open

Sourcery refactored main branch#1
sourcery-ai[bot] wants to merge 1 commit intomainfrom
sourcery/main

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Jan 30, 2022

Branch main 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 main branch, then run:

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

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from Mesteriis January 30, 2022 09:47
Comment on lines +57 to +64
elif job.pid is None:
print("'%s' is loaded but not currently running" % (job.label)) # noqa: T001
else:
if job.pid is None:
print("'%s' is loaded but not currently running" % (job.label)) # noqa: T001
else:
print("'%s' is loaded and currently running: PID = %s" % (job.label, job.pid)) # noqa: T001
while job.pid is not None:
print("Alive! PID = %s" % job.pid) # noqa: T001
job.refresh()
time.sleep(0.2)
print("'%s' is loaded and currently running: PID = %s" % (job.label, job.pid)) # noqa: T001
while job.pid is not None:
print("Alive! PID = %s" % job.pid) # noqa: T001
job.refresh()
time.sleep(0.2)
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 -39 to +40
v = open(os.path.join(os.path.dirname(__file__), "launchd", "__init__.py"))
VERSION = re.compile(r".*__version__ = \"(.*?)\"", re.S).match(v.read()).group(1)
v.close()
with open(os.path.join(os.path.dirname(__file__), "launchd", "__init__.py")) as v:
VERSION = re.compile(r".*__version__ = \"(.*?)\"", re.S).match(v.read()).group(1)
Copy link
Author

Choose a reason for hiding this comment

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

Lines 39-41 refactored with the following changes:

Comment on lines -21 to +26
if isinstance(arg, six.string_types):
if isinstance(arg, six.text_type):
cmd.append(arg.encode("utf-8"))
else:
cmd.append(arg)
else:
if not isinstance(arg, six.string_types):
raise ValueError("Argument is invalid: %r" % repr(arg))
if isinstance(arg, six.text_type):
cmd.append(arg.encode("utf-8"))
else:
cmd.append(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 launchctl refactored with the following changes:

Comment on lines -78 to +87
else:
self._properties = convert_NSDictionary_to_dict(val)
# update pid and laststatus attributes
try:
self._pid = self._properties["PID"]
except KeyError:
self._pid = None
try:
self._laststatus = self._properties["LastExitStatus"]
except KeyError:
self._laststatus = None
self._properties = convert_NSDictionary_to_dict(val)
# update pid and laststatus attributes
try:
self._pid = self._properties["PID"]
except KeyError:
self._pid = None
try:
self._laststatus = self._properties["LastExitStatus"]
except KeyError:
self._laststatus = None
Copy link
Author

Choose a reason for hiding this comment

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

Function LaunchdJob.refresh refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Jan 30, 2022

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 4.92 ⭐ 3.87 ⭐ -1.05 👍
Method Length 36.25 ⭐ 36.15 ⭐ -0.10 👍
Working memory 6.15 ⭐ 5.97 ⭐ -0.18 👍
Quality 78.26% 79.85% 1.59% 👍
Other metrics Before After Change
Lines 245 241 -4
Changed files Quality Before Quality After Quality Change
example.py 70.21% 🙂 72.42% 🙂 2.21% 👍
setup.py 55.63% 🙂 55.97% 🙂 0.34% 👍
launchd/cmd.py 70.35% 🙂 72.07% 🙂 1.72% 👍
launchd/launchctl.py 87.45% ⭐ 88.41% ⭐ 0.96% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
example.py main 7 ⭐ 128 😞 8 🙂 62.77% 🙂 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