@@ -133,34 +133,32 @@ export class ContextLinter {
133
133
*/
134
134
private async handleContextFilesRecursively ( directoryPath : string ) : Promise < boolean > {
135
135
let isValid = true ;
136
- const contextFiles = await getContextFiles ( directoryPath ) ;
136
+ const contextFiles = await getContextFiles ( directoryPath , ( filePath , relativeTo ) => this . contextignoreLinter . isIgnored ( filePath , relativeTo ) ) ;
137
137
138
138
for ( const filePath of contextFiles ) {
139
- if ( ! this . contextignoreLinter . isIgnored ( filePath , directoryPath ) ) {
140
- const fullPath = path . join ( directoryPath , filePath ) ;
141
- const fileContent = await fs . promises . readFile ( fullPath , 'utf-8' ) ;
142
- const fileExtension = path . extname ( fullPath ) ;
143
- let result : ValidationResult ;
144
-
145
- switch ( fileExtension ) {
146
- case '.md' :
147
- result = await this . lintMarkdownFile ( fileContent , fullPath ) ;
148
- break ;
149
- case '.yaml' :
150
- case '.yml' :
151
- result = await this . lintYamlFile ( fileContent , fullPath ) ;
152
- break ;
153
- case '.json' :
154
- result = await this . lintJsonFile ( fileContent , fullPath ) ;
155
- break ;
156
- default :
157
- this . log ( LogLevel . WARN , `Unsupported file extension: ${ fileExtension } ` ) ;
158
- continue ;
159
- }
160
-
161
- this . printValidationResult ( result , fullPath ) ;
162
- isValid = isValid && result . isValid ;
139
+ const fullPath = path . join ( directoryPath , filePath ) ;
140
+ const fileContent = await fs . promises . readFile ( fullPath , 'utf-8' ) ;
141
+ const fileExtension = path . extname ( fullPath ) ;
142
+ let result : ValidationResult ;
143
+
144
+ switch ( fileExtension ) {
145
+ case '.md' :
146
+ result = await this . lintMarkdownFile ( fileContent , fullPath ) ;
147
+ break ;
148
+ case '.yaml' :
149
+ case '.yml' :
150
+ result = await this . lintYamlFile ( fileContent , fullPath ) ;
151
+ break ;
152
+ case '.json' :
153
+ result = await this . lintJsonFile ( fileContent , fullPath ) ;
154
+ break ;
155
+ default :
156
+ this . log ( LogLevel . WARN , `Unsupported file extension: ${ fileExtension } ` ) ;
157
+ continue ;
163
158
}
159
+
160
+ this . printValidationResult ( result , fullPath ) ;
161
+ isValid = isValid && result . isValid ;
164
162
}
165
163
166
164
// Recursively process subdirectories
@@ -180,11 +178,13 @@ export class ContextLinter {
180
178
* @param directoryPath The path of the directory to check for ignored files
181
179
*/
182
180
private logIgnoredFiles ( directoryPath : string ) : void {
183
- const ignoredFiles = this . contextignoreLinter . getIgnoredFiles ( directoryPath ) ;
184
- if ( ignoredFiles . length > 0 ) {
185
- this . log ( LogLevel . INFO , '\nIgnored files:' ) ;
186
- for ( const file of ignoredFiles ) {
187
- this . log ( LogLevel . INFO , ` ${ this . normalizePath ( file ) } ` ) ;
181
+ if ( this . logLevel === LogLevel . DEBUG ) {
182
+ const ignoredFiles = this . contextignoreLinter . getIgnoredFiles ( directoryPath ) ;
183
+ if ( ignoredFiles . length > 0 ) {
184
+ this . log ( LogLevel . DEBUG , '\nIgnored files:' ) ;
185
+ for ( const file of ignoredFiles ) {
186
+ this . log ( LogLevel . DEBUG , ` ${ this . normalizePath ( file ) } ` ) ;
187
+ }
188
188
}
189
189
}
190
190
}
@@ -262,7 +262,7 @@ export class ContextLinter {
262
262
* @returns A ValidationResult object
263
263
*/
264
264
private async lintYamlFile ( content : string , filePath : string ) : Promise < ValidationResult > {
265
- this . log ( LogLevel . INFO , ' - Validating YAML structure' ) ;
265
+ this . log ( LogLevel . DEBUG , ' - Validating YAML structure' ) ;
266
266
267
267
try {
268
268
const yamlData = this . parseYaml ( content ) ;
@@ -291,7 +291,7 @@ export class ContextLinter {
291
291
* @returns A ValidationResult object
292
292
*/
293
293
private async lintJsonFile ( content : string , filePath : string ) : Promise < ValidationResult > {
294
- this . log ( LogLevel . INFO , ' - Validating JSON structure' ) ;
294
+ this . log ( LogLevel . DEBUG , ' - Validating JSON structure' ) ;
295
295
296
296
try {
297
297
const jsonData = JSON . parse ( content ) as Record < string , unknown > ;
@@ -322,10 +322,23 @@ export class ContextLinter {
322
322
const relativePath = this . normalizePath ( path . relative ( process . cwd ( ) , filePath ) ) ;
323
323
this . log ( LogLevel . INFO , `Linting file: ${ relativePath } ` ) ;
324
324
325
- this . log ( LogLevel . INFO , `main context: ${ result . coveragePercentage . toFixed ( 2 ) } % (${ result . coveredFields } /${ result . totalFields } top level fields)` ) ;
325
+ // Display main context coverage information at INFO level
326
+ this . log ( LogLevel . INFO , `Main context: ${ result . coveragePercentage . toFixed ( 2 ) } % (${ result . coveredFields } /${ result . totalFields } top level fields)` ) ;
326
327
327
- for ( const [ sectionName , sectionResult ] of Object . entries ( result . sections ) ) {
328
- this . log ( LogLevel . INFO , `|- ${ sectionName } : ${ sectionResult . coveragePercentage . toFixed ( 2 ) } % (${ sectionResult . coveredFields } /${ sectionResult . totalFields } fields)` ) ;
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)` ) ;
341
+ }
329
342
}
330
343
331
344
if ( ! result . isValid ) {
0 commit comments