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

Ensure min/max property editor settings are valid before rendering for content editing #17881

Open
wants to merge 2 commits into
base: v15/dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
this._min = this.#parseInt(config.getValueByAlias('minNumber'), 0);
this._max = this.#parseInt(config.getValueByAlias('maxNumber'), Infinity);
this._overlaySize = config.getValueByAlias<UUIModalSidebarSize>('overlaySize') ?? 'small';

if (this._min && this._max && this._min > this._max) {

Check warning on line 31 in src/Umbraco.Web.UI.Client/src/packages/multi-url-picker/property-editor/property-editor-ui-multi-url-picker.element.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

❌ New issue: Complex Conditional

UmbPropertyEditorUIMultiUrlPickerElement.setconfig has 1 complex conditionals with 2 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
this._max = this._min;
//TODO Maybe we want to show some kind of error element rather than trying to fix the mistake made by the user...?
throw new Error(
`Property Editor Multi URL Picker: max is greater than min and set to be equal. Please change your data type configuration.`,
);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
this._max = this.#parseInt(config.getValueByAlias('max'));
this._step = this.#parseInt(config.getValueByAlias('step'));
this._placeholder = config.getValueByAlias('placeholder');

if (this._min && this._max && this._min > this._max) {

Check warning on line 42 in src/Umbraco.Web.UI.Client/src/packages/property-editors/number/property-editor-ui-number.element.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

❌ New issue: Complex Conditional

UmbPropertyEditorUINumberElement.setconfig has 1 complex conditionals with 2 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
this._max = this._min;
//TODO Maybe we want to show some kind of error element rather than trying to fix the mistake made by the user...?
throw new Error(
`Property Editor Number: max is greater than min and set to be equal. Please change your data type configuration.`,
);
}
}

#parseInt(input: unknown): number | undefined {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@
this._minHeight = Number(config?.getValueByAlias('minHeight')) || undefined;
this._maxHeight = Number(config?.getValueByAlias('maxHeight')) || undefined;

if (this._minHeight && this._maxHeight && this._minHeight > this._maxHeight) {

Check warning on line 47 in src/Umbraco.Web.UI.Client/src/packages/property-editors/textarea/property-editor-ui-textarea.element.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

❌ New issue: Complex Conditional

UmbPropertyEditorUITextareaElement.setconfig has 1 complex conditionals with 2 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
this._maxHeight = this._minHeight;
//TODO Maybe we want to show some kind of error element rather than trying to fix the mistake made by the user...?
throw new Error(
`Property Editor Text Area: max is greater than min and set to be equal. Please change your data type configuration.`,
);
}

Check notice on line 54 in src/Umbraco.Web.UI.Client/src/packages/property-editors/textarea/property-editor-ui-textarea.element.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

ℹ Getting worse: Complex Method

UmbPropertyEditorUITextareaElement.setconfig increases in cyclomatic complexity from 11 to 15, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
this._css = {
'--uui-textarea-min-height': this._minHeight ? `${this._minHeight}px` : 'reset',
'--uui-textarea-max-height': this._maxHeight ? `${this._maxHeight}px` : 'reset',
Expand Down
Loading