Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix undefined metric description #2883

Merged
merged 5 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -62,6 +62,13 @@ function compareSuspiciousMetricSuggestionLinks(a: MetricSuggestionParameters, b
return 0
}

function getNameAndDescriptionOfMetric(metricName: string): string {
if (metricDescriptions.get(metricName)) {
return `${metricName} (${metricDescriptions.get(metricName)})`
MW-Friedrich marked this conversation as resolved.
Show resolved Hide resolved
}
return `${metricName}`
}

export function findGoodAndBadMetrics(
metricValuesByLanguages: MetricValuesByLanguage,
mainProgrammingLanguage: string
Expand All @@ -84,7 +91,7 @@ export function findGoodAndBadMetrics(
const maxMetricValue = Math.max(...valuesOfMetric)

if (maxMetricValue <= thresholdConfig.percentile70) {
metricAssessmentResults.unsuspiciousMetrics.push(`${metricName} (${metricDescriptions.get(metricName)})`)
metricAssessmentResults.unsuspiciousMetrics.push(getNameAndDescriptionOfMetric(metricName))
} else if (maxMetricValue > thresholdConfig.percentile70) {
metricAssessmentResults.suspiciousMetrics.set(metricName, {
from: thresholdConfig.percentile70,
Expand Down
Expand Up @@ -14,5 +14,6 @@ export const metricDescriptions: Map<string, string> = new Map([
["line_coverage", "number of code lines covered by tests"],
["sonar_code_smells", "number of smells Sonar has identified"],
["avg_code_churn", "average number of lines added or removed from this file"],
["number_of_authors", "number of authors that have edited this file"]
["number_of_authors", "number of authors that have edited this file"],
["statements", "number of statements"]
])