Skip to content

Commit e17f55b

Browse files
committed
feat: enhance task fixing functionality with TaskFixResult interface and refactor applyBasicFixes method
1 parent d3db978 commit e17f55b

File tree

5 files changed

+31
-8
lines changed

5 files changed

+31
-8
lines changed

src/core/fixers/task.fixer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FixRecord, IFixerOptions, ITask } from '../../types/tasks';
1+
import { FixRecord, IFixerOptions, ITask, TaskFixResult } from '../../types/tasks';
22

33
import { fixPriority } from './priority.fixer';
44
import { fixStatus } from './status.fixer';
@@ -22,15 +22,15 @@ export class TaskFixer {
2222

2323
/**
2424
* Applies basic automatic fixes to common validation issues in a task object.
25-
* @param asObj - The original task object (not modified).
25+
* @param task - The original task object (not modified).
2626
* @returns An object containing the fixed task and an array of FixRecord objects describing the fixes applied.
2727
*/
28-
applyBasicFixes(asObj: ITask): { fixedTask: ITask; fixes: FixRecord[] } {
28+
applyBasicFixes(task: ITask): TaskFixResult {
2929
const fixes: FixRecord[] = [];
30-
const id = String(asObj.id);
30+
const id = String(task.id);
3131

3232
// Chain the immutable fixes
33-
let fixedTask = fixPriority(asObj, fixes, id);
33+
let fixedTask = fixPriority(task, fixes, id);
3434
fixedTask = fixStatus(fixedTask, fixes, id);
3535
fixedTask = fixDateField({
3636
nowIso: this.nowIso,

src/core/storage/task.manager.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ export class TaskManager implements ITaskStore, IChangelogStore {
168168
): void {
169169
const afterUnreleasedIndex = content.indexOf('\n', unreleasedIndex);
170170
if (afterUnreleasedIndex === -1) {
171-
this.logger.warn('Could not append entry to CHANGELOG.md: no newline found after "Unreleased" section.', { entry });
171+
this.logger.warn(
172+
'Could not append entry to CHANGELOG.md: no newline found after "Unreleased" section.',
173+
{ entry },
174+
);
172175
return;
173176
}
174177

src/types/tasks/ITaskFixer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { FixRecord } from './FixRecord';
21
import { ITask } from './ITask';
2+
import { TaskFixResult } from './TaskFixResult';
33

44
/**
55
* Interface for automatically fixing common task validation issues.
@@ -42,5 +42,5 @@ export interface ITaskFixer {
4242
* // result.fixes contains descriptions of applied fixes
4343
* ```
4444
*/
45-
applyBasicFixes(task: ITask): { fixedTask: ITask; fixes: FixRecord[] };
45+
applyBasicFixes(task: ITask): TaskFixResult;
4646
}

src/types/tasks/TaskFixResult.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { FixRecord } from './FixRecord';
2+
import { ITask } from './ITask';
3+
4+
/**
5+
* Result of applying fixes to a task object.
6+
*
7+
* Contains both the corrected task and a record of what fixes were applied.
8+
*/
9+
export interface TaskFixResult {
10+
/**
11+
* The task object with fixes applied.
12+
*/
13+
fixedTask: ITask;
14+
15+
/**
16+
* Array of records describing what fixes were applied to the task.
17+
*/
18+
fixes: FixRecord[];
19+
}

src/types/tasks/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export * from './TaskStatus';
1313
export * from './TaskProviderType';
1414
export * from './IFixerOptions';
1515
export * from './FixRecord';
16+
export * from './TaskFixResult';
1617

1718
// Todo command types (task-specific commands)
1819
export * from './AddTaskArgs';

0 commit comments

Comments
 (0)