Skip to content

Commit

Permalink
HCK-7073 - Fix sonar reports (#32)
Browse files Browse the repository at this point in the history
* Fix sonar reliability reports

* Fix reliability reports

* Update indexHelper.js

---------

Co-authored-by: chulanovskyi-bs <[email protected]>
  • Loading branch information
bigorn0 and chulanovskyi-bs authored Jul 12, 2024
1 parent 1d149f9 commit 5276575
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
17 changes: 3 additions & 14 deletions forward_engineering/helpers/keyHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ module.exports = (_, clean) => {
}

const primaryKeyConstraints = mapProperties(jsonSchema, ([name, schema]) => {
if (!isPrimaryKey(schema)) {
return;
} else if (_.isEmpty(schema.primaryKeyConstraintName)) {
if (!isPrimaryKey(schema) || _.isEmpty(schema.primaryKeyConstraintName)) {
return;
}

Expand All @@ -109,25 +107,16 @@ module.exports = (_, clean) => {
'PRIMARY KEY',
name,
schema.isActivated,
jsonSchema,
);
}).filter(Boolean);

const uniqueKeyConstraints = _.flatten(
mapProperties(jsonSchema, ([name, schema]) => {
if (!isUniqueKey(schema)) {
return;
} else if (_.isEmpty(schema.uniqueKeyConstraintName)) {
if (!isUniqueKey(schema) || _.isEmpty(schema.uniqueKeyConstraintName)) {
return;
}

return hydrateKeyConstraintOptions(
schema.uniqueKeyConstraintName,
'UNIQUE',
name,
schema.isActivated,
jsonSchema,
);
return hydrateKeyConstraintOptions(schema.uniqueKeyConstraintName, 'UNIQUE', name, schema.isActivated);
}),
).filter(Boolean);

Expand Down
6 changes: 3 additions & 3 deletions reverse_engineering/helpers/connectionHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ const createConnection = async (connectionInfo, sshService, logger) => {

return {
execute: query => {
return new Promise(async (resolve, reject) => {
return new Promise((resolve, reject) => {
const queryArgument = createArgument('query', query);
const queryResult = spawn(`"${javaPath}"`, [...teradataClientCommandArguments, queryArgument], {
shell: true,
});

queryResult.on('error', error => {
reject(error);
reject(new Error(error));
});

const errorData = [];
Expand Down Expand Up @@ -172,7 +172,7 @@ const createConnection = async (connectionInfo, sshService, logger) => {

const parsedResult = JSON.parse(rowJson);
if (parsedResult.error) {
reject(parsedResult.error);
reject(new Error(parsedResult.error));
return;
}

Expand Down
6 changes: 3 additions & 3 deletions reverse_engineering/helpers/indexHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const cleanKeyName = (name = '') => {
};
const parseIndexKeys = statement => {
const mathResult = statement.match(regexConfig.indexKeyName);
if (!mathResult || !mathResult.length) {
if (!mathResult?.length) {
return [];
}

Expand All @@ -14,7 +14,7 @@ const parseIndexKeys = statement => {

const parseHashIndexStatement = statement => {
const matchResult = regexConfig.createHashIndex.exec(statement);
if (!matchResult || !matchResult.groups) {
if (!matchResult?.groups) {
return {};
}

Expand All @@ -32,7 +32,7 @@ const parseHashIndexStatement = statement => {

const parseJoinIndexStatement = statement => {
const matchResult = regexConfig.createJoinIndex.exec(statement);
if (!matchResult || !matchResult.groups) {
if (!matchResult?.groups) {
return {};
}

Expand Down

0 comments on commit 5276575

Please sign in to comment.