Skip to content

Commit 6723103

Browse files
Drop redundant guards and dead variables flagged by CodeQL
Each guard sits behind an earlier early-return that already enforces truthiness, so the inner check can never fire false. The visible ternaries always rendered the truthy branch. The dead UnifiedInputContainer inside the council-mode arm was a duplicate of the real one in the non-council branch. Plus four script imports nothing referenced, chat.ts seedId not consumed downstream, MiniPlayer imageKey overwritten on every branch, ErrorBoundary errorInfo only ever written, and SpeechPanel's OptionButtons prop was declared but never destructured.
1 parent 1313af3 commit 6723103

14 files changed

Lines changed: 28 additions & 50 deletions

File tree

client/scripts/extract-public-data.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// Reads full seed data, voice profiles, figure translations, and story files
55
// Outputs lightweight summaries for prerendering and client display
66

7-
import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync } from 'fs';
8-
import { join, basename } from 'path';
7+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';
8+
import { join } from 'path';
99

1010
const CLIENT_DIR = join(import.meta.dirname, '..');
1111
const SEEDS_DIR = join(CLIENT_DIR, 'src/assets/translations/seeds');

client/scripts/prerender.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// Phase 1: HTML shell pages with meta tags + JSON-LD for crawlers
55
// Phase 2 (future): Full React SSR rendering with react-dom/server
66

7-
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';
8-
import { join, dirname } from 'path';
7+
import { readFileSync, writeFileSync, mkdirSync } from 'fs';
8+
import { join } from 'path';
99

1010
const BUILD_DIR = join(import.meta.dirname, '..', 'build');
1111
const SITE_URL = 'https://agoracosmica.org';

client/src/components/AudioLibrary/MiniPlayer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ const MiniPlayer: FC<MiniPlayerProps> = ({ story, figure, onExpand, audioService
6363
if (playback.figureName) {
6464
// Extract imageKey from figure name for image loading
6565
const figureNameLower = playback.figureName.toLowerCase();
66-
let imageKey = 'default';
67-
68-
// Extract the key from the figure name
66+
// Extract the key from the figure name. All branches below assign,
67+
// so no initial fallback is needed.
68+
let imageKey: string;
6969
if (figureNameLower.includes('leonardo') || figureNameLower.includes('vinci')) {
7070
imageKey = 'vinci';
7171
} else if (figureNameLower.includes('king jr')) {

client/src/components/AudioLibrary/NowPlayingView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ const NowPlayingView: FC<NowPlayingViewProps> = ({ story, figure, audioService,
632632
priority={true}
633633
withBlurUp={true}
634634
className="now-playing-view__figure-image"
635-
alt={tString('audioLibrary.nowPlaying.imageOf', `Image of ${currentFigure && currentFigure.name ? getFigureDisplayName(currentFigure.name) : ''}`).replace('{{figureName}}', currentFigure && currentFigure.name ? getFigureDisplayName(currentFigure.name) : '')}
635+
alt={tString('audioLibrary.nowPlaying.imageOf', `Image of ${currentFigure.name ? getFigureDisplayName(currentFigure.name) : ''}`).replace('{{figureName}}', currentFigure.name ? getFigureDisplayName(currentFigure.name) : '')}
636636
/>
637637
)}
638638

client/src/components/CosmicCouncil/CouncilSetupModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ const CouncilSetupModal: FC<CouncilSetupModalProps> = ({
211211
}
212212

213213
if (selectedFigures.length < 3) {
214-
const allFigures = moderator ? [moderator, ...selectedFigures] : selectedFigures;
214+
// moderator is non-null here — the !moderator branch above returned.
215+
const allFigures = [moderator, ...selectedFigures];
215216
const genderCheck = checkGenderLimit(allFigures, figure);
216217
if (!genderCheck.canAdd) {
217218
console.warn(genderCheck.reason);

client/src/components/ErrorBoundary.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ interface ErrorBoundaryProps extends ErrorBoundaryWrapperProps {
1313
interface ErrorBoundaryState {
1414
hasError: boolean;
1515
error: Error | null;
16-
errorInfo: ErrorInfo | null;
1716
}
1817

1918
// Wrapper component to use hooks with class component
@@ -23,10 +22,9 @@ function ErrorBoundaryWrapper(props: ErrorBoundaryWrapperProps): React.ReactElem
2322
}
2423

2524
class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
26-
state: ErrorBoundaryState = {
27-
hasError: false,
28-
error: null,
29-
errorInfo: null
25+
state: ErrorBoundaryState = {
26+
hasError: false,
27+
error: null
3028
};
3129

3230
static getDerivedStateFromError(): Partial<ErrorBoundaryState> {
@@ -35,7 +33,7 @@ class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundarySta
3533

3634
componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
3735
console.error('Story Mode Error:', error, errorInfo);
38-
this.setState({ error, errorInfo });
36+
this.setState({ error });
3937
}
4038

4139
render(): ReactNode {

client/src/components/HomePage/MainContent.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,6 @@ const MainContent: FC<MainContentProps> = ({
284284
isReviewMode={isReviewMode}
285285
isAudioPlaying={isAudioPlaying}
286286
/>
287-
288-
{/* Hide input field during council mode - autonomous conversation doesn't need user input */}
289-
{!isCouncilMode && (
290-
<UnifiedInputContainer
291-
selectedFigure={selectedFigure?.name || 'Unknown'}
292-
onSubmitMessage={onSubmitMessage}
293-
/>
294-
)}
295287
</>
296288
) : !conversationStartedFinal ? (
297289
// Show empty state while mode selector or language wheel should appear

client/src/components/QuestVerdictCard/PostQuestVerdictCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const PostQuestVerdictCard: FC<PostQuestVerdictCardProps> = ({
4444

4545
return (
4646
<div
47-
className={`quest-verdict-card ${visible ? 'visible' : ''}`}
47+
className="quest-verdict-card visible"
4848
role="status"
4949
aria-live="polite"
5050
onTouchStart={handleTouchStart}

client/src/components/StoryPlayer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ const StoryPlayer: FC<StoryPlayerProps> = ({
586586
const { audioUrl } = storyData;
587587

588588
// Don't show loading if we have valid story data
589-
const isLoading = status === 'loading' && (!storyData || !storyData.text);
589+
const isLoading = status === 'loading' && !storyData.text;
590590

591591
// Don't show the story player at all if we're in translation mode
592592
if (storyData.needsTranslation) {

client/src/components/WisdomMapModal/PostDialogueBloomInvite.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const PostDialogueBloomInvite: FC<PostDialogueBloomInviteProps> = ({ count, onTa
6767

6868
return (
6969
<div
70-
className={`bloom-invite ${visible ? 'visible' : ''}`}
70+
className="bloom-invite visible"
7171
onClick={handleTap}
7272
onTouchStart={handleTouchStart}
7373
onTouchEnd={handleTouchEnd}

0 commit comments

Comments
 (0)