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

Code Cleanup #8

Merged
merged 9 commits into from
Feb 25, 2021
Merged

Code Cleanup #8

merged 9 commits into from
Feb 25, 2021

Conversation

mcdonnnj
Copy link
Member

🗣 Description

This PR is mostly just some housekeeping for this project. There is a bug fixed in 93798d3, and a potential side-effect is removed in 28c9247, but the bulk is some general polish. The logging has also been adjusted to printf style that is preferred because of logging library internals.

💭 Motivation and context

The bug I mentioned is a problem for anyone else trying to use this code in production. While I was fixing the aforementioned bug, I wanted to do some general housekeeping since this project was created before we moved to an "Initial Pull Request" model as talked about in the development guide.

🧪 Testing

Automated testing passes and some basic checks I ran locally gave expected results.

✅ Checklist

  • This PR has an informative and human-readable title.
  • Changes are limited to a single goal - eschew scope creep!
  • All relevant type-of-change labels have been added.
  • I have read the CONTRIBUTING document.
  • These code changes follow cisagov code standards.
  • All new and existing tests pass.

There was the possibllity of falling through to an unset variable previously.
Type hints should be added whenever possible. This fixes missing return value
hints for two methods.
Deleting the parameter when no users are present may cause dependent tools to
fail instead of performing a no-op because it is empty.
Sorting the users that are turned into a comma delimited list makes it easier
for manual interaction in the AWS console. The tool should be preferred, but we
should still consider other interactions.
The ManageOperators.add_user() and ManageOperators.remove_user() methods were
needlessly complicated about the return value. This simplifies them since the
method they are relying on for functionality returns the same type of value.
Replace all of the f-strings with the substitution based log messaging that is
preferred.
Single character variable names are generally discouraged for Python.
Simply of an over-complicated check in Schema validation. Remove an unnecessary
else return usage.
@mcdonnnj mcdonnnj added bug This issue or pull request addresses broken functionality improvement This issue or pull request will add or improve functionality, maintainability, or ease of use labels Feb 19, 2021
@mcdonnnj mcdonnnj requested a review from dav3r as a code owner February 19, 2021 00:47
@mcdonnnj mcdonnnj self-assigned this Feb 19, 2021
@mcdonnnj mcdonnnj added this to In progress in Cyber Hygiene (CyHy) via automation Feb 19, 2021
Cyber Hygiene (CyHy) automation moved this from In progress to Reviewer approved Feb 19, 2021
Copy link
Member

@dav3r dav3r left a comment

Choose a reason for hiding this comment

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

Nice improvements! 🎟️

try:
# The SSM response on success currently only contains a version
# number and the parameter tier.
# Neither are useful to us at this time, so we don't store them..
Copy link
Member

Choose a reason for hiding this comment

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

Is the double-period intentional here? I saw another one elsewhere.

Suggested change
# Neither are useful to us at this time, so we don't store them..
# Neither are useful to us at this time, so we don't store them.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, nice catch. Fixed both instances in 5b1711c.

It was pointed out in review that I had some unintentional double periods, so I
have fixed them.
@mcdonnnj mcdonnnj merged commit e8f6d6a into develop Feb 25, 2021
Cyber Hygiene (CyHy) automation moved this from Reviewer approved to Done Feb 25, 2021
@mcdonnnj mcdonnnj deleted the improvement/code_cleanup branch February 25, 2021 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue or pull request addresses broken functionality improvement This issue or pull request will add or improve functionality, maintainability, or ease of use
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants