diff --git a/src/Analyzer/CodeAnalyzer.cs b/src/Analyzer/CodeAnalyzer.cs index 596048f..08f05b4 100644 --- a/src/Analyzer/CodeAnalyzer.cs +++ b/src/Analyzer/CodeAnalyzer.cs @@ -26,7 +26,7 @@ public class CodeAnalyzer : Codacy.Engine.Seed.CodeAnalyzer, IDisposable private readonly ImmutableArray availableAnalyzers; private readonly DiagnosticsRunner diagnosticsRunner; private readonly string tmpSonarLintFolder; - private static HashSet blacklist = new HashSet { "S1144", "S2325", "S2077" }; + private static HashSet blacklist = new HashSet { "S1144", "S2325", "S2077", "AD0001" }; public static bool IsInBlacklist(string id) { @@ -123,15 +123,7 @@ public async Task Analyze(string file, CancellationToken cancellationToken) try { var solution = CompilationHelper.GetSolutionFromFile(DefaultSourceFolder + file); - var project = solution.Projects.First(); - - // FIX: Prevent SonarAnalyzer NullReferenceException - project = project.AddAnalyzerConfigDocument( - ".editorconfig", - Microsoft.CodeAnalysis.Text.SourceText.From("is_global = true\n"), - filePath: "/.editorconfig").Project; - - var compilation = await project.GetCompilationAsync(cancellationToken); + var compilation = await solution.Projects.First().GetCompilationAsync(); // Parallelize diagnostics fetching var diagnostics = await diagnosticsRunner.GetDiagnostics(compilation, cancellationToken); @@ -192,4 +184,4 @@ public static ImmutableArray GetUtilityAnalyzers() return utilityAnalyzers; } } -} +} \ No newline at end of file diff --git a/src/Analyzer/Runner/DiagnosticsRunner.cs b/src/Analyzer/Runner/DiagnosticsRunner.cs index 477bb72..3b2fc96 100644 --- a/src/Analyzer/Runner/DiagnosticsRunner.cs +++ b/src/Analyzer/Runner/DiagnosticsRunner.cs @@ -53,7 +53,8 @@ public Task> GetDiagnostics(Compilation compilation, var modifiedCompilation = compilation.WithOptions(compilationOptions); var compilationWithAnalyzer = modifiedCompilation.WithAnalyzers( diagnosticsAnalyzers, - options); + options, + cancellationToken); return compilationWithAnalyzer.GetAnalyzerDiagnosticsAsync(cancellationToken); } @@ -71,4 +72,4 @@ private ReportDiagnostic GetReportDiagnosticForPattern(string diagnosticId) } } } -} +} \ No newline at end of file diff --git a/src/Analyzer/Utilities/RuleFinder.cs b/src/Analyzer/Utilities/RuleFinder.cs index 46d254c..d93af46 100644 --- a/src/Analyzer/Utilities/RuleFinder.cs +++ b/src/Analyzer/Utilities/RuleFinder.cs @@ -40,8 +40,8 @@ public IEnumerable GetParameterlessAnalyzerTypes() public static bool IsParameterized(Type analyzerType) { - return Array.Exists(analyzerType.GetProperties(), - p => p.GetCustomAttributes().Any()); + return analyzerType.GetProperties() + .Any(p => p.GetCustomAttributes().Any()); } public IEnumerable GetAnalyzerTypes() @@ -69,4 +69,4 @@ public static AnalyzerLanguage GetTargetLanguages(Type analyzerType) return AnalyzerLanguage.CSharp; } } -} +} \ No newline at end of file