Skip to content

Commit 3de161b

Browse files
committed
Solves new sonar complains
1 parent f6432cd commit 3de161b

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

lib/federate-runner.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11

2-
var childProcess = require('node:child_process');
3-
var devnull = require('dev-null');
4-
var fs = require('fs-extra');
5-
var tmp = require('tmp');
6-
var portUtils = require('./port-utils');
7-
var path = require('node:path');
8-
var find = require('find');
9-
var _ = require('lodash');
10-
let removeDir = require('./utils').removeDir;
2+
const childProcess = require('node:child_process');
3+
const devnull = require('dev-null');
4+
const fs = require('fs-extra');
5+
const tmp = require('tmp');
6+
const portUtils = require('./port-utils');
7+
const path = require('node:path');
8+
const find = require('find');
9+
const _ = require('lodash');
10+
const removeDir = require('./utils').removeDir;
1111

1212
const javaCommand = process.env.JAVA_BIN_PATH ? process.env.JAVA_BIN_PATH : 'java';
1313

14-
var DEFAULT_OPTIONS = {
14+
const DEFAULT_OPTIONS = {
1515
bitcoinPeer: 'localhost:20123',
1616
command: javaCommand,
1717
mainClass: 'co.rsk.federate.FederateRunner',
@@ -22,7 +22,7 @@ var DEFAULT_OPTIONS = {
2222
}
2323
}
2424

25-
var FederateRunner = function(options) {
25+
const FederateRunner = function(options) {
2626
this.options = Object.assign({}, DEFAULT_OPTIONS, options);
2727
}
2828

@@ -31,7 +31,7 @@ FederateRunner.prototype._assignPorts = function(selectedPorts) {
3131
rsk: this.options.port,
3232
rpc: this.options.rpcPort
3333
};
34-
var portIndex = 0;
34+
const portIndex = 0;
3535
if (!this.ports.rsk) {
3636
this.ports.rsk = selectedPorts[portIndex++];
3737
}
@@ -41,7 +41,7 @@ FederateRunner.prototype._assignPorts = function(selectedPorts) {
4141
};
4242

4343
FederateRunner.prototype._setupCustomConfig = function() {
44-
var customConfig = this.options.customConfig || {};
44+
const customConfig = this.options.customConfig || {};
4545

4646
if (this.options.bitcoinPeer && this.options.customConfig['federator.bitcoinPeerAddresses.0'] == null) {
4747
this.options.customConfig['federator.bitcoinPeerAddresses.0'] = this.options.bitcoinPeer;
@@ -60,7 +60,7 @@ FederateRunner.prototype._setupCustomConfig = function() {
6060
};
6161

6262
FederateRunner.prototype._buildArguments = function(customConfig) {
63-
var args = [
63+
const args = [
6464
'-cp', this.options.classpath,
6565
`-Drsk.conf.file=${this.options.configFile}`
6666
];
@@ -80,7 +80,7 @@ FederateRunner.prototype._buildArguments = function(customConfig) {
8080
}
8181

8282
if (this.options.forks.activationHeights) {
83-
var overrideMessage = [];
83+
const overrideMessage = [];
8484
const activationHeightsKeys = Object.keys(this.options.forks.activationHeights);
8585
for (const key of activationHeightsKeys) {
8686
args.push(`-Dblockchain.config.hardforkActivationHeights.${key}=${this.options.forks.activationHeights[key]}`)
@@ -130,27 +130,27 @@ FederateRunner.prototype.start = function() {
130130
throw "Must specify a classpath for the Federate";
131131
}
132132
this.options.classpath = path.resolve(this.options.classpath);
133-
var originalFilename = this.options.classpath;
133+
const originalFilename = this.options.classpath;
134134

135135
if (!fs.existsSync(originalFilename)) {
136136
throw `${originalFilename} does not exist`;
137137
}
138138

139-
var filename = fs.realpathSync(originalFilename);
139+
const filename = fs.realpathSync(originalFilename);
140140
dir = path.dirname(filename);
141141

142142
const runnerStdOut = this.options.runnerStdOut;
143143
find.file(/federate-node.+\-all\.jar$/, dir, function(files) {
144144
//get the files from simbolic links
145-
var realFiles = _.map(files, function(file) {
146-
var stats = fs.lstatSync(file);
147-
var realFile = file;
145+
const realFiles = _.map(files, function(file) {
146+
const stats = fs.lstatSync(file);
147+
let realFile = file;
148148
if(stats.isSymbolicLink()){
149149
realFile = fs.readlinkSync(file);
150150
}
151151
return realFile;
152152
});
153-
var maxFileName = _.max(realFiles);
153+
const maxFileName = _.max(realFiles);
154154
if(maxFileName != null && path.basename(maxFileName) !== path.basename(filename)) {
155155
runnerStdOut.write("WARNING Federate classpath uses " + path.basename(filename) + " but there is a newer version: " + path.basename(maxFileName) + "\n");
156156
}
@@ -161,13 +161,13 @@ FederateRunner.prototype.start = function() {
161161
}
162162
this.options.configFile = path.resolve(this.options.configFile);
163163

164-
var portsNeeded = (!this.options.port ? 1 : 0) + (!this.options.rpcPort ? 1 : 0);
165-
var futurePorts = portsNeeded === 0 ? Promise.resolve([]) : portUtils.findFreePort(20000, 20100, '127.0.0.1', portsNeeded);
164+
const portsNeeded = (!this.options.port ? 1 : 0) + (!this.options.rpcPort ? 1 : 0);
165+
const futurePorts = portsNeeded === 0 ? Promise.resolve([]) : portUtils.findFreePort(20000, 20100, '127.0.0.1', portsNeeded);
166166

167167
return futurePorts.then((selectedPorts) => {
168168
this._assignPorts(selectedPorts);
169-
var customConfig = this._setupCustomConfig();
170-
var args = this._buildArguments(customConfig);
169+
const customConfig = this._setupCustomConfig();
170+
const args = this._buildArguments(customConfig);
171171
this._setupProcess(args);
172172

173173
runnerStdOut.write(` starting!\n`);

lib/rsk-utils.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ let secp;
2525

2626
// NOSONAR: Top-level await is not supported in CommonJS modules (this file uses require()).
2727
// Using promise chain to initialize secp module. The module is loaded asynchronously before functions that use it are called.
28-
// NOSONAR
29-
import('@noble/secp256k1').then(secpModule => {
28+
import('@noble/secp256k1').then(secpModule => { // NOSONAR S-6036
3029
secp = secpModule;
3130
});
3231

0 commit comments

Comments
 (0)