Skip to content

Commit f780f5a

Browse files
committed
feat: add cyclomatic complexity to leaderboard
1 parent 93c1e09 commit f780f5a

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/components/leaderboard/Leaderboard.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ const Leaderboard: React.FC<LeaderboardProps> = ({ benchmarkId }) => {
5555
return 1;
5656
}
5757
return 0;
58+
case 'cyclomaticComplexity':
59+
if (row1.cyclomaticComplexity! < row2.cyclomaticComplexity!) {
60+
return -1;
61+
}
62+
if (row1.cyclomaticComplexity! > row2.cyclomaticComplexity!) {
63+
return 1;
64+
}
65+
return 0;
5866
}
5967
return 0;
6068
}
@@ -240,6 +248,20 @@ const Leaderboard: React.FC<LeaderboardProps> = ({ benchmarkId }) => {
240248
/>
241249
</div>
242250
</th>
251+
<th
252+
scope="col"
253+
className="dark:text-gray-100 px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
254+
onClick={() => setSortedField('cyclomaticComplexity')}
255+
>
256+
<div className="flex">
257+
Cyclomatic complexity
258+
<img
259+
className="w-4 h-4 ml-2"
260+
alt="Sort by lint score"
261+
src="https://image.flaticon.com/icons/png/512/162/162735.png"
262+
/>
263+
</div>
264+
</th>
243265
<th
244266
scope="col"
245267
className="dark:text-gray-100 px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
@@ -313,6 +335,9 @@ const Leaderboard: React.FC<LeaderboardProps> = ({ benchmarkId }) => {
313335
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
314336
{row.execDuration}
315337
</td>
338+
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
339+
{row.cyclomaticComplexity}
340+
</td>
316341
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
317342
{row.duplicatedSubmissions
318343
? row.duplicatedSubmissions.length

src/components/leaderboard/LeaderboardModel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default class LeaderboardModel {
66
memUsage: number | undefined;
77
execDuration: number | undefined;
88
createdAt: string | undefined;
9+
cyclomaticComplexity: number | undefined;
910
duplicatedSubmissions: [] | undefined;
1011
user:
1112
| {

0 commit comments

Comments
 (0)