[PR #526] [MERGED] Reduce code complexity #601

Closed
opened 2026-02-27 15:59:19 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/retspen/webvirtcloud/pull/526
Author: @Regan-He
Created: 8/22/2022
Status: Merged
Merged: 8/22/2022
Merged by: @catborise

Base: masterHead: master


📝 Commits (1)

  • 4d78917 modify some shell scripts to make variable references safer; modify some python scripts to reduce the code complexity and cyclomatic complexity of functions.

📊 Changes

12 files changed (+164 additions, -262 deletions)

View changed files

📝 dev/libvirt-bootstrap.sh (+7 -11)
📝 gunicorn.conf.py (+1 -4)
📝 vrtManager/IPy.py (+1 -4)
📝 vrtManager/create.py (+19 -46)
📝 vrtManager/hostdetails.py (+20 -21)
📝 vrtManager/interface.py (+32 -42)
📝 vrtManager/network.py (+27 -46)
📝 vrtManager/nwfilters.py (+1 -4)
📝 vrtManager/storage.py (+11 -26)
📝 vrtManager/util.py (+18 -24)
📝 webvirtcloud/common_tags.py (+5 -13)
📝 webvirtcloud/ldapbackend.py (+22 -21)

📄 Description

For shell:

  • modify some shell scripts to make variable references safer
  • remove useless local variables
  • check exit code directly with 'if ! mycmd;'

For python:

  • simplify comparison to boolean
  • replace if statement with if expression
  • use contextlib's suppress method to silence an error
  • convert for loop into list comprehension
  • replace identity comprehension with call to collection constructor
  • replace multiple comparisons of same variable with in operator
  • use except Exception: rather than bare except:
  • swap if/else branches, Remove unnecessary else after guard condition
  • reduce cyclomatic complexity
  • don't assign to builtin variable or keyword

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/retspen/webvirtcloud/pull/526 **Author:** [@Regan-He](https://github.com/Regan-He) **Created:** 8/22/2022 **Status:** ✅ Merged **Merged:** 8/22/2022 **Merged by:** [@catborise](https://github.com/catborise) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (1) - [`4d78917`](https://github.com/retspen/webvirtcloud/commit/4d78917c35c16e85dddae0bfd9af1ebcf45b7cbc) modify some shell scripts to make variable references safer; modify some python scripts to reduce the code complexity and cyclomatic complexity of functions. ### 📊 Changes **12 files changed** (+164 additions, -262 deletions) <details> <summary>View changed files</summary> 📝 `dev/libvirt-bootstrap.sh` (+7 -11) 📝 `gunicorn.conf.py` (+1 -4) 📝 `vrtManager/IPy.py` (+1 -4) 📝 `vrtManager/create.py` (+19 -46) 📝 `vrtManager/hostdetails.py` (+20 -21) 📝 `vrtManager/interface.py` (+32 -42) 📝 `vrtManager/network.py` (+27 -46) 📝 `vrtManager/nwfilters.py` (+1 -4) 📝 `vrtManager/storage.py` (+11 -26) 📝 `vrtManager/util.py` (+18 -24) 📝 `webvirtcloud/common_tags.py` (+5 -13) 📝 `webvirtcloud/ldapbackend.py` (+22 -21) </details> ### 📄 Description For shell: - modify some shell scripts to make variable references safer - remove useless local variables - check exit code directly with 'if ! mycmd;' For python: - simplify comparison to boolean - replace if statement with if expression - use `contextlib`'s `suppress` method to silence an error - convert for loop into list comprehension - replace identity comprehension with call to collection constructor - replace multiple comparisons of same variable with `in` operator - use `except Exception:` rather than bare `except:` - swap if/else branches, Remove unnecessary else after guard condition - reduce cyclomatic complexity - don't assign to builtin variable or keyword --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 15:59:19 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/webvirtcloud#601
No description provided.