From a228658b911ca42304878d1298822172c9df5d28 Mon Sep 17 00:00:00 2001 From: Arseniy Zaostrovnykh <70532144+arseniy-sonar@users.noreply.github.com> Date: Tue, 1 Jun 2021 16:50:15 +0200 Subject: [PATCH] RULEAPI-626 Fix the crash when choosing terraform, rust, solidity, html - any non covered language --- frontend/.gitignore | 3 ++- frontend/src/RulePage.tsx | 12 ++++++++---- frontend/src/utils/useRuleCoverage.ts | 12 ++++++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/frontend/.gitignore b/frontend/.gitignore index e137dcd861..d6759aded4 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -22,4 +22,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* -.eslintcache \ No newline at end of file +.eslintcache +incomplete-rules-repo/ diff --git a/frontend/src/RulePage.tsx b/frontend/src/RulePage.tsx index ff1640448b..2f8b0246c1 100644 --- a/frontend/src/RulePage.tsx +++ b/frontend/src/RulePage.tsx @@ -70,6 +70,8 @@ const languageToJiraProject = new Map(Object.entries({ "TSQL": "SONARTSQL", "VB6": "SONARVBSIX", "XML": "SONARXML", + "CLOUDFORMATION": "SONARIAC", + "TERRAFORM": "SONARIAC", })); const languageToGithubProject = new Map(Object.entries({ @@ -91,13 +93,15 @@ const languageToGithubProject = new Map(Object.entries({ "PLI": "sonar-pli", "CFAMILY": "sonar-cpp", "CSS": "sonar-css", + "FLEX": "sonar-flex", "PHP": "sonar-php", - "PL/SQL": "sonar-plsql", - "Python": "sonar-python", + "PLSQL": "sonar-plsql", + "PYTHON": "sonar-python", "RPG": "sonar-rpg", - "Swift": "sonar-swift", - "T-SQL": "sonar-tsql", + "TSQL": "sonar-tsql", "XML": "sonar-xml", + "CLOUDFORMATION": "sonar-iac", + "TERRAFORM": "sonar-iac", })); diff --git a/frontend/src/utils/useRuleCoverage.ts b/frontend/src/utils/useRuleCoverage.ts index 653475d3bc..16bce0b37d 100644 --- a/frontend/src/utils/useRuleCoverage.ts +++ b/frontend/src/utils/useRuleCoverage.ts @@ -30,7 +30,10 @@ export function useRuleCoverage() { 'tsql': ['TSQL'], 'vb6': ['VB'], 'WEB': ['WEB'], - 'xml': ['XML'] + 'xml': ['XML'], + 'html': ['HTML'], + 'cloudformation': ['CLOUDFORMATION'], + 'terraform': ['TERRAFORM'] })); function ruleCoverage(language: string, ruleKeys: string[], mapper: any) { if (coveredRulesError) { @@ -47,11 +50,12 @@ export function useRuleCoverage() { // const keys = coveredRules.keys; const languageKeys = languageToSonarpedia.get(language); if (!languageKeys) { - throw new Error(`Unknown key ${language}`) + return 'Nonsupported language'; } languageKeys.forEach(sonarpediaKey => { ruleKeys.forEach(ruleKey => { - if (ruleKey in coveredRules[sonarpediaKey]) { + if (sonarpediaKey in coveredRules && + ruleKey in coveredRules[sonarpediaKey]) { result.push(mapper(sonarpediaKey, coveredRules[sonarpediaKey][ruleKey])) } }); @@ -64,4 +68,4 @@ export function useRuleCoverage() { } return ruleCoverage; -} \ No newline at end of file +}