Sonar refactor: Roles Controller
What does this MR do and why?
Resolve all sonar issues in roles_controller.py. Improving the code and documentation in required areas.
roles_controller.py now generates no issues in Sonar, Pylint, Ruff, and Ty! Removes 2 high, 4 medium, and 2 info severity issues in Sonar cloud.
- Replace Typing
Union[str | int]with updatedstr | intstyle. - Update
delete_roles_permissionto accept aCollectionrather than aSequence. This resolves two Sonar warnings and better captures the use behavior see elsewhere in Crafty. The Collection allows asetto be passed, not just alistortuple. - Isorted
roles_controller.pyandserver_permissions.py - Resolved
FIXMEin and improveget_server_ids_and_perms_from_role. Request to db now only grabs needed information rather than the entire server objects. Modified output to better match what type checker Ty wanted. - Added missing type annotations and docstrings to touched functions.
- Removes unused version of update_role.
- Resolves todo related to tracking update time in the database rather than calculating this value in the python code.
How to set up and validate locally
Most changes are stylistic, some parts of code logic are touched.
- Confirm that role behavior remains as expected
- Test that removing servers from a role behaves as expected
- Edit a role and confirm that update time for the role still shows time correctly.
- Confirm removing a manager for a role behaves as expected.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
- Have you checked this doesn't interfere/conflict/duplicate someone elses work?
- Have you fully tested your changes?
- Have you resolved any lint issues?
- Have you assigned a reviewer?
- Have you applied correct labels?
Edited by Wout Bouckaert