diff --git a/lib/init-action.js b/lib/init-action.js index 3cd5e4206..60390ec11 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -90261,22 +90261,6 @@ async function initConfig(features, inputs) { ); } const config = await initActionState(inputs, userConfig); - if (await features.getValue("ignore_generated_files" /* IgnoreGeneratedFiles */) && isCCR()) { - try { - const generatedFiles = await getGeneratedFiles(inputs.sourceRoot); - if (generatedFiles.length > 0) { - config.computedConfig["paths-ignore"] ??= []; - config.computedConfig["paths-ignore"].push(...generatedFiles); - logger.info( - `Detected ${generatedFiles.length} generated file(s), which will be excluded from analysis: ${generatedFiles.join(", ")}` - ); - } - } catch (error3) { - logger.info(`Cannot ignore generated files: ${getErrorMessage(error3)}`); - } - } else { - logger.debug(`Skipping check for generated files.`); - } if (config.analysisKinds.length === 1 && isCodeQualityEnabled(config)) { if (hasQueryCustomisation(config.computedConfig)) { throw new ConfigurationError( @@ -90299,6 +90283,22 @@ async function initConfig(features, inputs) { throw e; } } + if (await features.getValue("ignore_generated_files" /* IgnoreGeneratedFiles */) && isCCR()) { + try { + const generatedFiles = await getGeneratedFiles(inputs.sourceRoot); + if (generatedFiles.length > 0) { + config.computedConfig["paths-ignore"] ??= []; + config.computedConfig["paths-ignore"].push(...generatedFiles); + logger.info( + `Detected ${generatedFiles.length} generated file(s), which will be excluded from analysis: ${generatedFiles.join(", ")}` + ); + } + } catch (error3) { + logger.info(`Cannot ignore generated files: ${getErrorMessage(error3)}`); + } + } else { + logger.debug(`Skipping check for generated files.`); + } const { overlayDatabaseMode, useOverlayDatabaseCaching } = await getOverlayDatabaseMode( inputs.codeql, inputs.features, diff --git a/src/config-utils.ts b/src/config-utils.ts index 55d369de4..7ebda7032 100644 --- a/src/config-utils.ts +++ b/src/config-utils.ts @@ -916,27 +916,6 @@ export async function initConfig( const config = await initActionState(inputs, userConfig); - // If we are in CCR or the corresponding FF is enabled, try to determine - // which files in the repository are marked as generated and add them to - // the `paths-ignore` configuration. - if ((await features.getValue(Feature.IgnoreGeneratedFiles)) && isCCR()) { - try { - const generatedFiles = await getGeneratedFiles(inputs.sourceRoot); - - if (generatedFiles.length > 0) { - config.computedConfig["paths-ignore"] ??= []; - config.computedConfig["paths-ignore"].push(...generatedFiles); - logger.info( - `Detected ${generatedFiles.length} generated file(s), which will be excluded from analysis: ${generatedFiles.join(", ")}`, - ); - } - } catch (error) { - logger.info(`Cannot ignore generated files: ${getErrorMessage(error)}`); - } - } else { - logger.debug(`Skipping check for generated files.`); - } - // If Code Quality analysis is the only enabled analysis kind, then we will initialise // the database for Code Quality. That entails disabling the default queries and only // running quality queries. We do not currently support query customisations in that case. @@ -974,6 +953,27 @@ export async function initConfig( } } + // If we are in CCR or the corresponding FF is enabled, try to determine + // which files in the repository are marked as generated and add them to + // the `paths-ignore` configuration. + if ((await features.getValue(Feature.IgnoreGeneratedFiles)) && isCCR()) { + try { + const generatedFiles = await getGeneratedFiles(inputs.sourceRoot); + + if (generatedFiles.length > 0) { + config.computedConfig["paths-ignore"] ??= []; + config.computedConfig["paths-ignore"].push(...generatedFiles); + logger.info( + `Detected ${generatedFiles.length} generated file(s), which will be excluded from analysis: ${generatedFiles.join(", ")}`, + ); + } + } catch (error) { + logger.info(`Cannot ignore generated files: ${getErrorMessage(error)}`); + } + } else { + logger.debug(`Skipping check for generated files.`); + } + // The choice of overlay database mode depends on the selection of languages // and queries, which in turn depends on the user config and the augmentation // properties. So we need to calculate the overlay database mode after the