<commit_before>import is from '@sindresorhus/is';
import { logger } from '../logger';
import { RenovateConfig, ValidationMessage } from './common';
import * as configMassage from './massage';
import * as configMigration from './migration';
import * as configValidation from './validation';

export async function migrateAndValidate(
  config: RenovateConfig,
  input: RenovateConfig
): Promise<RenovateConfig> {
  logger.debug('migrateAndValidate()');
  try {
    const { isMigrated, migratedConfig } = configMigration.migrateConfig(input);
    if (isMigrated) {
      logger.debug(
        { oldConfig: input, newConfig: migratedConfig },
        'Config migration necessary'
      );
    } else {
      logger.debug('No config migration necessary');
    }
    const massagedConfig = configMassage.massageConfig(migratedConfig);
    logger.debug({ config: massagedConfig }, 'massaged config');
    const {
      warnings,
      errors,
    }: {
      warnings: ValidationMessage[];
      errors: ValidationMessage[];
    } = await configValidation.validateConfig(massagedConfig);
    // istanbul ignore if
    if (is.nonEmptyArray(warnings)) {
      logger.info({ warnings }, 'Found renovate config warnings');
    }
    if (is.nonEmptyArray(errors)) {
      logger.info({ errors }, 'Found renovate config errors');
    }
    massagedConfig.errors = (config.errors || []).concat(errors);
    if (!config.repoIsOnboarded) {
      massagedConfig.warnings = (config.warnings || []).concat(warnings);
    }
    return massagedConfig;
  } catch (err) /* istanbul ignore next */ {
    logger.debug({ config: input }, 'migrateAndValidate error');
    throw err;
  }
}
<commit_msg>logs: warn for config warnings<commit_after>import is from '@sindresorhus/is';
import { logger } from '../logger';
import { RenovateConfig, ValidationMessage } from './common';
import * as configMassage from './massage';
import * as configMigration from './migration';
import * as configValidation from './validation';

export async function migrateAndValidate(
  config: RenovateConfig,
  input: RenovateConfig
): Promise<RenovateConfig> {
  logger.debug('migrateAndValidate()');
  try {
    const { isMigrated, migratedConfig } = configMigration.migrateConfig(input);
    if (isMigrated) {
      logger.debug(
        { oldConfig: input, newConfig: migratedConfig },
        'Config migration necessary'
      );
    } else {
      logger.debug('No config migration necessary');
    }
    const massagedConfig = configMassage.massageConfig(migratedConfig);
    logger.debug({ config: massagedConfig }, 'massaged config');
    const {
      warnings,
      errors,
    }: {
      warnings: ValidationMessage[];
      errors: ValidationMessage[];
    } = await configValidation.validateConfig(massagedConfig);
    // istanbul ignore if
    if (is.nonEmptyArray(warnings)) {
      logger.warn({ warnings }, 'Found renovate config warnings');
    }
    if (is.nonEmptyArray(errors)) {
      logger.info({ errors }, 'Found renovate config errors');
    }
    massagedConfig.errors = (config.errors || []).concat(errors);
    if (!config.repoIsOnboarded) {
      massagedConfig.warnings = (config.warnings || []).concat(warnings);
    }
    return massagedConfig;
  } catch (err) /* istanbul ignore next */ {
    logger.debug({ config: input }, 'migrateAndValidate error');
    throw err;
  }
}

{'fraction_non_alphanumeric': 0.12808320950965824, 'fraction_numerical': 0.0, 'mean_word_length': 3.554803788903924, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '793049', 'n_tokens_mistral': 960, 'n_tokens_neox': 969, 'n_words': 236}