Skip to content

Conversation

@ghazwarhili
Copy link
Contributor

PR Summary

shunt compensator creation dialog migration TS

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@flomillot flomillot self-requested a review December 30, 2025 15:42
[MAX_Q_AT_NOMINAL_V]: yup.number().nullable().min(0, 'ShuntCompensatorErrorQAtNominalVoltageLessThanZero'),
[MAX_SUSCEPTANCE]: yup.number().nullable(),
[MAXIMUM_SECTION_COUNT]: yup.number().min(1, 'MaximumSectionCountMustBeGreaterOrEqualToOne').nullable(),
[MAXIMUM_SECTION_COUNT]: yup.number().nullable().min(1, 'MaximumSectionCountMustBeGreaterOrEqualToOne'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[MAXIMUM_SECTION_COUNT]: yup.number().nullable().min(1, 'MaximumSectionCountMustBeGreaterOrEqualToOne'),
[MAXIMUM_SECTION_COUNT]: yup.number().min(1, 'MaximumSectionCountMustBeGreaterOrEqualToOne').nullable(),


export type CharacteristicsFormProps = {
previousValues?: ShuntCompensatorFormInfos;
isModification?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
isModification?: boolean;
isModification: boolean;

Why question mark if we have a default value ?

const previousMaxQAtNominalV = useMemo(() => {
const previousValue = previousValues?.qatNominalV * previousValues?.maximumSectionCount;
return isNaN(previousValue) ? null : previousValue;
const prevValue = previousValues && previousValues?.qAtNominalV * previousValues?.maximumSectionCount;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const prevValue = previousValues && previousValues?.qAtNominalV * previousValues?.maximumSectionCount;
const prevValue = previousValues && previousValues.qAtNominalV * previousValues.maximumSectionCount;

const previousMaxSusceptance = useMemo(() => {
const previousValue = previousValues?.bperSection * previousValues?.maximumSectionCount;
return isNaN(previousValue) ? null : previousValue;
const prevValue = previousValues && previousValues?.bPerSection * previousValues?.maximumSectionCount;
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

label={'SwitchedOnMaxQAtNominalV'}
adornment={ReactivePowerAdornment}
previousValue={previousValues?.qatNominalV * previousValues?.sectionCount}
previousValue={previousValues && previousValues?.qAtNominalV * previousValues?.sectionCount}
Copy link
Contributor

Choose a reason for hiding this comment

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

same

label={'SwitchedOnMaxSusceptance'}
adornment={SusceptanceAdornment}
previousValue={previousValues?.bperSection * previousValues?.sectionCount}
previousValue={previousValues && previousValues?.bPerSection * previousValues?.sectionCount}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same there is no need of question mark when you already checked if the value exists.

[EQUIPMENT_ID]: yup.string().required(),
[EQUIPMENT_NAME]: yup.string().nullable(),
...getConnectivityWithPositionValidationSchema(),
[CONNECTIVITY]: getConnectivityWithPositionSchema(),
Copy link
Contributor

Choose a reason for hiding this comment

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

better to use the id field at as it's done for other function

Comment on lines +43 to +48
[MAX_Q_AT_NOMINAL_V]?: number | null;
[MAX_SUSCEPTANCE]?: number | null;
[MAXIMUM_SECTION_COUNT]?: number | null;
[SECTION_COUNT]?: number | null;
[SWITCHED_ON_Q_AT_NOMINAL_V]?: number | null;
[SWITCHED_ON_SUSCEPTANCE]?: number | null;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is equivalent to number | null | undefined
We should do this only if null is different from optional and is a valid value
If the field is optional, we should remove this null type and use optional() instead of nullable() on the yup schema

shuntCompensatorCreationInfos: ShuntCompensatorCreationInfos;
studyUuid: UUID;
nodeUuid: UUID;
modificationUuid?: string | null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why null?

Comment on lines +506 to +510
maxSusceptance?: number | null;
maxQAtNominalV?: number | null;
shuntCompensatorType?: string | null;
sectionCount?: number | null;
maximumSectionCount?: number | null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, except if you have a good reason, you shouldn't use null with undefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants