Skip to content

Commit 3e45c09

Browse files
committed
Merge branch 'main' into codex/editar-.gitignore-e-limpar-artefactos
2 parents 418e6b3 + 613ec22 commit 3e45c09

File tree

7 files changed

+53
-8
lines changed

7 files changed

+53
-8
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ TODO_REPORT.md
66
CHANGELOG.md
77
compile.txt
88
.env
9+
.yarn/
10+
dist/
11+
coverage/
12+
CHANGELOG.md
13+
compile.txt

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,4 @@ smart-todo-action/
135135
├── package.json
136136
├── tsconfig.json
137137
└── README.md
138-
```
138+
```

TODO_REPORT.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# 📌 TODO Report
2+
3+
Total unique TODOs: **12**
4+
5+
## TODO
6+
7+
- `inline.ts:14` — Refactor login logic @alice #auth type=refactor _( priority=high, due=2025-06-01 )_
8+
- `inline.ts:1` — Refatorar este método _( priority=high, due=2025-06-01 )_
9+
- `inline.ts:40` — improve retry logic for API errors _( priority=high )_
10+
- `inline.ts:1` — sFromContent.ts
11+
- `inline.ts:1` — sWithStructuredTags.ts
12+
- `inline.ts:1` — sWithStructuredTagsFromDir.ts
13+
- `inline.ts:1` — .ts
14+
- `inline.ts:2` — Refactor this logic to improve performance
15+
- `inline.ts:1` — Refactor this module
16+
17+
## FIXME
18+
19+
- `inline.ts:3` — Corrigir possível vazamento de memória
20+
- `inline.py:1` — Handle edge case
21+
22+
## BUG
23+
24+
- `inline.ts:6` — Corrigir lógica de ordenação _( due=2025-01-01 )_
25+

src/parser/extractTodos.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from 'fs';
22
import path from 'path';
33
import { TodoItem } from './types';
4+
import { normalizeTag } from '../utils/isTextFile';
45

56
const COMMENT_PATTERNS = [
67
{ ext: ['.ts', '.js', '.java', '.go'], pattern: /^\s*\/\/\s*(.*)$/ },
@@ -37,8 +38,9 @@ export function extractTodosFromFile(filePath: string): TodoItem[] {
3738
const comment = commentMatch[1];
3839
const tagMatch = comment.match(TAG_REGEX);
3940
if (tagMatch) {
40-
const [_, tag, metaRaw, text] = tagMatch;
41+
const [_, rawTag, metaRaw, text] = tagMatch;
4142
const metadata = metaRaw ? extractMetadata(metaRaw) : undefined;
43+
const tag = normalizeTag(rawTag) ?? rawTag;
4244
todos.push({
4345
file: filePath,
4446
line: idx + 1,

src/parser/extractTodosFromContent.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// src/parser/extractTodosFromContent.ts
22

33
import { TodoItem } from './types';
4+
import { normalizeTag } from '../utils/isTextFile';
45

56
const COMMENT_PATTERNS = [
67
{ ext: ['.ts', '.js', '.java', '.go'], pattern: /^\s*\/\/\s*(.*)$/ },
@@ -36,8 +37,9 @@ export function extractTodosFromString(content: string, ext: string): TodoItem[]
3637
const comment = commentMatch[1];
3738
const tagMatch = comment.match(TAG_REGEX);
3839
if (tagMatch) {
39-
const [_, tag, metaRaw, text] = tagMatch;
40+
const [_, rawTag, metaRaw, text] = tagMatch;
4041
const metadata = metaRaw ? extractMetadata(metaRaw) : undefined;
42+
const tag = normalizeTag(rawTag) ?? rawTag;
4143
todos.push({
4244
file: `inline${ext}`,
4345
line: idx + 1,

src/parser/extractTodosWithStructuredTagsFromDir.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ export function extractTodosWithStructuredTagsFromDir(dir: string): TodoItem[] {
2020
if (IGNORED_DIRS.includes(entry.name)) continue;
2121
walk(fullPath);
2222
} else if (entry.isFile()) {
23-
try {
24-
const fileTodos = extractTodosWithStructuredTags(fullPath);
25-
todos.push(...fileTodos);
26-
} catch {
27-
// opcional: log de ficheiros ignorados
23+
if (isTextFile(fullPath)) {
24+
try {
25+
const fileTodos = extractTodosWithStructuredTags(fullPath);
26+
todos.push(...fileTodos);
27+
} catch {
28+
// opcional: log de ficheiros ignorados
29+
}
2830
}
2931
}
3032
}

tests/extractTodosFromContent.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,13 @@ describe('extractTodosFromString', () => {
2828
due: '2025-06-01'
2929
});
3030
});
31+
32+
it('normalizes localized tags', () => {
33+
const content = `// À FAIRE: tarefa\n# À CORRIGER: problema`;
34+
const jsTodos = extractTodosFromString(content, '.js');
35+
const pyTodos = extractTodosFromString(content, '.py');
36+
37+
expect(jsTodos[0].tag).toBe('TODO');
38+
expect(pyTodos[0].tag).toBe('FIXME');
39+
});
3140
});

0 commit comments

Comments
 (0)