Skip to content

chore: arreglar S7741 introducidos en #48#50

Merged
DevOtter97 merged 1 commit into
mainfrom
chore/sonar-typeof-undefined
May 2, 2026
Merged

chore: arreglar S7741 introducidos en #48#50
DevOtter97 merged 1 commit into
mainfrom
chore/sonar-typeof-undefined

Conversation

@DevOtter97

Copy link
Copy Markdown
Owner

Resumen

Cierra los 3 issues S7741 (Compare with `undefined` directly) que introduje yo en #48 al sustituir `window.X` por `globalThis.window.X`. Sonar prefiere comparacion directa con `undefined` cuando la variable es accesible sin throw — y `globalThis.window` lo es.

`typeof globalThis.window === 'undefined'` → `globalThis.window === undefined`

Ficheros

  • `src/utils/theme.ts` (2 ocurrencias)
  • `src/components/profile/PublicUserProfile.tsx` (1 ocurrencia)

Por que solo 3 cuando hay mas

Las otras 5 ocurrencias del mismo patron viven en `tests/setup.ts`. `sonar-project.properties` excluye `tests/**` del analisis, asi que Sonar no las flagea. Las dejo igual para mantener consistencia con el resto del setup de tests.

Test plan

  • `npx tsc --noEmit` limpio (TS narrowing acepta la comparacion directa pese a que `globalThis.window` esta tipado como `Window`)
  • `npm run test:run` 60/60
  • CI verde

Sonar prefiere comparacion directa con undefined cuando la variable es
accesible sin throw (como globalThis.window). Las 3 ocurrencias en
codigo de produccion las introduje yo en #48 al cambiar window.X por
globalThis.window.X. Las 5 en tests/setup.ts no estan flageadas (Sonar
excluye tests/** del analisis), no se tocan.
@vercel

vercel Bot commented May 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
gororeads Ignored Ignored May 2, 2026 9:51am

@sonarqubecloud

sonarqubecloud Bot commented May 2, 2026

Copy link
Copy Markdown

@DevOtter97 DevOtter97 merged commit 0f5da3c into main May 2, 2026
7 checks passed
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.

1 participant