Skip to content

Commit

Permalink
addressed sonar cloud feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
anissa-agahchen committed May 4, 2023
1 parent f334257 commit a3bbfec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion api/src/utils/media/csv/validation/csv-row-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export const getValidFormatFieldsValidator = (config?: ColumnFormatValidatorConf
return csvWorksheet;
}

const regexFlags = config.column_format_validator.reg_exp_flags || '';
const regexFlags = config.column_format_validator.reg_exp_flags ?? '';

const regex = new RegExp(config.column_format_validator.reg_exp, regexFlags);

Expand Down
16 changes: 8 additions & 8 deletions api/src/utils/media/xlsx/transformation/xlsx-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export type RowObject = {
_data: { [key: string]: NonObjectPrimitive };
_name: string;
_key: string;
_parentKey: string | '';
_parentKey: string;
_type: 'root' | 'leaf' | '';
_row: number;
_childKeys: string[];
Expand Down Expand Up @@ -388,7 +388,7 @@ export class XLSXTransform {

const fields = mapSchemaItem.fields;

if (fields && fields.length) {
if (fields?.length) {
// For each item in the `fields` array
for (const fieldsItem of fields) {
// The final computed cell value for this particular schema field element
Expand Down Expand Up @@ -423,7 +423,7 @@ export class XLSXTransform {
let pathValue = '';
if (Array.isArray(pathValues)) {
// cell value is the concatenation of multiple values
pathValue = (pathValues.length && pathValues.flat(Infinity).join(columnValueItem.join || ':')) || '';
pathValue = (pathValues.length && pathValues.flat(Infinity).join(columnValueItem.join ?? ':')) || '';
} else {
// cell value is a single value
pathValue = pathValues || '';
Expand All @@ -450,20 +450,20 @@ export class XLSXTransform {
if (Array.isArray(postfixPathValues)) {
// postfix value is the concatenation of multiple values
postfixValue =
(postfixPathValues.length && postfixPathValues.join(columnValueItem.join || ':')) || '';
(postfixPathValues.length && postfixPathValues.join(columnValueItem.join ?? ':')) || '';
} else {
// postfix value is a single value
postfixValue = postfixPathValues || '';
}
}

cellValue = `${cellValue}${columnValueItem.join || ':'}${postfixValue}`;
cellValue = `${cellValue}${columnValueItem.join ?? ':'}${postfixValue}`;
}
}

// Check for `add` additions at the field level
const columnValueItemAdd = columnValueItem.add;
if (columnValueItemAdd && columnValueItemAdd.length) {
if (columnValueItemAdd?.length) {
for (const columnValueItemAddItem of columnValueItemAdd) {
mapSchema.push(columnValueItemAddItem);
}
Expand All @@ -485,7 +485,7 @@ export class XLSXTransform {

// Check for additions at the sheet level
const sheetAdds = mapSchemaItem.add;
if (sheetAdds && sheetAdds.length) {
if (sheetAdds?.length) {
for (const sheetAddsItem of sheetAdds) {
mapSchema.push(sheetAddsItem);
}
Expand Down Expand Up @@ -527,7 +527,7 @@ export class XLSXTransform {
_processIfNotEmptyCondition(check: IfNotEmptyCheck, rowObjects: RowObject[]): boolean {
const pathValues = this._processPaths([check.ifNotEmpty], rowObjects);

if (!pathValues || !pathValues.length) {
if (!pathValues?.length) {
// condition failed
return false;
}
Expand Down

0 comments on commit a3bbfec

Please sign in to comment.