Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCK-7062: fix Sonar reports #51

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it's checked here

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, '`', '`');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it's checked here

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