Skip to content

Commit 7b850e8

Browse files
authored
feat(scoring): add language-specific causes of death (#19)
* feat(scoring): add language-specific causes of death Fixes #10 * test: prevent tie with 'Abandoned for a shinier idea' rule in language tests
1 parent b7bc93b commit 7b850e8

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

src/lib/scoring.test.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,50 @@ test('"dependencies" returns dependency hell', () => {
267267
const repo = buildRepo({ lastCommitMessage: 'update dependencies', lastCommitDate: new Date().toISOString() })
268268
assert.equal(generateLastWords(repo), 'trapped in dependency hell')
269269
})
270+
271+
// ── language-specific causes ───────────────────────────────────────
272+
273+
test('Ruby repo idle >365 days → Gemfile quip', () => {
274+
const repo = buildRepo({
275+
language: 'Ruby',
276+
lastCommitDate: '2023-01-01T00:00:00.000Z',
277+
isArchived: false,
278+
isFork: false,
279+
openIssuesCount: 2,
280+
stargazersCount: 5,
281+
forksCount: 0,
282+
description: 'a gem that time forgot',
283+
})
284+
const cause = determineCauseOfDeath(repo)
285+
assert.equal(cause, 'Gemfile.lock never unlocked')
286+
})
287+
288+
test('Perl repo returns Perl-specific cause', () => {
289+
const repo = buildRepo({
290+
language: 'Perl',
291+
lastCommitDate: '2024-01-01T00:00:00.000Z',
292+
isArchived: false,
293+
isFork: false,
294+
openIssuesCount: 2,
295+
stargazersCount: 5,
296+
forksCount: 0,
297+
description: 'a Perl tool',
298+
})
299+
const cause = determineCauseOfDeath(repo)
300+
assert.equal(cause, 'Nobody could read it, including the author')
301+
})
302+
303+
test('Objective-C repo idle >365 days returns Swift quip', () => {
304+
const repo = buildRepo({
305+
language: 'Objective-C',
306+
lastCommitDate: '2022-01-01T00:00:00.000Z',
307+
isArchived: false,
308+
isFork: false,
309+
openIssuesCount: 2,
310+
stargazersCount: 5,
311+
forksCount: 0,
312+
description: 'an old iOS lib',
313+
})
314+
const cause = determineCauseOfDeath(repo)
315+
assert.equal(cause, 'Swift happened')
316+
})

src/lib/scoring.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,30 @@ export function determineCauseOfDeath(repo: RepoData): string {
9292
score: isJS && daysSince > 365 ? 5 : 0,
9393
cause: 'Lost in dependency hell',
9494
},
95+
{
96+
score: repo.language?.toLowerCase() === 'ruby' && daysSince > 365 ? 4 : 0,
97+
cause: 'Gemfile.lock never unlocked',
98+
},
99+
{
100+
score: repo.language?.toLowerCase() === 'python' && daysSince > 365 ? 4 : 0,
101+
cause: 'Pip froze, then everything else did',
102+
},
103+
{
104+
score: repo.language?.toLowerCase() === 'php' && daysSince > 365 ? 4 : 0,
105+
cause: 'Died of PHP fatigue',
106+
},
107+
{
108+
score: repo.language?.toLowerCase() === 'perl' ? 5 : 0,
109+
cause: 'Nobody could read it, including the author',
110+
},
111+
{
112+
score: repo.language?.toLowerCase() === 'coffeescript' ? 5 : 0,
113+
cause: 'Outlived by the thing it inspired',
114+
},
115+
{
116+
score: repo.language?.toLowerCase() === 'objective-c' && daysSince > 365 ? 5 : 0,
117+
cause: 'Swift happened',
118+
},
95119
{
96120
score: descLower.includes('microservice') || descLower.includes('enterprise') ? 5 : 0,
97121
cause: 'Killed by overengineering',

0 commit comments

Comments
 (0)