@@ -133,34 +133,32 @@ export class ContextLinter {
133133 */
134134 private async handleContextFilesRecursively ( directoryPath : string ) : Promise < boolean > {
135135 let isValid = true ;
136- const contextFiles = await getContextFiles ( directoryPath ) ;
136+ const contextFiles = await getContextFiles ( directoryPath , ( filePath , relativeTo ) => this . contextignoreLinter . isIgnored ( filePath , relativeTo ) ) ;
137137
138138 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 ;
163158 }
159+
160+ this . printValidationResult ( result , fullPath ) ;
161+ isValid = isValid && result . isValid ;
164162 }
165163
166164 // Recursively process subdirectories
@@ -180,11 +178,13 @@ export class ContextLinter {
180178 * @param directoryPath The path of the directory to check for ignored files
181179 */
182180 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+ }
188188 }
189189 }
190190 }
@@ -262,7 +262,7 @@ export class ContextLinter {
262262 * @returns A ValidationResult object
263263 */
264264 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' ) ;
266266
267267 try {
268268 const yamlData = this . parseYaml ( content ) ;
@@ -291,7 +291,7 @@ export class ContextLinter {
291291 * @returns A ValidationResult object
292292 */
293293 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' ) ;
295295
296296 try {
297297 const jsonData = JSON . parse ( content ) as Record < string , unknown > ;
@@ -322,10 +322,23 @@ export class ContextLinter {
322322 const relativePath = this . normalizePath ( path . relative ( process . cwd ( ) , filePath ) ) ;
323323 this . log ( LogLevel . INFO , `Linting file: ${ relativePath } ` ) ;
324324
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)` ) ;
326327
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+ }
329342 }
330343
331344 if ( ! result . isValid ) {
0 commit comments