Skip to content

Various quality fixes on network-map-viewer #64

Open
@flo-dup

Description

@flo-dup

Comments posted by @capyq in powsybl/powsybl-incubator#267 which were on the code extracted from https://github.com/gridsuite/gridstudy-app
This should be cut later in pieces to separate the easy parts from the most difficult ones (like typescript).

Originally posted in powsybl/powsybl-incubator#267 (comment)

I notice to much confusion between "null" and "undefined".
it's not a javaScript way to handle Object by using the class Map. it's better to use JSON Object.

Originally posted in powsybl/powsybl-incubator#267 (comment)

let labelDistanceInSegment = remainingDistance;
if (goodSegment.idx === 0) {
    labelDistanceInSegment = -alreadyDoneDistance;
} 

Originally posted in powsybl/powsybl-incubator#267 (comment)

return equipments ?? [];

Originally posted in powsybl/powsybl-incubator#267 (comment)

if (!equipementsToIndex?.length) {

Originally posted in powsybl/powsybl-incubator#267 (comment)

if (substationAdded || voltageLevelAdded) {

it's more readable

Originally posted in powsybl/powsybl-incubator#267 (comment)

why doing this at the end ?
this is cost expensive and if it's needed, you should add an else statement on the fullrender check (line 108)

Originally posted in powsybl/powsybl-incubator#267 (comment)

this should be a "const" you never asign it after this line

Originally posted in powsybl/powsybl-incubator#267 (comment)

does "null" and undefined are separate ? if not, you better use this version

if (!props.network && !props.geoData) {

Originally posted in powsybl/powsybl-incubator#267 (comment)

does null and undefined are two expected value ? if not, prefer short version

    !props.network && !props.geoData && !props.filteredNominalVoltages
) {

Originally posted in powsybl/powsybl-incubator#267 (comment)

separate in two lines we don't understand what should not be undefined

Originally posted in powsybl/powsybl-incubator#267 (comment)

this method is never used

Originally posted in powsybl/powsybl-incubator#267 (comment)

you are mixing null and undefined
1 - if infos is undefined you also should return null (or undefined) => if (!infos){...}
2 - why testing infos?.id but not infos.name ?

Originally posted in powsybl/powsybl-incubator#267 (comment)

those are not else if but only if and you don't need else case because you return each statement

Originally posted in powsybl/powsybl-incubator#267 (comment)

It's not a good practice to use variable to store component React doesn't tag this as react component and re-render it more than needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions