getOptionsFile method

File getOptionsFile (
  1. Folder root,
  2. {bool crawlUp: false}

Return the analysis options file from which options should be read, or null if there is no analysis options file for code in the given root.

The given root directory will be searched first. If no file is found and if crawlUp is true, then enclosing directories will be searched.


File getOptionsFile(Folder root, {bool crawlUp = false}) {
  Resource resource;
  for (Folder folder = root; folder != null; folder = folder.parent) {
    resource = folder.getChild(AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE);
    if (resource.exists || !crawlUp) {
  if (resource is File && resource.exists) {
    return resource;
  return null;