Skip to content

Tech - Nettoyage tech. #5176

Open
louptheron wants to merge 1 commit into
masterfrom
loup/react_fixes_after_doctor_pass
Open

Tech - Nettoyage tech. #5176
louptheron wants to merge 1 commit into
masterfrom
loup/react_fixes_after_doctor_pass

Conversation

@louptheron

Copy link
Copy Markdown
Collaborator

Linked issues

  1. Non-component export in component file (×17). When you edit a React file
    during development, Vite's "Fast Refresh" swaps in your new code while keeping
    the app's state (open panels, form contents, etc.). It can only do that safely
    if the file exports only components. Mix in a utility function and every edit to
    that file throws away your state and reloads. Severity: zero impact on your
    users — this purely makes development slower and more annoying. The fun finding:
    most of the flagged files weren't component files at all — they were plain
    TypeScript wearing a .tsx costume, which is also what confused the tool.
  • src/api/geoserver.tsx → renamed to .ts (9 of the 17 hits — pure API module,
    zero JSX)
  • interestPoint.style.tsx, Buttons.style.tsx, Backoffice.style.tsx → renamed to
    .ts (styled-components only, no JSX; all imports are extensionless so nothing
    else changed)
  • locale_frFR.jsx → renamed to .js (it's a locale data object, not a component)
  • EnvironmentBox.tsx → moved getEnvironmentBorderStyle to
    src/utils/getEnvironmentBorderStyle.ts (matching the one-function-per-file
    convention there); updated its 3 importers
  • InterestPointOverlay.tsx, OverlayTrianglePointer.tsx → removed export from
    initialOffsetValue and computeTriangleMargins; I checked, nothing imports them
  1. Pure function rebuilt every render (×13). Each of these helpers gets
    recreated from scratch every single time the component redraws — even though it
    never uses anything from inside the component. It's like rewriting the same
    sticky note every time you glance at it. Severity: minor. Each allocation is
    cheap; the real cost is that a "new" function each render can defeat memoized
    children (making React redo work it could have skipped). Users wouldn't notice
    on these screens, it's mostly hygiene. I verified each helper against the rule's
    false-positive checklist (none touch props, state, or other local values) and
    moved all 13 to module scope: onConnect (Login), handleRedirect (RequireAuth),
    findStage (BeaconMalfunctionBoard), openXML (LogbookMessage),
    getPercentOfTotalWeight (PNOMessageResume — which even had a TODO saying to do
    exactly this), 2 chart helpers (SpeciesAndWeightChart), filterDuplicateSpecies
    (LANMessageResume), handleCenterOnMap ×2 (both FormikCoordinatesPickers),
    handleZoomToMission (MissionList), getInitialTitleVisibility (ReportingForm),
    getText (InfractionsSummary).

  2. Await inside a loop (×6, 3 real). await inside a loop means each operation
    waits for the previous one to fully finish — like a cashier who won't start
    scanning your items until the previous customer has driven out of the parking
    lot. Severity: no production impact — all 3 real cases are in the puppeteer e2e
    harness. It launches 2 browsers, connects to them, and closes them
    one-at-a-time; now they run concurrently, shaving a few seconds off every
    multi-windows test run. Order is preserved (Promise.all keeps array order,
    window positions still come from the index).


  • Tests E2E (Cypress)

@tristanrobert

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants