Skip to content

Commit

Permalink
#242: Added option to remove risk hotspots section
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpalme committed May 20, 2019
1 parent f5b24d0 commit 46bd5f5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ CHANGELOG
4.1.6.0

* New: Issue #239: Added link back to the summary page
* New: Issue #242: Added option to remove risk hotspots section

4.1.5.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
/// </summary>
public class RiskHotspotsAnalysisThresholds
{
/// <summary>
/// Gets or sets a value indicating whether risk hotspots should be disabled or not.
/// </summary>
public bool DisableRiskHotspots { get; set; } = false;

/// <summary>
/// Gets or sets the threshold for cylomatic complexity.
/// </summary>
Expand Down
13 changes: 13 additions & 0 deletions src/ReportGenerator.Core/CodeAnalysis/RiskHotspotsAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ namespace Palmmedia.ReportGenerator.Core.CodeAnalysis
/// </summary>
internal class RiskHotspotsAnalyzer : IRiskHotspotsAnalyzer
{
/// <summary>
/// Indicates whether risk hotspots should be disabled or not.
/// </summary>
private readonly bool disabled;

/// <summary>
/// The thresholds of the various metrics.
/// </summary>
Expand All @@ -21,6 +26,8 @@ internal class RiskHotspotsAnalyzer : IRiskHotspotsAnalyzer
/// <param name="riskHotspotsAnalysisThresholds">The metric thresholds.</param>
public RiskHotspotsAnalyzer(RiskHotspotsAnalysisThresholds riskHotspotsAnalysisThresholds)
{
this.disabled = riskHotspotsAnalysisThresholds.DisableRiskHotspots;

this.thresholdsByMetricName = new Dictionary<string, decimal>()
{
{ ReportResources.CyclomaticComplexity, riskHotspotsAnalysisThresholds.MetricThresholdForCyclomaticComplexity },
Expand All @@ -37,6 +44,12 @@ public RiskHotspotsAnalyzer(RiskHotspotsAnalysisThresholds riskHotspotsAnalysisT
public RiskHotspotAnalysisResult PerformRiskHotspotAnalysis(IEnumerable<Assembly> assemblies)
{
var riskHotspots = new List<RiskHotspot>();

if (this.disabled)
{
return new RiskHotspotAnalysisResult(riskHotspots, false);
}

decimal threshold = -1;

bool codeCodeQualityMetricsAvailable = false;
Expand Down
1 change: 1 addition & 0 deletions src/ReportGenerator.Core/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"riskHotspotsAnalysisThresholds": {
"disableRiskHotspots": false,
"metricThresholdForCyclomaticComplexity": 30,
"metricThresholdForCrapScore": 15,
"metricThresholdForNPathComplexity": 200
Expand Down

0 comments on commit 46bd5f5

Please sign in to comment.