chore: arreglar SonarCloud MAJOR (a11y, readonly, cleanup, ternarios)#47
Merged
Conversation
- Imports sin usar: OAuthProvider en FirebaseAuthService, Timestamp en FirestoreFriendRepository, increment+setDoc en FirestoreCustomListRepository, orderBy en FirestoreReadingRepository. - Asignaciones muertas: handleLogout/authService inutilizados en ListManager y ReadingList (Header tiene su propio dropdown logout desde hace tiempo); normalizedQuery muerto en searchUsers. - console.error y comentario en ingles desfasado eliminado en ImageCropperModal. - catch sin handle en CustomListModal: ahora loguea el error. - Optional chain en FirebaseAuthService (firebaseUser?.email) y ListCommentSection (comment.userId === currentUser?.id). - removeChild -> .remove() en useDropdown.test. - Spacing JSX ambiguo en UsernameSetupModal y CustomListModal.
- Props de los 40 componentes Preact ahora son Readonly<...>. SonarQube recomienda esto para componentes funcionales: deja claro que no se van a mutar y deja al type-checker pillar mutaciones accidentales. - collectionRef en los 3 FirestoreXRepository marcado readonly. - map en MemoryStorage de tests/setup marcado readonly.
- Cambia for= por htmlFor= en LoginForm, RegisterForm, ReadingForm, AccountSecurityForm, UsernameChangeForm, DeleteAccountSection. SonarQube no detectaba la asociacion con el atributo HTML 'for' en JSX. - Anade htmlFor + id a labels que no tenian asociacion explicita en UserProfile (5 campos), CustomListModal (nombre/descripcion/buscador de lecturas), UsernameSetupModal, AccountSecurityForm (email actual), UsernameChangeForm (username actual). - Convierte labels de grupos de radios a fieldset/legend en CustomListModal (Visibilidad), StartReadingModal y ReadingForm (Unidad de Progreso). Es la forma a11y correcta para etiquetar un grupo en vez de un control unico.
SonarQube S3358 marca ternarios nested-in-ternaries como dificiles de leer. Las ramas mas comunes en este codebase eran: - 'loading ? <Loading /> : empty ? <Empty /> : <Content />' en tabs y pickers (ProfileCommentsTab, ProfileListsTab, ProfilePostsTab, HomeFeed, NotificationBell, ListPickerModal, ReadingPickerModal, ExternalSearchModal, CommentList, CustomListModal). Se split en conditional-renders separados con && (sin else implicito anidado). - Mappers de string en JSX (placeholder de PostComposer, label de ReadingForm/ReadingCard/ReadingDetailsModal, action button de UserSearch). Extraidos a helpers (composerPlaceholder, charCountModifier, currentProgressLabel, formatChapterProgress, computeProgressWidth, submitButtonLabel). - UserProfile loading/profile/empty: split a 3 conditionals con &&. Comportamiento identico, solo mejora la legibilidad.
# Conflicts: # src/components/home/PostComposer.tsx # src/components/lists/CustomListModal.tsx # src/components/profile/ProfileCommentsTab.tsx # src/components/profile/ProfileListsTab.tsx # src/components/profile/ProfilePostsTab.tsx # src/components/readings/ReadingCard.tsx # src/components/readings/ReadingDetailsModal.tsx # src/components/readings/ReadingForm.tsx
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Segunda tanda de SonarCloud, basada encima de la PR #46. Cubre los hallazgos de severidad MAJOR (~70 issues) divididos en cuatro categorias, una sub-rama por categoria.
Cambios
chore: limpieza de imports/asignaciones muertas y micro-fixes (S1128 + S1854 + S125 + S2486 + S6772 + S6582 + S7762)
OAuthProvider,Timestamp,increment,setDoc,orderBy.handleLogout/authServicemuertos enListManageryReadingList(Header tiene su propio dropdown desde hace tiempo).normalizedQuerymuerto ensearchUsers. Comentario en ingles desfasado eliminado.console.errorcomentado enImageCropperModal.catchsin handle enCustomListModalahora loguea.FirebaseAuthService(firebaseUser?.email) yListCommentSection.removeChild->.remove()enuseDropdown.test.UsernameSetupModalyCustomListModal.chore: marcar props y miembros como readonly (S6759 + S2933)
Readonly<...Props>en su firma.collectionRefreadonlyen los 3FirestoreXRepository.mapreadonlyenMemoryStoragede tests/setup.fix(a11y): form labels asociados con htmlFor y fieldset/legend (S6853 + S6847)
for=porhtmlFor=en formularios (SonarQube no detectaba la asociacion con el atributo HTML 'for' en JSX).htmlFor+ida labels que no tenian asociacion explicita enUserProfile,CustomListModal,UsernameSetupModal,AccountSecurityForm,UsernameChangeForm.<fieldset><legend>enCustomListModal(Visibilidad),StartReadingModalyReadingForm(Unidad de Progreso).refactor: aplanar ternarios anidados (S3358)
&&.composerPlaceholder,charCountModifier,currentProgressLabel,formatChapterProgress,computeProgressWidth,submitButtonLabel).UserProfileloading/profile/empty: split a 3 conditionals con&&.Test plan
npx tsc --noEmit— solo el error pre-existente deReadingMeasureUnitnpm run test:run— 60/60npm run build— OK