Skip to content

Commit

Permalink
HCK-7064: fix Sonar issue reports (#48)
Browse files Browse the repository at this point in the history
* HCK-7064: fix Sonar issue reports

* fix
  • Loading branch information
AlikRakhmonov authored Jul 12, 2024
1 parent a28486c commit fbbfeab
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
29 changes: 18 additions & 11 deletions forward_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ module.exports = {
relationship,
child,
bidirectional:
relationship &&
relationship.customProperties &&
relationship.customProperties.biDirectional &&
relationship?.customProperties?.biDirectional &&
child.GUID !== parent.GUID,
});
});
Expand Down Expand Up @@ -483,14 +481,16 @@ module.exports = {
entities.relationships = relationships;
}
}
const getId = key => key.keyId;

Object.keys(entities).forEach(type => {
entities[type].forEach(entity => {
if (entity.index) {
entity.index.forEach(index => {
if (index.key) {
const fields = this.findFields(
entity,
index.key.map(key => key.keyId),
index.key.map(getId),
);
if (fields.length) {
const indexScript = getIndex({
Expand Down Expand Up @@ -674,23 +674,30 @@ const getTemporalFieldFunctionStatement = (fieldMode, fieldStatementValue) => {
const timeSampleValue = JSON.stringify('12:00');

switch (fieldMode) {
case 'date':
case 'date': {
return `date(${fieldStatementValue})`;
case 'datetime':
}
case 'datetime': {
return `datetime(${fieldStatementValue})`;
case 'localdatetime':
}
case 'localdatetime': {
return `localdatetime(${fieldStatementValue})`;
case 'localtime':
}
case 'localtime': {
const localTimeStatementValue = isDefaultSample ? timeSampleValue : fieldStatementValue;
return `localtime(${localTimeStatementValue})`;
case 'time':
}
case 'time': {
const timeStatementValue = isDefaultSample ? timeSampleValue : fieldStatementValue;
return `time(${timeStatementValue})`;
case 'duration':
}
case 'duration': {
const durationStatementValue = isDefaultSample ? durationSampleValue : fieldStatementValue;
return `duration(${durationStatementValue})`;
default:
}
default: {
return fieldStatementValue;
}
}
};

Expand Down
20 changes: 10 additions & 10 deletions reverse_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module.exports = {

getDbCollectionsData: async function (data, logger, cb, app) {
try {
this.getDbCollectionsDataWrapped(data, logger, cb, app);
await this.getDbCollectionsDataWrapped(data, logger, cb, app);
} catch (error) {
logger.log('error', prepareError(error), 'RE Get Collections Data');
cb(error);
Expand Down Expand Up @@ -483,17 +483,17 @@ const getLabelPackage = (

const prepareIndexes3x = indexes => {
const hasProperties = /INDEX\s+ON\s+\:(.*)\((.*)\)/i;
let map = {};
const map = {};

indexes.forEach((index, i) => {
if (index.properties) {
index.properties = index.properties;
} else if (hasProperties.test(index.description)) {
let parsedDescription = index.description.match(hasProperties);
index.label = parsedDescription[1];
index.properties = parsedDescription[2].split(',').map(s => s.trim());
} else {
index.properties = [];
if (!index.properties) {
if (hasProperties.test(index.description)) {
const parsedDescription = index.description.match(hasProperties);
index.label = parsedDescription[1];
index.properties = parsedDescription[2].split(',').map(s => s.trim());
} else {
index.properties = [];
}
}

if (!map[index.label]) {
Expand Down

0 comments on commit fbbfeab

Please sign in to comment.