Skip to content

Commit 5accc7d

Browse files
committed
update sonarcloud issues
1 parent 62a1a47 commit 5accc7d

File tree

1 file changed

+23
-33
lines changed

1 file changed

+23
-33
lines changed

frontend/src/components/CardDetailsPage.tsx

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,18 @@ const DetailsCard = ({
8282
}: DetailsCardProps) => {
8383
const { data } = useSession()
8484

85+
// Pre-compute common type checks to reduce cognitive complexity
86+
const isProjectOrRepository = type === 'project' || type === 'repository'
87+
const isProgramOrModule = type === 'program' || type === 'module'
88+
const showStatistics =
89+
type === 'project' ||
90+
type === 'repository' ||
91+
type === 'committee' ||
92+
type === 'user' ||
93+
type === 'organization'
94+
const showIssuesAndMilestones =
95+
type === 'project' || type === 'repository' || type === 'user' || type === 'organization'
96+
8597
// compute styles based on type prop
8698
const typeStylesMap = {
8799
chapter: 'gap-2 md:col-span-3',
@@ -152,11 +164,7 @@ const DetailsCard = ({
152164
<SocialLinks urls={socialLinks || []} />
153165
)}
154166
</SecondaryCard>
155-
{(type === 'project' ||
156-
type === 'repository' ||
157-
type === 'committee' ||
158-
type === 'user' ||
159-
type === 'organization') && (
167+
{showStatistics && (
160168
<SecondaryCard
161169
icon={FaChartPie}
162170
title={<AnchorTitle title="Statistics" />}
@@ -192,7 +200,7 @@ const DetailsCard = ({
192200
</div>
193201
)}
194202
</div>
195-
{(type === 'project' || type === 'repository') && (
203+
{isProjectOrRepository && (
196204
<div
197205
className={`mb-8 grid grid-cols-1 gap-6 ${topics.length === 0 || languages.length === 0 ? 'md:col-span-1' : 'md:grid-cols-2'}`}
198206
>
@@ -208,7 +216,7 @@ const DetailsCard = ({
208216
)}
209217
</div>
210218
)}
211-
{(type === 'program' || type === 'module') && (
219+
{isProgramOrModule && (
212220
<>
213221
{((tags?.length || 0) > 0 || (domains?.length || 0) > 0) && (
214222
<div
@@ -305,41 +313,23 @@ const DetailsCard = ({
305313
moduleKey={entityKey || ''}
306314
/>
307315
)}
308-
{(type === 'project' ||
309-
type === 'repository' ||
310-
type === 'user' ||
311-
type === 'organization') && (
316+
{showIssuesAndMilestones && (
312317
<div className="grid-cols-2 gap-4 lg:grid">
313318
<RecentIssues data={recentIssues} showAvatar={showAvatar} />
314-
{type === 'user' ||
315-
type === 'organization' ||
316-
type === 'repository' ||
317-
type === 'project' ? (
318-
<Milestones data={recentMilestones} showAvatar={showAvatar} />
319-
) : (
320-
<RecentReleases
321-
data={recentReleases}
322-
showAvatar={showAvatar}
323-
showSingleColumn={true}
324-
/>
325-
)}
319+
<Milestones data={recentMilestones} showAvatar={showAvatar} />
326320
</div>
327321
)}
328-
{(type === 'project' ||
329-
type === 'repository' ||
330-
type === 'organization' ||
331-
type === 'user') && (
322+
{showIssuesAndMilestones && (
332323
<div className="grid-cols-2 gap-4 lg:grid">
333324
<RecentPullRequests data={pullRequests} showAvatar={showAvatar} />
334325
<RecentReleases data={recentReleases} showAvatar={showAvatar} showSingleColumn={true} />
335326
</div>
336327
)}
337-
{(type === 'project' || type === 'user' || type === 'organization') &&
338-
repositories.length > 0 && (
339-
<SecondaryCard icon={FaFolderOpen} title={<AnchorTitle title="Repositories" />}>
340-
<RepositoryCard maxInitialDisplay={4} repositories={repositories} />
341-
</SecondaryCard>
342-
)}
328+
{['project', 'user', 'organization'].includes(type) && repositories.length > 0 && (
329+
<SecondaryCard icon={FaFolderOpen} title={<AnchorTitle title="Repositories" />}>
330+
<RepositoryCard maxInitialDisplay={4} repositories={repositories} />
331+
</SecondaryCard>
332+
)}
343333
{type === 'program' && modules.length > 0 && (
344334
<SecondaryCard
345335
icon={FaFolderOpen}

0 commit comments

Comments
 (0)