Skip to content

Commit

Permalink
Extract GetExtraProperties method
Browse files Browse the repository at this point in the history
  • Loading branch information
vnaskos-sonar committed Nov 27, 2024
1 parent 672d2a4 commit f783f7d
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/SLCore/Analysis/SLCoreAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,7 @@ public void ExecuteAnalysis(string path, Guid analysisId, IEnumerable<AnalysisLa
return;
}

Dictionary<string, string> extraProperties = [];
if (IsCFamily(detectedLanguages))
{
var compilationDatabasePath = compilationDatabaseLocator.Locate();
if (compilationDatabasePath != null)
{
extraProperties[CFamilyCompileCommandsProperty] = compilationDatabasePath;
}
}
var extraProperties = GetExtraProperties(detectedLanguages);

ExecuteAnalysisInternalAsync(path, configurationScope.Id, analysisId, analyzerOptions, analysisService, analysisStatusNotifier, extraProperties, cancellationToken).Forget();
}
Expand Down Expand Up @@ -130,5 +122,21 @@ [new FileUri(path)],
}
}

private Dictionary<string, string> GetExtraProperties(IEnumerable<AnalysisLanguage> detectedLanguages)
{
Dictionary<string, string> extraProperties = [];
if (!IsCFamily(detectedLanguages))
{
return extraProperties;
}

var compilationDatabasePath = compilationDatabaseLocator.Locate();
if (compilationDatabasePath != null)
{
extraProperties[CFamilyCompileCommandsProperty] = compilationDatabasePath;
}
return extraProperties;
}

private static bool IsCFamily(IEnumerable<AnalysisLanguage> detectedLanguages) => detectedLanguages != null && detectedLanguages.Contains(AnalysisLanguage.CFamily);
}

0 comments on commit f783f7d

Please sign in to comment.