This routine is actually checking all the include patterns in
order to avoid scanning everything under base dir.
@since Ant 1.6
545554
private void checkIncludePatterns() {
        Map newroots = new HashMap();
        // put in the newroots map the include patterns without
        // wildcard tokens
        for (int i = 0; i < includes.length; i++) {
            if (FileUtil.isAbsolutePath(includes[i])) {
                //skip abs. paths not under basedir, if set:
                if (basedir != null
                    && !SelectorUtils.matchPatternStart(includes[i],
                    basedir.getAbsolutePath(), isCaseSensitive())) {
                    continue;
                }
            } else if (basedir == null) {
                //skip non-abs. paths if basedir == null:
                continue;
            }
            newroots.put(SelectorUtils.rtrimWildcardTokens(
                includes[i]), includes[i]);
        }
        if (newroots.containsKey("") && basedir != null) {
            // we are going to scan everything anyway
            scandir(basedir, "", true);
        } else {
            // only scan directories that can include matched files or
            // directories
            Iterator it = newroots.entrySet().iterator();

            File canonBase = null;
            if (basedir != null) {
                try {
                    canonBase = basedir.getCanonicalFile();
                } catch (IOException ex) {
                    throw new RuntimeException(ex);
                }
            }
            while (it.hasNext()) {
                Map.Entry entry = (Map.Entry) it.next();
                String currentelement = (String) entry.getKey();

                if (basedir == null && !FileUtil.isAbsolutePath(currentelement)) {
                    continue;
                }
                String originalpattern = (String) entry.getValue();
                File myfile = new File(basedir, currentelement);

                if (myfile.exists()) {
                    // may be on a case insensitive file system.  We want
                    // the results to show what's really on the disk, so
                    // we need to double check.
                    try {
                        String path = (basedir == null)
                            ? myfile.getCanonicalPath()
                            : FileUtil.removeLeadingPath(canonBase,
                            myfile.getCanonicalFile());
                        if (!path.equals(currentelement)) {
                            myfile = findFile(basedir, currentelement, true);
                            if (myfile != null && basedir != null) {
                                currentelement = FileUtil.removeLeadingPath(
                                    basedir, myfile);
                            }
                        }
                    } catch (IOException ex) {
                        throw new RuntimeException(ex);
                    }
                }
                if ((myfile == null || !myfile.exists()) && !isCaseSensitive()) {
                    File f = findFile(basedir, currentelement, false);
                    if (f != null && f.exists()) {
                        // adapt currentelement to the case we've
                        // actually found
                        currentelement = (basedir == null)
                            ? f.getAbsolutePath()
                            : FileUtil.removeLeadingPath(basedir, f);
                        myfile = f;
                    }
                }
                if (myfile != null && myfile.exists()) {
                    if (!followSymlinks
                        && isSymlink(basedir, currentelement)) {
                        continue;
                    }
                    if (myfile.isDirectory()) {
                        if (isIncluded(currentelement)
                            && currentelement.length() > 0) {
                            accountForIncludedDir(currentelement, myfile, true);
                        }  else {
                            if (currentelement.length() > 0) {
                                if (currentelement.charAt(currentelement
                                                          .length() - 1)
                                    != File.separatorChar) {
                                    currentelement =
                                        currentelement + File.separatorChar;
                                }
                            }
                            scandir(myfile, currentelement, true);
                        }
                    } else {
                        boolean included = isCaseSensitive()
                            ? originalpattern.equals(currentelement)
                            : originalpattern.equalsIgnoreCase(currentelement);
                        if (included) {
                            accountForIncludedFile(currentelement, myfile);
                        }
                    }
                }
            }
        }
    }
786451
def files_inspected(ext, delimiter = ',', remove = @config.working_dir)
        @path.is_a?(Array) ? @path.split(delimiter) : file_list(@path, ext, remove)
      end
625407
public function checkAllAction()
    {
        $batch = $this->loader->getTracker()->checkTrackRounds('trackCheckRoundsAll', $this->currentUser->getUserId());
        $this->_helper->BatchRunner($batch, $this->_('Checking round assignments for all tracks.'), $this->accesslog);

        $this->addSnippet('Track\\CheckRoundsInformation');
    }
544348
@Override
    public boolean isOrderDeterministic() {
        if ( ! super.isOrderDeterministic()) {
            return false;
        }
        IndexScanPlanNode index_scan = getInlineIndexScan();
        if ( ! index_scan.isOrderDeterministic()) {
            m_nondeterminismDetail = index_scan.m_nondeterminismDetail;
            return false;
        }
        return true;
    }
220870
private boolean includes(String identifier) {
    if (includes.isEmpty()) return !exclude(identifier);

    String includeMatch = null;
    String excludeMatch = null;
    for (String rule = identifier; rule != null; rule = enclosing(rule)) {
      if (excludes.contains(rule)) {
        excludeMatch = rule;
      }
      if (includes.contains(rule)) {
        includeMatch = rule;
      }
    }
    if (excludeMatch != null) {
      usedExcludes.add(excludeMatch);
      return false;
    }
    if (includeMatch != null) {
      usedIncludes.add(includeMatch);
      return true;
    }
    return false;
  }
956139
def ensure_clean(self):
        
        if not self.is_clean:
            raise WorkingTreeNotCleanError(compact("""
                The repository's local working tree ({local})
                contains changes to tracked files!
            """, local=format_path(self.local)))
556867
public static function ensureDefines()
    {
        if (defined('DIR_CORE')) {
            return;
        }
        
        // Define directory basenames
        define("DIR_PUBLIC_BASENAME", "public/");
        define("DIR_LIBS_BASENAME", "libs/");
        define("DIR_ADDONS_BASENAME", "addons/");
        define("DIR_DATA_BASENAME", "data/");
        define("DIR_CONTENT_BASENAME", "content/");
        define("DIR_CONFIG_BASENAME", "config/");
        define("DIR_TEMPLATES_BASENAME", "templates/");
        define("DIR_LOCALE_BASENAME", "locale/");
        
        // Define directories
        define(Xentriq::CONST_DIR_ASSUMED_ROOT, dirname(DIR_PUBLIC) . '/', false);
        
        define(Xentriq::CONST_DIR_CORE, dirname(__FILE__) . '/', false);
        define(Xentriq::CONST_DIR_LIBS, str_replace(DIR_PUBLIC_BASENAME, DIR_LIBS_BASENAME, DIR_PUBLIC) . '/');
        define(Xentriq::CONST_DIR_ADDONS, str_replace(DIR_PUBLIC_BASENAME, DIR_ADDONS_BASENAME, DIR_PUBLIC) . '/', false);
        define("DIR_DATA", str_replace(DIR_PUBLIC_BASENAME, DIR_DATA_BASENAME, DIR_PUBLIC) . '/', false);
        define("DIR_CONTENT", str_replace(DIR_PUBLIC_BASENAME, DIR_CONTENT_BASENAME, DIR_PUBLIC) . '/', false);
        define("DIR_CONFIG", str_replace(DIR_PUBLIC_BASENAME, DIR_CONFIG_BASENAME, DIR_PUBLIC) . '/', false);
        
        define("DIR_TEMPLATES", DIR_CONTENT . DIR_TEMPLATES_BASENAME);
        
        define("DIR_LOCALE", DIR_CORE . DIR_LOCALE_BASENAME);
        define("DIR_LOCALE_PROJECT", DIR_CONTENT . DIR_LOCALE_BASENAME);
        
        // Define extensions
        define("EXT_PAGE", ".xpage");
        define("EXT_PART", ".xpart");
        define("TEMPLATE_INDEX", 'index.xpage');
        
        define("EXT_CSS", ".css");
        define("EXT_SCSS", ".scss");
        define("EXT_SASS", ".sass");
        define("EXT_JS", ".js");
        define("EXT_PHP", ".php");
        define("EXT_XML", ".xml");
        define("EXT_JSON", ".json");
        define("EXT_AUTH", ".auth");
        
        // Define characters
        define("CHAR_SPACE", ' ');
        define("CHAR_CRLF", "\r\n");
        define("CHAR_SLASH", '/');
        define("CHAR_BACKSLASH", '\\');
        define("CHAR_OB", '[');
        define("CHAR_CB", ']');
        define("CHAR_OCB", '(');
        define("CHAR_CCB", ')');
        define("CHAR_OSB", '{');
        define("CHAR_CSB", '}');
        define("CHAR_SEMICOLON", ';');
        define("CHAR_QUOTE", '\'');
        define("CHAR_DOUBLE_QUOTE", '"');
        define("CHAR_BACKTICK", '`');
        
        define("GZIP_SUPPORTED", (substr_count(ArrayUtils::getArrayValueForKeyOrDefault($_SERVER, 'HTTP_ACCEPT_ENCODING', ''), 'gzip') > 0));
        
        // Define environment, defaults to `default`
        define("XENTRIQ_ENVIRONMENT", Utils::getEnvironmentVariable("XENTRIQ_ENVIRONMENT", "default"));
        
        // Define base DEBUG value to ensure proper output.
        define(Xentriq::CONST_DEBUG, Utils::getEnvironmentVariable(Xentriq::CONST_DEBUG, false), true);
        
        // Try to load configuration values from JSON configuration
        define(Xentriq::CONST_DEBUG, Config::getConfigurationValue('debug'));
        
        define("INDEX_FILE", 'index.php');
        define("USE_INDEX_FILE", Config::getConfigurationValueOrDefault('useIndexPhp', false));
        
        define("DISABLE_GZIP", Config::getConfigurationValueOrDefault('disableGzip', false));
        
        define("DISABLE_DEFAULT_RESPONSE_HEADERS", Config::getConfigurationValueOrDefault('disableDefaultResponseHeaders', false));
        
        define("URL_SITE", Request::getSiteUrl());
    }
326147
private String[] scan( FileSet fileSet )
    {
        File basedir = new File( fileSet.getDirectory() );
        if ( !basedir.exists() || !basedir.isDirectory() )
        {
            return null;
        }

        DirectoryScanner scanner = new DirectoryScanner();

        List<String> includes = fileSet.getIncludes();
        List<String> excludes = fileSet.getExcludes();

        if ( includes != null && includes.size() > 0 )
        {
            scanner.setIncludes( includes.toArray( new String[0] ) );
        }

        if ( excludes != null && excludes.size() > 0 )
        {
            scanner.setExcludes( excludes.toArray( new String[0] ) );
        }

        scanner.setBasedir( basedir );

        scanner.scan();
        return scanner.getIncludedFiles();
    }
1116820
@Override
    protected List<ChecksumFile> getFilesToProcess()
    {
        final List<ChecksumFile> filesToProcess = new ArrayList<ChecksumFile>();
        for ( final FileSet fileSet : fileSets )
        {
            final DirectoryScanner scanner = new DirectoryScanner();
            final String fileSetDirectory = (new File( fileSet.getDirectory() ) ).getPath();

            scanner.setBasedir( fileSetDirectory );
            String[] includes;
            if ( fileSet.getIncludes() != null && !fileSet.getIncludes().isEmpty() )
            {
                final List<String> fileSetIncludes = fileSet.getIncludes();
                includes = fileSetIncludes.toArray( new String[fileSetIncludes.size()] );
            }
            else
            {
                includes = DEFAULT_INCLUDES;
            }
            scanner.setIncludes( includes );

            if ( fileSet.getExcludes() != null && !fileSet.getExcludes().isEmpty() )
            {
                final List<String> fileSetExcludes = fileSet.getExcludes();
                scanner.setExcludes( fileSetExcludes.toArray( new String[fileSetExcludes.size()] ) );
            }

            scanner.addDefaultExcludes();

            scanner.scan();

            for ( String filePath : scanner.getIncludedFiles() )
            {
                filesToProcess.add( new ChecksumFile( (new File( fileSetDirectory ) ).getPath(), new File( fileSetDirectory, filePath ), null, null ) );
            }
            }

        return filesToProcess;
    }
328618
public void clean() {
        final Path bPath = FileSystems.getDefault().getPath(basePath);
        for (int i = 0; i < 3; i++) {
            try {
                final CleanUpFileVisitor visitor = new CleanUpFileVisitor();
                Files.walkFileTree(bPath, visitor);
                if (!visitor.hasErrors()) {
                    print("Deleted " + basePath);
                    return;
                } else if (useLogger && logger.isDebugEnabled()) {
                    for (final Throwable t : visitor.getErrors()) {
                        logger.debug("Could not delete files/directories.", t);
                    }
                }
            } catch (final Exception e) {
                print(e.getMessage() + " Retring to delete it.");
                try {
                    Thread.sleep(1000);
                } catch (final InterruptedException ignore) {
                    // ignore
                }
            }
        }
        print("Failed to delete " + basePath + " in this process.");
    }
692882
private static void includeAffected(Set<String> allClasses, Set<String> affectedClasses, List<File> sortedFiles) {
        Storer storer = Config.createStorer();
        Hasher hasher = Config.createHasher();

        NameBasedCheck classCheck = Config.DEBUG_MODE_V != Config.DebugMode.NONE ?
            new DebugNameCheck(storer, hasher, DependencyAnalyzer.CLASS_EXT) :
            new NameBasedCheck(storer, hasher, DependencyAnalyzer.CLASS_EXT);
        NameBasedCheck covCheck = new NameBasedCheck(storer, hasher, DependencyAnalyzer.COV_EXT);
        MethodCheck methodCheck = new MethodCheck(storer, hasher);
        String prevClassName = null;
        for (File file : sortedFiles) {
            String fileName = file.getName();
            String dirName = file.getParent();
            String className = null;
            if (file.isDirectory()) {
                continue;
            }
            if (fileName.endsWith(DependencyAnalyzer.COV_EXT)) {
                className = covCheck.includeAll(fileName, dirName);
            } else if (fileName.endsWith(DependencyAnalyzer.CLASS_EXT)) {
                className = classCheck.includeAll(fileName, dirName);
            } else {
                className = methodCheck.includeAll(fileName, dirName);
            }
            // Reset after some time to free space.
            if (prevClassName != null && className != null && !prevClassName.equals(className)) {
                methodCheck.includeAffected(affectedClasses);
                methodCheck = new MethodCheck(Config.createStorer(), Config.createHasher());
            }
            if (className != null) {
                allClasses.add(className);
                prevClassName = className;
            }
        }
        classCheck.includeAffected(affectedClasses);
        covCheck.includeAffected(affectedClasses);
        methodCheck.includeAffected(affectedClasses);
    }
409774
private synchronized void clearCaches() {
        fileListMap.clear();
        includeNonPatterns.clear();
        excludeNonPatterns.clear();
        includePatterns = null;
        excludePatterns = null;
        areNonPatternSetsReady = false;
    }
923378
private function getIncludedFiles()
    {
        // Retrieve the include and exclude lists
        // from the options
        $include = Options::get('coverage.include');
        $exclude = Options::get('coverage.exclude');

        // Create empty arrays to store our filenames in
        $includedFiles = [];
        $excludedFiles = [];

        // If we have marked files as included
        if ($include !== null) {
            // Convert a string to an array so that
            // we only have to loop once
            if (!is_array($include)) {
                $include = [$include];
            }

            // Loop through each of the include glob strings
            foreach ($include as $glob) {
                // Prepend the current working directory to the glob
                $glob = $this->runner->pwd.'/'.$glob;

                // Add the glob results to the included files array
                $includedFiles = array_merge($includedFiles, glob_recursive($glob));
            }
        }

        // If we have marked files as excluded
        if ($exclude !== null) {
            // Convert a string to an array so that
            // we only have to loop once
            if (!is_array($exclude)) {
                $exclude = [$exclude];
            }

            // Loop through each of the include glob strings
            foreach ($exclude as $glob) {
                // Prepend the current working directory to the glob
                $glob = $this->runner->pwd.'/'.$glob;

                // Add the glob results to the excluded files array
                $excludedFiles = array_merge($excludedFiles, glob_recursive($glob));
            }
        }

        // Store the results
        $this->includedFiles = $includedFiles ?: [];
        $this->excludedFiles = $excludedFiles ?: [];
    }
1210837
protected function init()
    {
        foreach($this->excludePaths as $i => $path)
        {
            if(!$this->excludePaths[$i] = realpath($path))
            {
                unset($this->excludePaths[$i]);
            }
        }
        $this->excludeRule = implode('|', array_map('\Imi\Util\Imi::parseRule', $this->excludePaths));
        foreach($this->includePaths as $i => $path)
        {
            if(!$this->includePaths[$i] = $path = realpath($path))
            {
                unset($this->includePaths[$i]);
                continue;
            }
            $directory = new \RecursiveDirectoryIterator($path, \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS);
            $iterator = new \RecursiveIteratorIterator($directory);
            if('' === $this->excludeRule)
            {
                foreach($iterator as $fileName => $fileInfo)
                {
                    $this->parseInitFile($fileName);
                }
            }
            else
            {
                $rule = "/^(?!{$this->excludeRule}).+$/i";
                $regex = new \RegexIterator($iterator, $rule, \RecursiveRegexIterator::GET_MATCH);
                foreach ($regex as $item)
                {
                    $this->parseInitFile($item[0]);
                }
            }
        }
    }
1019595
public function clean()
	{
		// So the task doesn't complain,
		// make any 'missing' dirs to cleanup
		array_map(function ($dir) {
			if ( ! is_dir($dir))
			{
				`mkdir -p {$dir}`;
			}
		}, $this->cleanDirs);

		$this->_cleanDir($this->cleanDirs);
		$this->_deleteDir($this->cleanDirs);
	}

	/**
	 * Run unit tests and generate coverage reports
	 */
	public function coverage()
	{
		$this->_run(['phpdbg -qrr -- vendor/bin/phpunit -c build']);
	}

	/**
	 * Generate documentation with phpdox
	 */
	public function docs()
	{
		$this->_run(['vendor/bin/phpdox']);
	}

	/**
	 * Verify that source files are valid
	 */
	public function lint()
	{
		$files = $this->getAllSourceFiles();

		$chunks = array_chunk($files, (int)`getconf _NPROCESSORS_ONLN`);

		foreach($chunks as $chunk)
		{
			$this->parallelLint($chunk);
		}
	}

	/**
	 * Run the phpcs tool
	 *
	 * @param bool $report - if true, generates reports instead of direct output
	 */
	public function phpcs($report = FALSE)
	{
		$dir = __DIR__;

		$report_cmd_parts = [
			'vendor/bin/phpcs',
			"--standard=./build/CodeIgniter",
			"--report-checkstyle=./build/logs/phpcs.xml",
		];

		$normal_cmd_parts = [
			'vendor/bin/phpcs',
			"--standard=./build/CodeIgniter",
		];

		$cmd_parts = ($report) ? $report_cmd_parts : $normal_cmd_parts;

		$this->_run($cmd_parts);
	}
1008036
private synchronized boolean isIncluded(String _clazzName) {
        if (includes.size() > 0) {
            for (String include : includes) {
                if (_clazzName.startsWith(include)) {
                    return true;

                }
            }
        } // if we dont have a list, we include nothing (to prevent circular classloader dependencies)
        return false;
    }
816005
private Collection<File> doListAllFiles(File rootDir,
                                            boolean includeDirectories) {
        Collection<File> result = new Stack<File>();
        File[] files = rootDir.listFiles();
        for (File f : files) {
            if (f.isDirectory()) {
                if (includeDirectories) {
                    result.add(f);
                }
                result.addAll(doListAllFiles(f, includeDirectories));
            } else if (f.isFile()) {
                result.add(f);
            }
        }
        return result;
    }