зеркало из https://github.com/github/codeql.git
C#: Only use small files during file content reference analysis.
This commit is contained in:
Родитель
a81d982c90
Коммит
61a523510e
|
@ -60,7 +60,8 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||||
|
|
||||||
packageDirectory = new TemporaryDirectory(ComputeTempDirectory(sourceDir.FullName));
|
packageDirectory = new TemporaryDirectory(ComputeTempDirectory(sourceDir.FullName));
|
||||||
var allFiles = GetFiles("*.*").ToList();
|
var allFiles = GetFiles("*.*").ToList();
|
||||||
this.fileContent = new FileContent(progressMonitor, GetFileNames(allFiles));
|
var smallFiles = GetSmallFiles(allFiles);
|
||||||
|
this.fileContent = new FileContent(progressMonitor, GetFileNames(smallFiles));
|
||||||
this.allSources = GetFileNames(allFiles, ".cs").ToList();
|
this.allSources = GetFileNames(allFiles, ".cs").ToList();
|
||||||
var allProjects = GetFileNames(allFiles, ".csproj");
|
var allProjects = GetFileNames(allFiles, ".csproj");
|
||||||
var solutions = options.SolutionFile is not null
|
var solutions = options.SolutionFile is not null
|
||||||
|
@ -194,6 +195,20 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||||
private static IEnumerable<string> GetFileNames(IEnumerable<FileInfo> files, params string[] extensions) =>
|
private static IEnumerable<string> GetFileNames(IEnumerable<FileInfo> files, params string[] extensions) =>
|
||||||
files.Where(fi => !extensions.Any() || extensions.Contains(fi.Extension)).Select(fi => fi.FullName);
|
files.Where(fi => !extensions.Any() || extensions.Contains(fi.Extension)).Select(fi => fi.FullName);
|
||||||
|
|
||||||
|
private IEnumerable<FileInfo> GetSmallFiles(IEnumerable<FileInfo> files)
|
||||||
|
{
|
||||||
|
const int oneMb = 1_048_576;
|
||||||
|
return files.Where(file =>
|
||||||
|
{
|
||||||
|
if (file.Length > oneMb)
|
||||||
|
{
|
||||||
|
progressMonitor.LogDebug($"Skipping {file.FullName} because it is bigger than 1MB.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Computes a unique temp directory for the packages associated
|
/// Computes a unique temp directory for the packages associated
|
||||||
/// with this source tree. Use a SHA1 of the directory name.
|
/// with this source tree. Use a SHA1 of the directory name.
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||||
public void LogInfo(string message) =>
|
public void LogInfo(string message) =>
|
||||||
logger.Log(Severity.Info, message);
|
logger.Log(Severity.Info, message);
|
||||||
|
|
||||||
private void LogDebug(string message) =>
|
public void LogDebug(string message) =>
|
||||||
logger.Log(Severity.Debug, message);
|
logger.Log(Severity.Debug, message);
|
||||||
|
|
||||||
private void LogError(string message) =>
|
private void LogError(string message) =>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче