Skip to content

Commit

Permalink
fix: sonarcube changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nitinmittal23 committed Aug 17, 2023
1 parent 51ef864 commit 3b09d13
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 38 deletions.
4 changes: 2 additions & 2 deletions example/consumer/src/interfaces/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
* be saved there for all transfers.
*/
export interface ITransfer {
transactionIndex: Number,
transactionIndex: number,
transactionHash: string,
transactionInitiator: string,
tokenAddress: string,
senderAddress: string,
receiverAddress: string,
amount: string,
timestamp: Date,
blockNumber: Number
blockNumber: number
}
2 changes: 1 addition & 1 deletion internal/block_getters/block_getter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class BlockGetter extends BlockFormatter implements IBlockGetter {
}

return this.formatBlockWithTransactions(
block as BlockTransactionObject,
block,
transactions
);
}
Expand Down
3 changes: 1 addition & 2 deletions internal/interfaces/consumer_config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ConsumerGlobalConfig } from "node-rdkafka";
import { ConsumerTopicConfig } from "node-rdkafka";
import { ConsumerGlobalConfig, ConsumerTopicConfig } from "node-rdkafka";
import { ICoderConfig } from "./coder_config.js";
import { IKafkaCoderConfig } from "./kafka_coder_config.js";

Expand Down
4 changes: 2 additions & 2 deletions internal/interfaces/raw_transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export interface IRawTransaction {
transactionIndex?: string,
from: string,
to: string | null,
value: string | string,
gasPrice: string | string,
value: string,
gasPrice: string,
gas: string,
input: string,
maxFeePerGas?: string,
Expand Down
21 changes: 0 additions & 21 deletions internal/kafka/consumer/abstract_consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,27 +336,6 @@ export abstract class AbstractConsumer extends noderdkafka.KafkaConsumer {
// Can alternatively use this.assign();
this.subscribe(this.topics);

// if (Object.keys(this.startOffsets).length) {
// await new Promise(r => setTimeout(r, 10000));
// for (let topic of Object.keys(this.startOffsets)) {
// Logger.info(`Seeking offset number: ${this.startOffsets[topic]}, for topic: ${topic}`);

// await new Promise(
// (res, rej) => this.seek({
// topic: topic,
// offset: this.startOffsets[topic],
// partition: 0
// }, this.connectionTimeout, (err) => {
// if (err) {
// return rej(err);
// }

// res(undefined);
// })
// );
// }
// }

this.consume();
} catch (error) {
throw KafkaError.createUnknown(error);
Expand Down
11 changes: 4 additions & 7 deletions internal/mongo/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ export class Database {
* @returns {Promis<boolean>}
*/
public async connect(): Promise<boolean> {
if (this.database.connection.readyState === 1 || this.database.connection.readyState === 2) {
return true;
if (!(this.database.connection.readyState === 1 || this.database.connection.readyState === 2)) {
await this.database.connect(this.url);
}

await this.database.connect(this.url);
return true;
}

Expand All @@ -47,12 +46,10 @@ export class Database {
* @returns {Promise<boolean>}
*/
public async disconnect(): Promise<boolean> {
if (this.database.connection.readyState === 0 || this.database.connection.readyState === 3) {
return true;
if (!(this.database.connection.readyState === 0 || this.database.connection.readyState === 3)) {
await this.database.disconnect();
}

await this.database.disconnect();

return true;
}

Expand Down
3 changes: 2 additions & 1 deletion internal/queue/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class Queue<T> {
* @returns {number} - The queue length after clearing.
*/
public clear(): number {
return this.items.length = 0;
this.items.length = 0;
return this.items.length;
}
}
2 changes: 1 addition & 1 deletion public/kafka/consumer/asynchronous_consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class AsynchronousConsumer extends InternalAsynchronousConsumer {

super(
topic,
coders as IKafkaCoderConfig,
coders,
config
);
}
Expand Down
2 changes: 1 addition & 1 deletion public/kafka/consumer/synchronous_consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class SynchronousConsumer extends InternalSynchronousConsumer {

super(
topic,
coders as IKafkaCoderConfig,
coders,
config
);
}
Expand Down

0 comments on commit 3b09d13

Please sign in to comment.