Lints a config file for syntactical and semantical correctness.

@param array $config         The parsed configuration to lint
@param bool  $verifyLogFiles Also verfy whether the log files are accessible

@return array
491668
public static function lint($config, $verifyLogFiles = false)
    {
        $valid = true;
        $checks = [];

        // Valid YAML
        $checks['valid_yaml'] = [
            'message' => 'Is a valid YAML file',
        ];
        try {
            $config = self::parse($config);
            $checks['valid_yaml']['status'] = 'ok';
        } catch (\Exception $e) {
            $valid = false;
            $checks['valid_yaml']['status'] = 'fail';
            $checks['valid_yaml']['error'] = $e->getMessage();
        }
        try {
            // Valid structure
            $checks['valid_structure'] = self::lintValidProperties($config);
            if ($checks['valid_structure']['status'] == 'fail') {
                throw new \Exception();
            }

            // Valid config values
            $checks['valid_settings'] = self::lintValidSettingsValues($config);
            if ($checks['valid_settings']['status'] == 'fail') {
                throw new \Exception();
            }

            // Validate log collections (each)

            $checks['log_collections'] = [
                'message' => 'Checking log collections',
            ];
            try {
                foreach ($config['logs'] as $logCollectionName => $logCollection) {
                    $checks['log_collections']['sub_checks'][$logCollectionName] = self::lintLogCollection($logCollectionName, $logCollection);
                    if ($checks['log_collections']['sub_checks'][$logCollectionName]['status'] == 'fail') {
                        throw new \Exception();
                    }
                }
                foreach ($config['logs'] as $logCollectionName => $logCollection) {
                    $checks['log_collections']['checks'][$logCollectionName] = self::lintLogCollection($logCollectionName, $logCollection, $verifyLogFiles);
                    if ($checks['log_collections']['checks'][$logCollectionName]['status'] == 'fail') {
                        throw new \Exception();
                    }
                }
                $checks['log_collections']['status'] = 'ok';
            } catch (\Exception $e) {
                $checks['log_collections']['status'] = 'fail';
                $checks['log_collections']['error'] = $e->getMessage();
                $valid = false;
            }
        } catch (\Exception $e) {
            $valid = false;
        }

        return [
            'valid'  => $valid,
            'checks' => $checks,
        ];
    }
1346023
protected function loadInstalledComponentsConfig(array $config = []) : array
    {
        $env    = $this->env === self::WEB ? 'web' : 'console';
        $config = FileHelper::loadExtensionsFiles('config/main.php',   $config);
        $config = FileHelper::loadExtensionsFiles("config/{$env}.php", $config);
        return $config;
    }
580223
public function checksGroups(array $config)
    {
        $this->writeln('<info>Updating groups and their rights.</info>', OutputInterface::VERBOSITY_VERBOSE);

        foreach ($config as $identifier => $rights) {
            $group = $this->em->getRepository(Group::class)->findOneBy(['_name' => $identifier]);
            if (null === $group) {
                $group = new Group();
                $group->setName($identifier)
                    ->setDescription(Collection::get($rights, 'description', $identifier));
                $this->em->persist($group);
                $this->em->flush($group);
            }

            $this->writeln(sprintf(' - Group `%s`', $identifier), OutputInterface::VERBOSITY_VERY_VERBOSE);
            $this->updateRights($group, $rights);
        }

        return $this;
    }
619791
static public function factory($config = array()) {
        if (is_string($config)) {
            // Assume $config is a filename
            $filename = $config;
            $config = array(
                'timestampFormat' => 'Y-m-d',
                array(
                    'writerName' => 'Stream',
                    'writerParams' => array(
                        'stream' => self::_getLoggingDirectory() . DIRECTORY_SEPARATOR . $filename
                    )
                )
            );
        }
        return parent::factory($config);
    }
617395
function validateConfig(config) {
  debug('Validating config')

  const deprecatedConfig = {
    gitDir: "lint-staged now automatically resolves '.git' directory.",
    verbose: `Use the command line flag ${chalk.bold('--debug')} instead.`
  }

  const errors = []

  try {
    schema.validateSync(config, { abortEarly: false, strict: true })
  } catch (error) {
    error.errors.forEach(message => errors.push(formatError(message)))
  }

  if (isObject(config.linters)) {
    Object.keys(config.linters).forEach(key => {
      if (
        (!isArray(config.linters[key]) || config.linters[key].some(item => !isString(item))) &&
        !isString(config.linters[key])
      ) {
        errors.push(
          createError(`linters[${key}]`, 'Should be a string or an array of strings', key)
        )
      }
    })
  }

  Object.keys(config)
    .filter(key => !defaultConfig.hasOwnProperty(key))
    .forEach(option => {
      if (deprecatedConfig.hasOwnProperty(option)) {
        logDeprecation(option, deprecatedConfig[option])
        return
      }

      unknownValidationReporter(config, option)
    })

  if (errors.length) {
    throw new Error(errors.join('\n'))
  }

  return config
}
561349
function lintMethod (mtd, file, config, cb, configPath) {
	let runConfig = transformConfig(config);

	if (typeof cb !== 'function') {
		cb = function () {};
	}

	try {
		let results = sassLint[mtd](file, runConfig, configPath);

		if (mtd !== 'lintFiles') {
			if (!Array.isArray(results)) {
				results = [results];
			}
		}

		let data = {
			results,
			errorCount: sassLint.errorCount(results),
			warningCount: sassLint.warningCount(results)
		};

		cb(null, data);
	} catch (err) {
		cb(err);
	}
}
447630
protected function maybeInvalidConfig(Config $config): ?Error
    {
        $groups = (array) $config->get('groups');

        return empty($groups)
            ? ResultFactory::makeError($this, ['***** Experimental *****', 'Groups is empty.'])
            : null;
    }
1259981
private function normalizeConfig(array $config)
    {
        // Backwards compatibility with old config format: `toolstack` is
        // changed to application `type` and `build`.`flavor`.
        if (isset($config['toolstack'])) {
            if (!strpos($config['toolstack'], ':')) {
                throw new InvalidConfigException("Invalid value for 'toolstack'");
            }
            list($config['type'], $config['build']['flavor']) = explode(':', $config['toolstack'], 2);
        }

        // The `web` section has changed to `web`.`locations`.
        if (isset($config['web']['document_root']) && empty($config['web']['locations'])) {
            $oldConfig = $config['web'] + $this->getOldWebDefaults();

            $location = &$config['web']['locations']['/'];

            $location['root'] = $oldConfig['document_root'];
            $location['expires'] = $oldConfig['expires'];
            $location['passthru'] = $oldConfig['passthru'];
            $location['allow'] = true;

            foreach ($oldConfig['whitelist'] as $pattern) {
                $location['allow'] = false;
                $location['rules'][$pattern]['allow'] = true;
            }

            foreach ($oldConfig['blacklist'] as $pattern) {
                $location['rules'][$pattern]['allow'] = false;
            }
        }

        return $config;
    }
1281863
private function prepareUploadConfig(Config $config)
    {
        $options = [];

        if (isset($this->config['encrypt']) && $this->config['encrypt']) {
            $options['params']['ServerSideEncryption'] = 'AES256';
        }

        if ($config->has('params')) {
            $options['params'] = $config->get('params');
        }

        if ($config->has('visibility')) {
            $options['params']['ACL'] = $this->normalizeVisibility($config->get('visibility'));
        }

        return $options;
    }
180635
protected function isParsedConfigValid(array $config, array $required)
    {
        $inConfig = count(array_intersect_key(array_flip($required), array_filter($config)));

        return $inConfig === count($required);
    }
1090951
protected function parseConfig($config)
    {
        $parsed = [];

        foreach ($config as $key=>$value) {
            if ($value instanceof XType) {
                $parsed[$key] = $value;
                continue;
            }
            $parsed[$key] = $this->stringToType($value);
        }

        return $parsed;
    }
270488
public function initModules(Config $config)
    {
        $moduleLoader = new ModuleLoader($this->getDI());
        //registers modules defined in modules.php file
        $modulesFile = $config->application->configDir
            . ModuleLoader::MODULE_STATIC_FILE;
        /**
         * For non-default environment modules are being dumped in each application start
         */
        if (!file_exists($modulesFile) || $this->getDI()->get('environment') != Constants::DEFAULT_ENV) {
            $modules = $moduleLoader->dump(
                $config->application->moduleDir,
                $config->application->configDir
            );
        } else {
            $modules = require $modulesFile;
        }
        if (!is_array($modules)) {
            throw new InvalidModulesListException();
        }
        $this->getApplication()->registerModules($modules);

        //prepares modules configurations
        foreach ($this->getApplication()->getModules() as $module) {
            $moduleConfigFile = dirname($module['path'])
                . DIRECTORY_SEPARATOR
                . 'config'
                . DIRECTORY_SEPARATOR
                . 'config.php';
            if (file_exists($moduleConfigFile)) {
                $moduleConfig = require $moduleConfigFile;
                if (is_array($moduleConfig)) {
                    $config->merge($moduleConfig);
                }
            }
        }

        $this->getDI()->set('modules', function() {
            return $this->getApplication()->getModules();
        });
    }
929790
public function lint($files = [], $cache = true)
    {
        if (empty($files)) {
            $files = $this->getFiles();
        }

        $processCallback = is_callable($this->processCallback) ? $this->processCallback : function () {
        };

        $errors = [];
        $running = [];
        $newCache = [];

        while (!empty($files) || !empty($running)) {
            for ($i = count($running); !empty($files) && $i < $this->processLimit; ++$i) {
                $file = array_shift($files);
                $filename = $file->getRealPath();
                $relativePathname = $file->getRelativePathname();
                if (!isset($this->cache[$relativePathname]) || $this->cache[$relativePathname] !== md5_file($filename)) {
                    $lint = $this->createLintProcess($filename);
                    $running[$filename] = [
                        'process' => $lint,
                        'file' => $file,
                        'relativePath' => $relativePathname,
                    ];
                    $lint->start();
                } else {
                    $newCache[$relativePathname] = $this->cache[$relativePathname];
                }
            }

            foreach ($running as $filename => $item) {
                /** @var Lint $lint */
                $lint = $item['process'];
                if ($lint->isRunning()) {
                    continue;
                }

                unset($running[$filename]);
                if ($lint->hasSyntaxError()) {
                    $processCallback('error', $item['file']);
                    $errors[$filename] = array_merge(['file' => $filename], $lint->getSyntaxError());
                } else {
                    $newCache[$item['relativePath']] = md5_file($filename);
                    $processCallback('ok', $item['file']);
                }
            }
        }

        $cache && Cache::put($newCache);

        return $errors;
    }
1294730
private function verifyOrBuildConfigFile()
    {
        $configFile = $this->cachePath . DIRECTORY_SEPARATOR . 'cache_config';
        if (!\file_exists($configFile) || !\is_readable($configFile)) {
            //no cache file so we assume a new caching place: creating config file
            $config = [
                'levels' => $this->levels,
                'codec' => get_class($this->codec),
                'hashalgo' => get_class($this->hashAlgo)
            ];

            file_put_contents($configFile, serialize($config));

            return $this;
        }

        $config = unserialize(file_get_contents($configFile));
        if ($config['levels'] !== $this->levels) {
            throw new \LogicException('Levels set (' . $this->levels . ') and one in config (' . $config['levels'] . ') mismatch.');
        }

        if ($config['codec'] !== get_class($this->codec)) {
            throw new \LogicException('Codec set (' . get_class($this->codec) . ') and one in config (' . $config['codec'] . ') mismatch.');
        }

        if ($config['hashalgo'] !== get_class($this->hashAlgo)) {
            throw new \LogicException('Hashing algorithm set (' . get_class($this->hashAlgo) . ') and one in config (' . $config['hashalgo'] . ') mismatch.');
        }

        return $this;
    }
883261
public function lintFileSets() {
    $this->say("Validating twig syntax for all custom modules and themes...");

    /** @var \Acquia\Blt\Robo\Filesets\FilesetManager $fileset_manager */
    $fileset_manager = $this->getContainer()->get('filesetManager');
    $fileset_ids = $this->getConfigValue('validate.twig.filesets');
    $filesets = $fileset_manager->getFilesets($fileset_ids);
    $this->executeTwigLintCommandAgainstFilesets($filesets);
  }
785455
public function setLogConfig(array $logConfig)
    {
        $this->logConfig = $logConfig;

        $this->hostConfig = array_merge($this->hostConfig, ['LogConfig' => $logConfig]);

        return $this;
    }
872546
public static function config($config = []) {
		if (!$config) {
			return ['rules' => static::$_rules];
		}
		foreach ($config as $key => $val) {
			if (isset(static::${'_' . $key})) {
				static::${'_' . $key} = $val + static::${'_' . $key};
			}
		}
	}