Skip to content

Commit f02d9ab

Browse files
committed
fix: added logging and clean up file traversal
1 parent 8249570 commit f02d9ab

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

linters/typescript/src/context_linter.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class ContextLinter {
7070
if (await fileExists(rootContextFile)) {
7171
const content = await fs.promises.readFile(rootContextFile, 'utf-8');
7272
const result = await this.lintMarkdownFile(content, rootContextFile);
73-
this.printValidationResult(result, rootContextFile);
73+
this.printValidationResult(result, rootContextFile, this.logLevel === LogLevel.DEBUG);
7474
isValid = isValid && result.isValid;
7575
}
7676

@@ -157,7 +157,7 @@ export class ContextLinter {
157157
continue;
158158
}
159159

160-
this.printValidationResult(result, fullPath);
160+
this.printValidationResult(result, fullPath, this.logLevel === LogLevel.DEBUG);
161161
isValid = isValid && result.isValid;
162162
}
163163

@@ -317,31 +317,31 @@ export class ContextLinter {
317317
* Print the validation result for a .context file
318318
* @param result The validation result
319319
* @param filePath The path of the file
320+
* @param isDebug Whether the linter is in debug mode
320321
*/
321-
private printValidationResult(result: ValidationResult, filePath: string): void {
322+
private printValidationResult(result: ValidationResult, filePath: string, isDebug: boolean): void {
322323
const relativePath = this.normalizePath(path.relative(process.cwd(), filePath));
323324
this.log(LogLevel.INFO, `Linting file: ${relativePath}`);
324325

326+
if (isDebug) {
327+
this.log(LogLevel.INFO, '(Debug mode: ON)');
328+
}
329+
325330
// Display main context coverage information at INFO level
326331
this.log(LogLevel.INFO, `Main context: ${result.coveragePercentage.toFixed(2)}% (${result.coveredFields}/${result.totalFields} top level fields)`);
327332

328-
// Display section names at INFO level
329-
const sectionNames = Object.keys(result.sections);
330-
if (sectionNames.length > 0) {
331-
this.log(LogLevel.INFO, 'Sections:');
332-
sectionNames.forEach(sectionName => {
333-
this.log(LogLevel.INFO, ` - ${sectionName}`);
334-
});
335-
}
336-
337-
// Display detailed section coverage information at DEBUG level
338-
if (this.logLevel === LogLevel.DEBUG) {
339-
for (const [sectionName, sectionResult] of Object.entries(result.sections)) {
340-
this.log(LogLevel.DEBUG, `|- ${sectionName}: ${sectionResult.coveragePercentage.toFixed(2)}% (${sectionResult.coveredFields}/${sectionResult.totalFields} fields)`);
333+
// Display detailed section coverage information
334+
let incompleteSections = false;
335+
for (const [sectionName, sectionResult] of Object.entries(result.sections)) {
336+
if (isDebug || sectionResult.coveragePercentage < 100) {
337+
this.log(LogLevel.INFO, `|- ${sectionName}: ${sectionResult.coveragePercentage.toFixed(2)}% (${sectionResult.coveredFields}/${sectionResult.totalFields} fields)`);
338+
if (sectionResult.coveragePercentage < 100) {
339+
incompleteSections = true;
340+
}
341341
}
342342
}
343343

344-
if (!result.isValid) {
344+
if (!result.isValid || incompleteSections) {
345345
this.log(LogLevel.WARN, `⚠️ File has coverage warnings`);
346346
}
347347

linters/typescript/src/contextdocs_linter.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ export class ContextdocsLinter {
3737

3838
const frontmatterLinksResult = this.lintFrontmatter(frontmatter);
3939
const similarLinksResult = this.checkSimilarLinks(markdownContent, frontmatterLinksResult.links);
40-
4140
this.log(LogLevel.INFO, '- Validating YAML front matter structure');
42-
this.log(LogLevel.INFO, '- Checking for similar links in markdown content');
4341

4442
if (!frontmatterLinksResult.isValid || !similarLinksResult) {
4543
this.log(LogLevel.WARN, '⚠️ File has validation warnings');

0 commit comments

Comments
 (0)