Skip to content

Commit

Permalink
made some changes on how we handle analysis with config file
Browse files Browse the repository at this point in the history
  • Loading branch information
DMarinhoCodacy committed Oct 22, 2024
1 parent 4e90a4c commit 8795c9d
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/Analyzer/CodeAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class CodeAnalyzer : Codacy.Engine.Seed.CodeAnalyzer, IDisposable
private readonly DiagnosticsRunner diagnosticsRunner;
private readonly string tmpSonarLintFolder;
private static HashSet<string> blacklist = new HashSet<string> { "S1144", "S2325", "S2077" };
private static XElement cachedConfigurationFile;

public static bool IsInBlacklist(string id)
{
Expand Down Expand Up @@ -74,17 +73,13 @@ public CodeAnalyzer() : base(csharpExtension)
new XDocument(new XElement("AnalysisInput", rules)).Save(tmpSonarLintPath);
additionalFiles.Add(new AnalyzerAdditionalFile(tmpSonarLintPath));
}
else if (cachedConfigurationFile == null && File.Exists(sonarConfigurationPath))
else if (File.Exists(sonarConfigurationPath))
{
// Cache the configuration file in memory
cachedConfigurationFile = XDocument.Load(sonarConfigurationPath).Element("AnalysisInput");
var configurationFile = XDocument.Load(sonarConfigurationPath).Element("AnalysisInput");
additionalFiles.Add(new AnalyzerAdditionalFile(sonarConfigurationPath));
}

if (PatternIds is null && cachedConfigurationFile != null)
{

// Load patterns from cached configuration file
var rules = cachedConfigurationFile.Element("Rules");
var rules = configurationFile.Element("Rules");
if (rules != null)
{
PatternIds = rules.Elements("Rule").Select(e => e.Elements("Key").Single().Value).ToImmutableList();
Expand Down

0 comments on commit 8795c9d

Please sign in to comment.