Skip to content

Commit c93a2d5

Browse files
committed
[Shivam] #271135 Fixed semgrep issues.
1 parent 1318c4f commit c93a2d5

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

src/graphing/components/quadrants.js

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const d3 = require('d3')
2-
const {getElementWidth, getElementHeight, decodeHTML} = require('../../util/htmlUtil')
3-
const {toRadian} = require('../../util/mathUtils')
4-
const {getRingIdString} = require('../../util/stringUtil')
2+
const { getElementWidth, getElementHeight, decodeHTML } = require('../../util/htmlUtil')
3+
const { toRadian } = require('../../util/mathUtils')
4+
const { getRingIdString } = require('../../util/stringUtil')
55
const {
66
graphConfig,
77
getGraphSize,
@@ -13,13 +13,12 @@ const {
1313

1414
const ANIMATION_DURATION = 1000
1515

16-
const {quadrantHeight, quadrantWidth, quadrantsGap, effectiveQuadrantWidth} = graphConfig
16+
const { quadrantHeight, quadrantWidth, quadrantsGap, effectiveQuadrantWidth } = graphConfig
1717

1818
let prevLeft, prevTop
1919
let quadrantScrollHandlerReference
2020
let scrollFlag = false
2121

22-
2322
const createElement = (tagName, text, attributes) => {
2423
const tag = document.createElement(tagName)
2524
Object.keys(attributes).forEach((keyName) => {
@@ -30,15 +29,10 @@ const createElement = (tagName, text, attributes) => {
3029
}
3130

3231
const replaceChild = (element, child) => {
33-
let elementChild = element.lastElementChild;
34-
while (elementChild) {
35-
element.removeChild(elementChild);
36-
elementChild = e.lastElementChild;
37-
}
32+
element.textContent = ''
3833
element.appendChild(child)
3934
}
4035

41-
4236
function selectRadarQuadrant(order, startAngle, name) {
4337
const noOfBlips = d3.selectAll('.quadrant-group-' + order + ' .blip-link').size()
4438
d3.select('#radar').classed('no-blips', noOfBlips === 0)
@@ -120,10 +114,10 @@ function selectRadarQuadrant(order, startAngle, name) {
120114
svg.classed('quadrant-view', true)
121115

122116
const quadrantGroupTranslate = {
123-
first: {x: 0, y: 0},
124-
second: {x: 0, y: -quadrantHeight},
125-
third: {x: -(quadrantWidth + quadrantsGap), y: 0},
126-
fourth: {x: -(quadrantWidth + quadrantsGap), y: -quadrantHeight},
117+
first: { x: 0, y: 0 },
118+
second: { x: 0, y: -quadrantHeight },
119+
third: { x: -(quadrantWidth + quadrantsGap), y: 0 },
120+
fourth: { x: -(quadrantWidth + quadrantsGap), y: -quadrantHeight },
127121
}
128122

129123
d3.select('.quadrant-group-' + order)
@@ -219,19 +213,19 @@ function wrapQuadrantNameInMultiLine(elem, isTopQuadrants, quadrantNameGroup, ti
219213
const words = text.split(' ')
220214
let line = ''
221215

222-
replaceChild(element, createElement('tspan', text, {id: 'text-width-check'}))
216+
replaceChild(element, createElement('tspan', text, { id: 'text-width-check' }))
223217
const testElem = document.getElementById('text-width-check')
224218

225219
function maxCharactersToFit(testLine, suffix) {
226220
let j = 1
227221
let firstLineWidth = 0
228222
const testElem1 = document.getElementById('text-width-check')
229-
testElem1.innerHTML = testLine
223+
testElem1.textContent = testLine
230224
if (testElem1.getBoundingClientRect().width < maxWidth) {
231225
return testLine.length
232226
}
233227
while (firstLineWidth < maxWidth && testLine.length > j) {
234-
testElem1.innerHTML = testLine.substring(0, j) + suffix
228+
testElem1.textContent = testLine.substring(0, j) + suffix
235229
firstLineWidth = testElem1.getBoundingClientRect().width
236230

237231
j++
@@ -252,33 +246,33 @@ function wrapQuadrantNameInMultiLine(elem, isTopQuadrants, quadrantNameGroup, ti
252246
if (testElem.getBoundingClientRect().width > maxWidth) {
253247
for (let i = 0; i < words.length; i++) {
254248
let testLine = line + words[i] + ' '
255-
testElem.innerHTML = testLine
249+
testElem.textContent = testLine
256250
const textWidth = testElem.getBoundingClientRect().width
257251

258252
if (textWidth > maxWidth) {
259253
if (i === 0) {
260254
let lineBreakIndex = maxCharactersToFit(testLine, '-')
261255
const elementText = `${words[i].substring(0, lineBreakIndex)}-`
262-
element.appendChild(createElement('tspan', elementText, {x: '0', dy}))
256+
element.appendChild(createElement('tspan', elementText, { x: '0', dy }))
263257
const secondLine = words[i].substring(lineBreakIndex, words[i].length) + ' ' + words.slice(i + 1).join(' ')
264258
lineBreakIndex = maxCharactersToFit(secondLine, '...')
265259
const text = `${secondLine.substring(0, lineBreakIndex)}${ellipsis(lineBreakIndex, secondLine)}`
266-
element.appendChild(createElement('tspan', text, {x: '0', dy: '20'}))
260+
element.appendChild(createElement('tspan', text, { x: '0', dy: '20' }))
267261
break
268262
} else {
269-
element.appendChild(createElement('tspan', line, {x: '0', dy}))
263+
element.appendChild(createElement('tspan', line, { x: '0', dy }))
270264
const secondLine = words.slice(i).join(' ')
271265
const lineBreakIndex = maxCharactersToFit(secondLine, '...')
272266
const text = `${secondLine.substring(0, lineBreakIndex)}${ellipsis(lineBreakIndex, secondLine)}`
273-
element.appendChild(createElement('tspan', text, {x: '0', dy: '20'}))
267+
element.appendChild(createElement('tspan', text, { x: '0', dy: '20' }))
274268
}
275269
line = words[i] + ' '
276270
} else {
277271
line = testLine
278272
}
279273
}
280274
} else {
281-
element.appendChild(createElement('tspan', text, {x: '0'}))
275+
element.appendChild(createElement('tspan', text, { x: '0' }))
282276
}
283277

284278
document.getElementById('text-width-check').remove()
@@ -338,7 +332,7 @@ function renderRadarQuadrants(size, svg, quadrant, rings, ringCalculator, tip) {
338332
})
339333

340334
const rectCoordMap = {
341-
first: {x: 0, y: 0, strokeDashArray: `0, ${quadrantWidth}, ${quadrantHeight + quadrantWidth}, ${quadrantHeight}`},
335+
first: { x: 0, y: 0, strokeDashArray: `0, ${quadrantWidth}, ${quadrantHeight + quadrantWidth}, ${quadrantHeight}` },
342336
second: {
343337
x: 0,
344338
y: quadrantHeight + quadrantsGap,

0 commit comments

Comments
 (0)