Skip to content

Commit adfb558

Browse files
author
diego Dupin
committed
[misc] code style length change to 120
1 parent 1da25cd commit adfb558

File tree

86 files changed

+515
-1493
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+515
-1493
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"es6": true
1818
},
1919
"rules": {
20-
"linebreak-style": ["error", "unix"]
20+
"linebreak-style": ["error", "unix"],
21+
"max-len": ["error", { "code": 120 , "ignoreStrings": true, "ignoreTemplateLiterals": true}]
2122
}
2223
}

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"trailingComma": "none",
33
"tabWidth": 2,
4-
"printWidth": 100,
4+
"printWidth": 120,
55
"semi": true,
66
"singleQuote": true,
77
"endOfLine": "lf"

benchmarks/benchs/insert_batch.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ function randomString(length) {
1414
}
1515

1616
let sqlTable =
17-
'CREATE TABLE testn.perfTestTextPipe (id MEDIUMINT NOT NULL AUTO_INCREMENT,t0 text' +
18-
', PRIMARY KEY (id))';
17+
'CREATE TABLE testn.perfTestTextPipe (id MEDIUMINT NOT NULL AUTO_INCREMENT,t0 text' + ', PRIMARY KEY (id))';
1918
sqlInsert = 'INSERT INTO testn.perfTestTextPipe(t0) VALUES (?)';
2019

2120
module.exports.title =

benchmarks/benchs/insert_pipelining.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ function randomString(length) {
1414
}
1515

1616
let sqlTable =
17-
'CREATE TABLE testn.perfTestTextPipe (id MEDIUMINT NOT NULL AUTO_INCREMENT,t0 text' +
18-
', PRIMARY KEY (id))';
17+
'CREATE TABLE testn.perfTestTextPipe (id MEDIUMINT NOT NULL AUTO_INCREMENT,t0 text' + ', PRIMARY KEY (id))';
1918
sqlInsert = 'INSERT INTO testn.perfTestTextPipe(t0) VALUES (?)';
2019

2120
module.exports.title = 'insert 100 characters pipelining';

benchmarks/common_benchmarks.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ function Bench() {
119119
if (promiseMysql2 && promiseMysql2.clearParserCache) promiseMysql2.clearParserCache();
120120
console.log(event.target.toString());
121121
const drvType = event.target.options.drvType;
122-
const benchTitle =
123-
event.target.options.benchTitle + '\n [ sql: ' + event.target.options.displaySql + ' ]';
122+
const benchTitle = event.target.options.benchTitle + '\n [ sql: ' + event.target.options.displaySql + ' ]';
124123
const iteration = 1 / event.target.times.period;
125124
const variation = event.target.stats.rme;
126125

@@ -259,16 +258,7 @@ Bench.prototype.fill = function (val, length, right) {
259258

260259
Bench.prototype.add = function (title, displaySql, fct, onComplete, usePool, requireExecute, conn) {
261260
const self = this;
262-
const addTest = getAddTest(
263-
self,
264-
this.suite,
265-
fct,
266-
this.minSamples,
267-
title,
268-
displaySql,
269-
onComplete,
270-
usePool
271-
);
261+
const addTest = getAddTest(self, this.suite, fct, this.minSamples, title, displaySql, onComplete, usePool);
272262

273263
if (conn) {
274264
addTest(conn, conn.desc);

benchmarks/log-utility.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,8 @@ const defaultImgJson = {
6464

6565
module.exports.getImg = (data) => {
6666
const pjson = require('../package-lock.json');
67-
const mysql2Version = pjson.packages['node_modules/mysql2']
68-
? pjson.packages['node_modules/mysql2'].version
69-
: null;
70-
const mysqlVersion = pjson.packages['node_modules/mysql']
71-
? pjson.packages['node_modules/mysql'].version
72-
: null;
67+
const mysql2Version = pjson.packages['node_modules/mysql2'] ? pjson.packages['node_modules/mysql2'].version : null;
68+
const mysqlVersion = pjson.packages['node_modules/mysql'] ? pjson.packages['node_modules/mysql'].version : null;
7369
const mariadbVersion = pjson.packages[''] ? pjson.packages[''].version : null;
7470

7571
//clone
@@ -105,7 +101,6 @@ module.exports.getImg = (data) => {
105101
resJson.options.title.text = data.title;
106102

107103
return (
108-
'https://quickchart.io/chart?devicePixelRatio=1.0&h=160&w=520&c=' +
109-
encodeURIComponent(JSON.stringify(resJson))
104+
'https://quickchart.io/chart?devicePixelRatio=1.0&h=160&w=520&c=' + encodeURIComponent(JSON.stringify(resJson))
110105
);
111106
};

lib/cmd/batch-bulk.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,7 @@ class BatchBulk extends Parser {
221221
*/
222222
sendComStmtBulkExecute(out, opts, info) {
223223
if (opts.logger.query)
224-
opts.logger.query(
225-
`BULK: (${this.prepare.id}) ${opts.logger.logParam ? this.displaySql() : this.sql}`
226-
);
224+
opts.logger.query(`BULK: (${this.prepare.id}) ${opts.logger.logParam ? this.displaySql() : this.sql}`);
227225
const parameterCount = this.prepare.parameters.length;
228226
this.rowIdx = 0;
229227
this.vals = this.values[this.rowIdx++];
@@ -439,16 +437,7 @@ class BatchBulk extends Parser {
439437
this.bulkPacketNo = 0;
440438
}
441439
if (this.stack) {
442-
err = Errors.createError(
443-
err.message,
444-
err.errno,
445-
info,
446-
err.sqlState,
447-
this.sql,
448-
err.fatal,
449-
this.stack,
450-
false
451-
);
440+
err = Errors.createError(err.message, err.errno, info, err.sqlState, this.sql, err.fatal, this.stack, false);
452441
}
453442
this.firstError = err;
454443
}

lib/cmd/change-user.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ class ChangeUser extends Handshake {
121121
}
122122
this.opts = cmdOpts ? Object.assign({}, connOpts, cmdOpts) : connOpts;
123123
this.opts.database = cmdOpts.database ? cmdOpts.database : connOpts.database;
124-
this.opts.connectAttributes = cmdOpts.connectAttributes
125-
? cmdOpts.connectAttributes
126-
: connOpts.connectAttributes;
124+
this.opts.connectAttributes = cmdOpts.connectAttributes ? cmdOpts.connectAttributes : connOpts.connectAttributes;
127125

128126
if (cmdOpts.charset && typeof cmdOpts.charset === 'string') {
129127
this.opts.collation = Collations.fromCharset(cmdOpts.charset.toLowerCase());
@@ -139,13 +137,11 @@ class ChangeUser extends Handshake {
139137
);
140138
}
141139
}
142-
if (this.opts.collation === undefined)
143-
throw new RangeError("Unknown charset '" + cmdOpts.charset + "'");
140+
if (this.opts.collation === undefined) throw new RangeError("Unknown charset '" + cmdOpts.charset + "'");
144141
} else if (cmdOpts.collation && typeof cmdOpts.collation === 'string') {
145142
const initial = cmdOpts.collation;
146143
this.opts.collation = Collations.fromName(initial.toUpperCase());
147-
if (this.opts.collation === undefined)
148-
throw new RangeError("Unknown collation '" + initial + "'");
144+
if (this.opts.collation === undefined) throw new RangeError("Unknown collation '" + initial + "'");
149145
} else {
150146
this.opts.collation = Collations.fromIndex(cmdOpts.charsetNumber) || connOpts.collation;
151147
}
@@ -154,9 +150,7 @@ class ChangeUser extends Handshake {
154150
}
155151

156152
function writeParam(out, val, encoding) {
157-
let param = Buffer.isEncoding(encoding)
158-
? Buffer.from(val, encoding)
159-
: Iconv.encode(val, encoding);
153+
let param = Buffer.isEncoding(encoding) ? Buffer.from(val, encoding) : Iconv.encode(val, encoding);
160154
out.writeLengthCoded(param.length);
161155
out.writeBuffer(param, 0, param.length);
162156
}

lib/cmd/close-prepare.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ class ClosePrepare extends Command {
1313
}
1414

1515
start(out, opts, info) {
16-
if (opts.logger.query)
17-
opts.logger.query(`CLOSE PREPARE: (${this.prepare.id}) ${this.prepare.query}`);
16+
if (opts.logger.query) opts.logger.query(`CLOSE PREPARE: (${this.prepare.id}) ${this.prepare.query}`);
1817
out.startPacket(this);
1918
out.writeInt8(0x19);
2019
out.writeInt32(this.prepare.id);

lib/cmd/column-definition.js

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,18 @@ class ColumnDef {
5050
switch (this.columnType) {
5151
case FieldType.TINY:
5252
if (this.signed()) {
53-
this._read = (packet, index, nullBitmap) =>
54-
isNullBitmap(index, nullBitmap) ? null : packet.readInt8();
53+
this._read = (packet, index, nullBitmap) => (isNullBitmap(index, nullBitmap) ? null : packet.readInt8());
5554
} else {
56-
this._read = (packet, index, nullBitmap) =>
57-
isNullBitmap(index, nullBitmap) ? null : packet.readUInt8();
55+
this._read = (packet, index, nullBitmap) => (isNullBitmap(index, nullBitmap) ? null : packet.readUInt8());
5856
}
5957
break;
6058

6159
case FieldType.YEAR:
6260
case FieldType.SHORT:
6361
if (this.signed()) {
64-
this._read = (packet, index, nullBitmap) =>
65-
isNullBitmap(index, nullBitmap) ? null : packet.readInt16();
62+
this._read = (packet, index, nullBitmap) => (isNullBitmap(index, nullBitmap) ? null : packet.readInt16());
6663
} else {
67-
this._read = (packet, index, nullBitmap) =>
68-
isNullBitmap(index, nullBitmap) ? null : packet.readUInt16();
64+
this._read = (packet, index, nullBitmap) => (isNullBitmap(index, nullBitmap) ? null : packet.readUInt16());
6965
}
7066
break;
7167

@@ -93,33 +89,26 @@ class ColumnDef {
9389

9490
case FieldType.INT:
9591
if (this.signed()) {
96-
this._read = (packet, index, nullBitmap) =>
97-
isNullBitmap(index, nullBitmap) ? null : packet.readInt32();
92+
this._read = (packet, index, nullBitmap) => (isNullBitmap(index, nullBitmap) ? null : packet.readInt32());
9893
} else {
99-
this._read = (packet, index, nullBitmap) =>
100-
isNullBitmap(index, nullBitmap) ? null : packet.readUInt32();
94+
this._read = (packet, index, nullBitmap) => (isNullBitmap(index, nullBitmap) ? null : packet.readUInt32());
10195
}
10296
break;
10397

10498
case FieldType.FLOAT:
105-
this._read = (packet, index, nullBitmap) =>
106-
isNullBitmap(index, nullBitmap) ? null : packet.readFloat();
99+
this._read = (packet, index, nullBitmap) => (isNullBitmap(index, nullBitmap) ? null : packet.readFloat());
107100
break;
108101

109102
case FieldType.DOUBLE:
110-
this._read = (packet, index, nullBitmap) =>
111-
isNullBitmap(index, nullBitmap) ? null : packet.readDouble();
103+
this._read = (packet, index, nullBitmap) => (isNullBitmap(index, nullBitmap) ? null : packet.readDouble());
112104
break;
113105

114106
case FieldType.BIGINT:
115107
this._read = (packet, index, nullBitmap, opts) => {
116108
if (isNullBitmap(index, nullBitmap)) return null;
117109
const val = this.signed() ? packet.readBigInt64() : packet.readBigUInt64();
118110
if (val != null && (opts.bigIntAsNumber || opts.supportBigNumbers)) {
119-
if (
120-
opts.supportBigNumbers &&
121-
(opts.bigNumberStrings || !Number.isSafeInteger(Number(val)))
122-
) {
111+
if (opts.supportBigNumbers && (opts.bigNumberStrings || !Number.isSafeInteger(Number(val)))) {
123112
return val.toString();
124113
}
125114
return Number(val);
@@ -134,10 +123,7 @@ class ColumnDef {
134123
if (isNullBitmap(index, nullBitmap)) return null;
135124
const valDec = packet.readDecimalLengthEncoded();
136125
if (valDec != null && (opts.decimalAsNumber || opts.supportBigNumbers)) {
137-
if (
138-
opts.supportBigNumbers &&
139-
(opts.bigNumberStrings || !Number.isSafeInteger(Number(valDec)))
140-
) {
126+
if (opts.supportBigNumbers && (opts.bigNumberStrings || !Number.isSafeInteger(Number(valDec)))) {
141127
return valDec.toString();
142128
}
143129
return Number(valDec);
@@ -239,10 +225,7 @@ class ColumnDef {
239225
this._read = (packet, index, nullBitmap, opts) => {
240226
const val = packet.readBigIntLengthEncoded();
241227
if (val != null && (opts.bigIntAsNumber || opts.supportBigNumbers)) {
242-
if (
243-
opts.supportBigNumbers &&
244-
(opts.bigNumberStrings || !Number.isSafeInteger(Number(val)))
245-
) {
228+
if (opts.supportBigNumbers && (opts.bigNumberStrings || !Number.isSafeInteger(Number(val)))) {
246229
return val.toString();
247230
}
248231
return Number(val);
@@ -256,10 +239,7 @@ class ColumnDef {
256239
this._read = (packet, index, nullBitmap, opts) => {
257240
const valDec = packet.readDecimalLengthEncoded();
258241
if (valDec != null && (opts.decimalAsNumber || opts.supportBigNumbers)) {
259-
if (
260-
opts.supportBigNumbers &&
261-
(opts.bigNumberStrings || !Number.isSafeInteger(Number(valDec)))
262-
) {
242+
if (opts.supportBigNumbers && (opts.bigNumberStrings || !Number.isSafeInteger(Number(valDec)))) {
263243
return valDec.toString();
264244
}
265245
return Number(valDec);

0 commit comments

Comments
 (0)