Skip to content

Commit

Permalink
HCK-7062: fix Sonar reports (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlikRakhmonov authored Jul 12, 2024
1 parent ce31d5b commit 2c155ac
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
3 changes: 3 additions & 0 deletions forward_engineering/ddlProvider/ddlHelpers/keyHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ module.exports = (_, clean) => {
}
};

const mapKeyOrder = key => `\`${key.name}\`${key.type === 'DESC' ? ' DESC' : ''}`;

const hydrateUniqueOptions = (options, columnName, isActivated) =>
clean({
keyType: 'UNIQUE',
Expand Down Expand Up @@ -163,5 +165,6 @@ module.exports = (_, clean) => {
isInlinePrimaryKey,
hydratePrimaryKeyOptions,
hydrateUniqueOptions,
mapKeyOrder,
};
};
14 changes: 6 additions & 8 deletions forward_engineering/ddlProvider/ddlProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,17 @@ module.exports = (baseProvider, options, app) => {
return '';
}

const allDeactivated = checkAllKeysDeactivated(index.indxKey || []);
const allDeactivated = checkAllKeysDeactivated(index.indxKey);
const wholeStatementCommented = index.isActivated === false || !isParentActivated || allDeactivated;
const indexType = index.indexType ? `${_.toUpper(index.indexType)} ` : '';
const ifNotExist = index.ifNotExist ? 'IF NOT EXISTS ' : '';
const name = wrap(index.indxName || '', '`', '`');
const name = wrap(index.indxName, '`', '`');
const table = getTableName(tableName, dbData.databaseName);
const indexCategory = index.indexCategory ? ` USING ${index.indexCategory}` : '';
let indexOptions = [];

const dividedKeys = divideIntoActivatedAndDeactivated(
index.indxKey || [],
key => `\`${key.name}\`${key.type === 'DESC' ? ' DESC' : ''}`,
);
const dividedKeys = divideIntoActivatedAndDeactivated(index.indxKey, keyHelper.mapKeyOrder);

const commentedKeys = dividedKeys.deactivatedItems.length
? commentIfDeactivated(dividedKeys.deactivatedItems.join(', '), {
isActivated: wholeStatementCommented,
Expand Down Expand Up @@ -252,9 +250,9 @@ module.exports = (baseProvider, options, app) => {

if (wholeStatementCommented) {
return commentIfDeactivated(indexStatement, { isActivated: false });
} else {
return indexStatement;
}

return indexStatement;
},

/**
Expand Down
2 changes: 1 addition & 1 deletion reverse_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ module.exports = {
const collections = data.collectionData.collections;
const dataBaseNames = data.collectionData.dataBaseNames;
const connection = await this.connect(data, app);
const instance = await connectionHelper.createInstance(connection, logger);
const instance = connectionHelper.createInstance(connection, logger);

log.info('MariaDB version: ' + (await instance.serverVersion()));
log.progress('Start reverse engineering ...');
Expand Down

0 comments on commit 2c155ac

Please sign in to comment.