Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions src/Analyzer/CodeAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class CodeAnalyzer : Codacy.Engine.Seed.CodeAnalyzer, IDisposable
private readonly ImmutableArray<DiagnosticAnalyzer> availableAnalyzers;
private readonly DiagnosticsRunner diagnosticsRunner;
private readonly string tmpSonarLintFolder;
private static HashSet<string> blacklist = new HashSet<string> { "S1144", "S2325", "S2077" };
private static HashSet<string> blacklist = new HashSet<string> { "S1144", "S2325", "S2077", "AD0001" };

public static bool IsInBlacklist(string id)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -192,4 +184,4 @@ public static ImmutableArray<DiagnosticAnalyzer> GetUtilityAnalyzers()
return utilityAnalyzers;
}
}
}
}
5 changes: 3 additions & 2 deletions src/Analyzer/Runner/DiagnosticsRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public Task<ImmutableArray<Diagnostic>> GetDiagnostics(Compilation compilation,
var modifiedCompilation = compilation.WithOptions(compilationOptions);
var compilationWithAnalyzer = modifiedCompilation.WithAnalyzers(
diagnosticsAnalyzers,
options);
options,
cancellationToken);

return compilationWithAnalyzer.GetAnalyzerDiagnosticsAsync(cancellationToken);
}
Expand All @@ -71,4 +72,4 @@ private ReportDiagnostic GetReportDiagnosticForPattern(string diagnosticId)
}
}
}
}
}
6 changes: 3 additions & 3 deletions src/Analyzer/Utilities/RuleFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public IEnumerable<Type> GetParameterlessAnalyzerTypes()

public static bool IsParameterized(Type analyzerType)
{
return Array.Exists(analyzerType.GetProperties(),
p => p.GetCustomAttributes<RuleParameterAttribute>().Any());
return analyzerType.GetProperties()
.Any(p => p.GetCustomAttributes<RuleParameterAttribute>().Any());
}

public IEnumerable<Type> GetAnalyzerTypes()
Expand Down Expand Up @@ -69,4 +69,4 @@ public static AnalyzerLanguage GetTargetLanguages(Type analyzerType)
return AnalyzerLanguage.CSharp;
}
}
}
}