-
Notifications
You must be signed in to change notification settings - Fork 3
Reduce code duplication to pass SonarQube quality gate #893
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Centralize duplicated error messages and form validation code to reduce duplication from 4.87% to below the 3% threshold. Backend changes: - Add controllers/api/constants.py with 40+ standardized error messages - Update 17 controller files to use shared constants - Update 2 test files with improved error message format Frontend changes: - Add mixins/formValidationMixin.js with reusable validation methods - Update 9 Vue components to use the shared mixin Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Extract common validation logic into validate_style_fields() helper function to reduce code duplication between post() and patch() methods. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Extract common patterns to reduce SonarQube duplication metrics: - Create helpers.py with shared allocation CRUD logic for props/scenery - Extract handle_override_patch/delete helpers in overrides.py - Update props.py and scenery.py to use shared helpers Net reduction of ~247 lines while preserving all functionality. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add handle_type_post, handle_type_patch, handle_type_delete helpers and update PropsTypesController and SceneryTypesController to use them. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Remove validateNewState and validateEditState convenience wrappers. Components now call getValidationState directly with the form state key. Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
claude
Issues created by Claude
client
Pull requests changing front end code
server
Pull requests changing back end code
xlarge-diff
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



Summary
Reduce code duplication to pass SonarQube quality gate (from ~7.7% to 2.3%, threshold ≤3%).
Changes
Python Error Constants (
server/controllers/api/constants.py)ERROR_SHOW_NOT_FOUND,ERROR_ID_MISSING,ERROR_NAME_MISSING, etc.Vue Form Validation Mixin (
client/src/mixins/formValidationMixin.js)getValidationState(),resetForm(),hasFormErrors()Stage Direction Styles Helper (
server/controllers/api/show/script/stage_direction_styles.py)validate_style_fields()helper to reduce duplication betweenpost()andpatch()methodsUser Overrides Helpers (
server/controllers/api/user/overrides.py)handle_override_patch()andhandle_override_delete()helpersStageDirectionOverridesControllerandCueColourOverridesControllernow share common CRUD logicStage Controller Helpers (
server/controllers/api/show/stage/helpers.py)handle_type_post(),handle_type_patch(),handle_type_delete()- for PropType/SceneryType CRUDhandle_allocation_post(),handle_allocation_delete()- for scene allocation managementprops.pyandscenery.pyto use these shared helpersFiles Changed
server/controllers/api/constants.py(new)server/controllers/api/show/stage/helpers.py(new)client/src/mixins/formValidationMixin.js(new)props.py,scenery.py,overrides.py,stage_direction_styles.pyrefactoredTest plan
🤖 Generated with Claude Code