Skip to content

Commit

Permalink
ADM-944: [frontend] feat: fix sonar isuue
Browse files Browse the repository at this point in the history
  • Loading branch information
Mandy-Tang committed May 29, 2024
1 parent 1423993 commit 525e167
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,16 @@ const ChartAndTitleWrapper = forwardRef(
return INCREASE;
} else if (trendInfo.trendNumber < 0) {
return DECREASE;
} else if (UP_TREND_IS_BETTER.includes(trendInfo.type)){

Check failure on line 46 in frontend/src/containers/ReportStep/ChartAndTitleWrapper/index.tsx

View workflow job for this annotation

GitHub Actions / frontend-check

Insert `·`

Check failure on line 46 in frontend/src/containers/ReportStep/ChartAndTitleWrapper/index.tsx

View workflow job for this annotation

GitHub Actions / frontend-check

Insert `·`
return INCREASE;
} else {
if (UP_TREND_IS_BETTER.includes(trendInfo.type)) {
return INCREASE;
} else {
return DECREASE;
}
return DECREASE;
}
};
const tipContent = (
<StyledToolTipContent>
<p>{`The rate of ${trendDescribe()} for ${CHART_TREND_TIP[trendInfo.type]}: `}</p>
{trendInfo.dateRangeList?.map((dateRange, index) => <p key={index}>{dateRange}</p>)}
{trendInfo.dateRangeList?.map((dateRange) => <p key={dateRange}>{dateRange}</p>)}
</StyledToolTipContent>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function extractedStackedBarData(allDateRanges: string[], mappedData: ReportResp
.slice(0, 2);
const extractedValues = mappedData?.map((data) =>
data.leadTimeForChangesList?.[0].valuesList.map((item) => {
return Number(item.value!);
return Number(item.value);
}),
);
const prLeadTimeValues = extractedValues?.map((value) => value![0]);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export const xAxisLabelDateFormatter = (dateRange: string) => {
export const getTrendInfo = (trendNumber: number, dateRangeList: string[], type: CHART_TYPE) => {
const result: ITrendInfo = {
trendNumber: trendNumber,
dateRangeList: dateRangeList as string[],
dateRangeList: dateRangeList,
type,
} as ITrendInfo;

Expand Down Expand Up @@ -254,7 +254,7 @@ export const calculateTrendInfo = (
const beforeLatestValidIndex = dataList.findLastIndex((data, index) => data && index !== latestValidIndex);

const trendNumber =
(dataList[latestValidIndex]! - dataList[beforeLatestValidIndex]!) / dataList[beforeLatestValidIndex]!;
(dataList[latestValidIndex] - dataList[beforeLatestValidIndex]) / dataList[beforeLatestValidIndex];
const validDateRangeList: string[] = [];
validDateRangeList.push(dateRangeList[latestValidIndex], dateRangeList[beforeLatestValidIndex]);

Expand Down

0 comments on commit 525e167

Please sign in to comment.