Sfoglia il codice sorgente

SONAR-16245 Place others category at the end

tags/9.5.0.56709
Jeremy Davis 2 anni fa
parent
commit
baaa4fd2ce

+ 20
- 20
server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/__snapshots__/HotspotList-test.tsx.snap Vedi File

@@ -106,23 +106,23 @@ exports[`should render correctly with hotspots: no pagination 1`] = `
<ul>
<li
className="spacer-bottom"
key="cat2"
key="cat1"
>
<HotspotCategory
categoryKey="cat2"
categoryKey="cat1"
hotspots={
Array [
Object {
"author": "Developer 1",
"component": "com.github.kevinsawicki:http-request:com.github.kevinsawicki.http.HttpRequest",
"creationDate": "2013-05-13T17:55:39+0200",
"key": "h1",
"key": "h2",
"line": 81,
"message": "'3' is a magic number.",
"project": "com.github.kevinsawicki:http-request",
"resolution": undefined,
"rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck",
"securityCategory": "cat2",
"securityCategory": "cat1",
"status": "TO_REVIEW",
"updateDate": "2013-05-13T17:55:39+0200",
"vulnerabilityProbability": "HIGH",
@@ -151,28 +151,28 @@ exports[`should render correctly with hotspots: no pagination 1`] = `
"vulnerabilityProbability": "HIGH",
}
}
title="cat2"
title="cat1"
/>
</li>
<li
className="spacer-bottom"
key="cat1"
key="cat2"
>
<HotspotCategory
categoryKey="cat1"
categoryKey="cat2"
hotspots={
Array [
Object {
"author": "Developer 1",
"component": "com.github.kevinsawicki:http-request:com.github.kevinsawicki.http.HttpRequest",
"creationDate": "2013-05-13T17:55:39+0200",
"key": "h2",
"key": "h1",
"line": 81,
"message": "'3' is a magic number.",
"project": "com.github.kevinsawicki:http-request",
"resolution": undefined,
"rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck",
"securityCategory": "cat1",
"securityCategory": "cat2",
"status": "TO_REVIEW",
"updateDate": "2013-05-13T17:55:39+0200",
"vulnerabilityProbability": "HIGH",
@@ -201,7 +201,7 @@ exports[`should render correctly with hotspots: no pagination 1`] = `
"vulnerabilityProbability": "HIGH",
}
}
title="cat1"
title="cat2"
/>
</li>
</ul>
@@ -386,23 +386,23 @@ exports[`should render correctly with hotspots: pagination 1`] = `
<ul>
<li
className="spacer-bottom"
key="cat2"
key="cat1"
>
<HotspotCategory
categoryKey="cat2"
categoryKey="cat1"
hotspots={
Array [
Object {
"author": "Developer 1",
"component": "com.github.kevinsawicki:http-request:com.github.kevinsawicki.http.HttpRequest",
"creationDate": "2013-05-13T17:55:39+0200",
"key": "h1",
"key": "h2",
"line": 81,
"message": "'3' is a magic number.",
"project": "com.github.kevinsawicki:http-request",
"resolution": undefined,
"rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck",
"securityCategory": "cat2",
"securityCategory": "cat1",
"status": "TO_REVIEW",
"updateDate": "2013-05-13T17:55:39+0200",
"vulnerabilityProbability": "HIGH",
@@ -431,28 +431,28 @@ exports[`should render correctly with hotspots: pagination 1`] = `
"vulnerabilityProbability": "HIGH",
}
}
title="cat2"
title="cat1"
/>
</li>
<li
className="spacer-bottom"
key="cat1"
key="cat2"
>
<HotspotCategory
categoryKey="cat1"
categoryKey="cat2"
hotspots={
Array [
Object {
"author": "Developer 1",
"component": "com.github.kevinsawicki:http-request:com.github.kevinsawicki.http.HttpRequest",
"creationDate": "2013-05-13T17:55:39+0200",
"key": "h2",
"key": "h1",
"line": 81,
"message": "'3' is a magic number.",
"project": "com.github.kevinsawicki:http-request",
"resolution": undefined,
"rule": "checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck",
"securityCategory": "cat1",
"securityCategory": "cat2",
"status": "TO_REVIEW",
"updateDate": "2013-05-13T17:55:39+0200",
"vulnerabilityProbability": "HIGH",
@@ -481,7 +481,7 @@ exports[`should render correctly with hotspots: pagination 1`] = `
"vulnerabilityProbability": "HIGH",
}
}
title="cat1"
title="cat2"
/>
</li>
</ul>

+ 11
- 1
server/sonar-web/src/main/js/apps/security-hotspots/utils.ts Vedi File

@@ -44,6 +44,8 @@ import {
StandardSecurityCategories
} from '../../types/types';

const OTHERS_SECURITY_CATEGORY = 'others';

export const RISK_EXPOSURE_LEVELS = [RiskExposure.HIGH, RiskExposure.MEDIUM, RiskExposure.LOW];
export const SECURITY_STANDARDS = [
SecurityStandard.SONARSOURCE,
@@ -74,11 +76,19 @@ export function groupByCategory(
) {
const groups = groupBy(hotspots, h => h.securityCategory);

return Object.keys(groups).map(key => ({
const groupList = Object.keys(groups).map(key => ({
key,
title: getCategoryTitle(key, securityCategories),
hotspots: groups[key]
}));

return [
...sortBy(
groupList.filter(group => group.key !== OTHERS_SECURITY_CATEGORY),
group => group.title
),
...groupList.filter(({ key }) => key === OTHERS_SECURITY_CATEGORY)
];
}

export function sortHotspots(hotspots: RawHotspot[], securityCategories: Dict<{ title: string }>) {

Loading…
Annulla
Salva