|
| 1 | +/** |
| 2 | + * Spam rules — patterns that indicate fraudulent or low-quality submissions. |
| 3 | + * |
| 4 | + * Category: spam |
| 5 | + * Evaluated after the spam scoring phase. |
| 6 | + */ |
| 7 | + |
| 8 | +import type { Rule } from '../src/rules/types.js'; |
| 9 | + |
| 10 | +const rules: Rule[] = [ |
| 11 | + { |
| 12 | + id: 'spam.high-score-reject', |
| 13 | + description: 'Reject issues with spam score above 0.85', |
| 14 | + category: 'spam', |
| 15 | + severity: 'reject', |
| 16 | + failureMessage: 'Issue has a very high spam score (> 0.85), indicating template-farmed or automated content.', |
| 17 | + evaluate: (ctx) => ctx.spamScore < 0.85, |
| 18 | + }, |
| 19 | + { |
| 20 | + id: 'spam.generic-title', |
| 21 | + description: 'Title should not be a generic/template title', |
| 22 | + category: 'spam', |
| 23 | + severity: 'penalize', |
| 24 | + weight: 0.4, |
| 25 | + failureMessage: 'Issue title appears to be generic or template-generated.', |
| 26 | + evaluate: (ctx) => { |
| 27 | + const generic = [ |
| 28 | + 'bug found', 'bug report', 'issue found', 'error found', |
| 29 | + 'problem found', 'bug', 'error', 'issue', 'problem', |
| 30 | + 'found a bug', 'found an issue', 'found error', |
| 31 | + ]; |
| 32 | + return !generic.includes(ctx.title.trim().toLowerCase()); |
| 33 | + }, |
| 34 | + }, |
| 35 | + { |
| 36 | + id: 'spam.body-is-title-repeat', |
| 37 | + description: 'Body should not be a simple repetition of the title', |
| 38 | + category: 'spam', |
| 39 | + severity: 'penalize', |
| 40 | + weight: 0.5, |
| 41 | + failureMessage: 'Issue body is essentially a copy of the title with no additional detail.', |
| 42 | + evaluate: (ctx) => { |
| 43 | + const titleNorm = ctx.title.toLowerCase().replace(/[^a-z0-9]/g, ''); |
| 44 | + const bodyNorm = ctx.body.toLowerCase().replace(/[^a-z0-9]/g, ''); |
| 45 | + if (bodyNorm.length === 0) return false; |
| 46 | + return titleNorm !== bodyNorm && !bodyNorm.startsWith(titleNorm); |
| 47 | + }, |
| 48 | + }, |
| 49 | + { |
| 50 | + id: 'spam.no-ai-filler', |
| 51 | + description: 'Body should not contain obvious AI-generated filler phrases', |
| 52 | + category: 'spam', |
| 53 | + severity: 'flag', |
| 54 | + failureMessage: 'Issue body contains phrases typical of AI-generated filler content.', |
| 55 | + evaluate: (ctx) => { |
| 56 | + const aiPhrases = [ |
| 57 | + 'as an ai', 'i cannot', 'delve into', 'it is important to note', |
| 58 | + 'in conclusion,', 'furthermore,', 'in summary,', |
| 59 | + 'this comprehensive', 'it\'s worth noting', |
| 60 | + ]; |
| 61 | + const lower = ctx.body.toLowerCase(); |
| 62 | + return !aiPhrases.some((p) => lower.includes(p)); |
| 63 | + }, |
| 64 | + }, |
| 65 | +]; |
| 66 | + |
| 67 | +export default rules; |
0 commit comments