Skip to content

Commit c98ce74

Browse files
authored
Cleanup code (#1053)
This patch removes obsolete comments and standardizes header and inline comment placements. The changes primarily involve reordering or removing ESLint disable comments, license header additions or removals, and the deletion of commented out legacy code. Meanwhile, this patch re-enables `test-raw-pub-sub.js` on Linux platform. Fix: #1052
1 parent 9dc1609 commit c98ce74

31 files changed

+80
-122
lines changed

lib/lifecycle_publisher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class LifecyclePublisher extends Publisher {
3737
* Publish a message only when activated; otherwise do nothing (nop);
3838
*
3939
* @param {object|Buffer} message - The message to be sent, could be kind of JavaScript message generated from .msg
40-
* or be a Buffer for a raw message.
40+
* or be a Buffer for a raw message.
4141
* @returns {undefined}
4242
*/
4343
publish(message) {

lib/node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ class Node extends rclnodejs.ShadowNode {
14961496
);
14971497
}
14981498

1499-
// publish ParameterEvent
1499+
// Publish ParameterEvent.
15001500
this._parameterEventPublisher.publish(parameterEvent);
15011501

15021502
return {

lib/parameter.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable camelcase */
2-
31
// Copyright (c) 2020 Wayne Parrott. All rights reserved.
42
//
53
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,8 +19,9 @@
2119

2220
'use strict';
2321

22+
/* eslint-disable camelcase */
23+
2424
const IsClose = require('is-close');
25-
const rclnodejs = require('bindings')('rclnodejs');
2625

2726
/**
2827
* The plus/minus tolerance for determining number equivalence.

lib/parameter_service.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const { Parameter, PARAMETER_SEPARATOR } = require('./parameter.js');
2727
* rcl_interfaces/srv/GetParameters
2828
* rcl_interfaces/srv/SetParameters
2929
* rcl_interfaces/srv/SetParametersAtomically
30+
* rcl_interfaces/srv/GetParameterTypes
3031
*
3132
* Call start() to begin receiving client request.
3233
* All service requests are forwarded to the node this service works for.

lib/publisher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Publisher extends Entity {
3838
/**
3939
* Publish a message
4040
* @param {object|Buffer} message - The message to be sent, could be kind of JavaScript message generated from .msg
41-
* or be a Buffer for a raw message.
41+
* or be a Buffer for a raw message.
4242
* @return {undefined}
4343
*/
4444
publish(message) {

lib/rate.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//
21
// Licensed under the Apache License, Version 2.0 (the "License");
32
// you may not use this file except in compliance with the License.
43
// You may obtain a copy of the License at

lib/rmw.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
'use strict';
214

315
const DistroUtils = require('./distro');

rosidl_gen/filter.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
13+
'use strict';
14+
115
const fs = require('fs');
216
const path = require('path');
317
const os = require('os');

rosidl_gen/message_translator.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
/* eslint-disable max-depth */
1818

19-
const debug = require('debug')('rclnodejs:message_translator');
20-
2119
function isTypedArray(value) {
2220
return ArrayBuffer.isView(value) && !(value instanceof DataView);
2321
}
@@ -39,7 +37,6 @@ function copyMsgObject(msg, obj) {
3937
// It's an array
4038
if (typeof obj[i][0] === 'object') {
4139
// It's an array of objects: converting to ROS message objects
42-
4340
// 1. Extract the element-type first
4441
// 2. Build the array by translate every elements
4542
let msgArray = [];
@@ -66,8 +63,7 @@ function copyMsgObject(msg, obj) {
6663
function verifyMessage(message, obj) {
6764
if (message.constructor.isROSArray) {
6865
// It's a ROS message array
69-
// Note: there won't be any JavaScript array in message
70-
66+
// Note: there won't be any JavaScript array in message.
7167
if (!Array.isArray(obj)) {
7268
return false;
7369
}
@@ -131,7 +127,7 @@ function toPlainObject(message, enableTypedArray = true) {
131127

132128
if (message.constructor.isROSArray) {
133129
// It's a ROS message array
134-
// Note: there won't be any JavaScript array in message
130+
// Note: there won't be any JavaScript array in message.
135131
let array = [];
136132
message.data.forEach((e) => {
137133
array.push(toPlainObject(e, enableTypedArray)); // Translate every elements

rostsd_gen/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/* eslint-disable max-depth */
2-
/* eslint-disable no-sync */
3-
/* eslint-disable camelcase */
41
// Licensed under the Apache License, Version 2.0 (the "License");
52
// you may not use this file except in compliance with the License.
63
// You may obtain a copy of the License at
@@ -26,6 +23,10 @@ declare module "rclnodejs" {
2623
}
2724
*/
2825

26+
/* eslint-disable max-depth */
27+
/* eslint-disable no-sync */
28+
/* eslint-disable camelcase */
29+
2930
'use strict';
3031

3132
const path = require('path');

scripts/generate_messages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env node
22

3-
/* eslint-disable camelcase */
43
// Copyright (c) 2018 Intel Corporation. All rights reserved.
54

65
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,6 +14,7 @@
1514
// See the License for the specific language governing permissions and
1615
// limitations under the License.
1716

17+
/* eslint-disable camelcase */
1818
'use strict';
1919

2020
const generator = require('../rosidl_gen/index.js');

scripts/ros_distro.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
'use strict';
214

315
const DistroUtils = require('../lib/distro');

scripts/run_test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ const Mocha = require('mocha');
1919
const os = require('os');
2020
const path = require('path');
2121

22-
let rootDir = path.dirname(__dirname);
23-
2422
fs.remove(path.join(path.dirname(__dirname), 'generated'), (err) => {
2523
if (!err) {
2624
let mocha = new Mocha();

src/rcl_bindings.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,6 @@ NAN_METHOD(HasContentFilter) {
710710
info.GetReturnValue().Set(Nan::False());
711711
return;
712712
#else
713-
714713
RclHandle* subscription_handle = RclHandle::Unwrap<RclHandle>(
715714
Nan::To<v8::Object>(info[0]).ToLocalChecked());
716715
rcl_subscription_t* subscription =

test/array_generator.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,6 @@ function noRound(v) {
4141
return v;
4242
}
4343

44-
// const arrayGen = require('./array_generator.js');
45-
// const arrayLength = 100 * 1024;
46-
// arrayGen.generateValues(Float32Array, arrayLength, 100000000, arrayGen.negative, arrayGen.noRound);
47-
// arrayGen.generateValues(Float32Array, arrayLength, 10000, arrayGen.negative, arrayGen.noRound);
48-
// arrayGen.generateValues(Float64Array, arrayLength, Number.MAX_VALUE, arrayGen.negative, arrayGen.noRound);
49-
// arrayGen.generateValues(Float64Array, arrayLength, 10000, arrayGen.negative, arrayGen.noRound);
50-
// arrayGen.generateValues(Int8Array, arrayLength, 128, arrayGen.negative, Math.floor);
51-
// arrayGen.generateValues(Int16Array, arrayLength, 32768, arrayGen.negative, Math.floor);
52-
// arrayGen.generateValues(Int32Array, arrayLength, 2147483648, arrayGen.negative, Math.floor);
53-
// arrayGen.generateValues(Uint8Array, arrayLength, 256, arrayGen.positive, Math.floor);
54-
// arrayGen.generateValues(Uint16Array, arrayLength, 65536, arrayGen.positive, Math.floor);
55-
// arrayGen.generateValues(Uint32Array, arrayLength, 4294967296, arrayGen.positive, Math.floor);
56-
// arrayGen.generateValues(Array, arrayLength, 256, arrayGen.positive, Math.floor);
57-
5844
module.exports = {
5945
generateValues: generateValues,
6046
positive: positive,

test/blocklist.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"Linux": [
3-
"test-raw-pub-sub.js",
43
"test-multi-nodes.js",
54
"test-msg-type-py-node.js",
65
"test-msg-type-cpp-node.js",
@@ -15,7 +14,7 @@
1514
"test-subscription-content-filter.js"
1615
],
1716
"Windows_NT": [
18-
"test-raw-pub-sub.js",
17+
"test-raw-pub-sub.js",
1918
"test-multi-nodes.js",
2019
"test-msg-type-py-node.js",
2120
"test-msg-type-cpp-node.js",

test/test-compound-msg-type-check.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
const assert = require('assert');
1818
const rclnodejs = require('../index.js');
19-
const assertThrowsError = require('./utils.js').assertThrowsError;
2019

2120
describe('Compound types', function () {
2221
this.timeout(60 * 1000);

test/test-distro.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
'use strict';
214

315
const assert = require('assert');
4-
const childProcess = require('child_process');
516
const rclnodejs = require('../index.js');
617

718
const DistroUtils = rclnodejs.DistroUtils;

test/test-extra-destroy-methods.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ describe('Node extra destroy methods testing', function () {
3131
it('destroyPublisher()', function () {
3232
var node = rclnodejs.createNode('node1');
3333
const RclString = 'std_msgs/msg/String';
34-
// const RclString = rclnodejs.require('std_msgs/msg/String');
3534
var publisher = node.createPublisher(RclString, 'chatter');
3635
assert.deepStrictEqual(node._publishers.length, 2);
3736

@@ -51,7 +50,6 @@ describe('Node extra destroy methods testing', function () {
5150
it('destroySubscription()', function () {
5251
var node = rclnodejs.createNode('node2');
5352
const RclString = 'std_msgs/msg/String';
54-
// const RclString = rclnodejs.require('std_msgs/msg/String');
5553
var subscription = node.createSubscription(RclString, 'chatter', () => {});
5654
assert.deepStrictEqual(node._subscriptions.length, 1);
5755

@@ -71,7 +69,6 @@ describe('Node extra destroy methods testing', function () {
7169
it('destroyClient()', function () {
7270
var node = rclnodejs.createNode('node3');
7371
const AddTwoInts = 'example_interfaces/srv/AddTwoInts';
74-
// const AddTwoInts = rclnodejs.require('example_interfaces/srv/AddTwoInts');
7572
var client = node.createClient(AddTwoInts, 'add_two_ints');
7673
assert.deepStrictEqual(node._clients.length, 1);
7774

@@ -91,7 +88,6 @@ describe('Node extra destroy methods testing', function () {
9188
it('destroyService()', function () {
9289
var node = rclnodejs.createNode('node4');
9390
const AddTwoInts = 'example_interfaces/srv/AddTwoInts';
94-
// const AddTwoInts = rclnodejs.require('example_interfaces/srv/AddTwoInts');
9591
var service = node.createService(AddTwoInts, 'add_two_ints', () => {});
9692
assert.deepStrictEqual(node._services.length, 7);
9793

test/test-lifecycle-publisher.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ const assertThrowsError = assertUtils.assertThrowsError;
2121

2222
const NODE_NAME = 'lifecycle_node';
2323

24-
// let StateInterface = rclnodejs.createMessage('lifecycle_msgs/msg/State').constructor;
25-
// let TransitionInterface = rclnodejs.createMessage('lifecycle_msgs/msg/Transition').constructor;
26-
2724
describe('LifecyclePublisher test suite', function () {
2825
let node;
2926
this.timeout(60 * 1000);

test/test-lifecycle.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//
21
// Licensed under the Apache License, Version 2.0 (the "License");
32
// you may not use this file except in compliance with the License.
43
// You may obtain a copy of the License at
@@ -18,7 +17,6 @@ const assert = require('assert');
1817
const rclnodejs = require('../index.js');
1918
const childProcess = require('child_process');
2019
const assertUtils = require('./utils.js');
21-
const assertThrowsError = assertUtils.assertThrowsError;
2220

2321
const NODE_NAME = 'lifecycle_node';
2422

@@ -332,7 +330,6 @@ describe('LifecycleNode test suite', function () {
332330
if (version < GALACTIC_VERSION) return;
333331

334332
let rosDistro = process.env.ROS_DISTRO;
335-
let firstChar = rosDistro.charAt(0);
336333
let testNode = new rclnodejs.lifecycle.LifecycleNode(
337334
'TEST_NODE',
338335
undefined,

test/test-message-type.js

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,6 @@ const assert = require('assert');
1818
const childProcess = require('child_process');
1919
const rclnodejs = require('../index.js');
2020

21-
// function checkType(m, rclType, jsType, value, callback) {
22-
// // rclnodejs, 'Bool', 'boolean', '"true"', callback
23-
// if ((typeof rclType !== 'string') || (typeof value !== 'string')) {
24-
// throw TypeError('Invalid type of parameters!');
25-
// }
26-
27-
// var node = m.createNode(rclType + '_subscription');
28-
// var msgType = m.require('std_msgs').msg[rclType];
29-
// var publisher = childProcess.fork(`${__dirname}/publisher_msg.js`, [rclType, value]);
30-
// var subscription = node.createSubscription(msgType, rclType + '_type_channel', (msg) => {
31-
// publisher.send('quit');
32-
// callback(msg, jsType, value);
33-
// });
34-
// m.spin(node);
35-
// }
36-
3721
describe('Rclnodejs message type testing', function () {
3822
this.timeout(60 * 1000);
3923

@@ -126,19 +110,6 @@ describe('Rclnodejs message type testing', function () {
126110
rclnodejs.spin(node);
127111
});
128112

129-
// it('InitString', function(done) {
130-
// var node = rclnodejs.createNode('init_string_subscription');
131-
// var msgString = 'std_msgs/msg/String';
132-
// var publisher = childProcess.fork(`${__dirname}/publisher_msg.js`, ['InitString', '"RCL String"']);
133-
// var subscription = node.createSubscription(msgString, 'InitString_channel', (msg) => {
134-
// publisher.send('quit');
135-
// assert.deepStrictEqual(typeof msg.data, 'string');
136-
// assert.deepStrictEqual(msg.data, 'RCL String');
137-
// done();
138-
// });
139-
// rclnodejs.spin(node);
140-
// });
141-
142113
it('Int8', function (done) {
143114
var node = rclnodejs.createNode('int8_subscription');
144115
const msgInt8 = 'std_msgs/msg/Int8';
@@ -354,27 +325,23 @@ describe('Rclnodejs message type testing', function () {
354325
(msg) => {
355326
publisher.kill('SIGINT');
356327
assert.ok('r' in msg);
357-
// assert.deepStrictEqual(typeof msg.r, 'number');
328+
assert.deepStrictEqual(typeof msg.r, 'number');
358329
assert.deepStrictEqual(msg.r, 127);
359330
assert.ok('g' in msg);
360-
// assert.deepStrictEqual(typeof msg.g, 'number');
331+
assert.deepStrictEqual(typeof msg.g, 'number');
361332
assert.deepStrictEqual(msg.g, 255);
362333
assert.ok('b' in msg);
363-
// assert.deepStrictEqual(typeof msg.b, 'number');
334+
assert.deepStrictEqual(typeof msg.b, 'number');
364335
assert.deepStrictEqual(msg.b, 255);
365336
assert.ok('a' in msg);
366-
// assert.deepStrictEqual(typeof msg.a, 'number');
337+
assert.deepStrictEqual(typeof msg.a, 'number');
367338
assert.ok(Math.abs(msg.a - 0.5) < 0.000001);
368339
done();
369340
}
370341
);
371342
rclnodejs.spin(node);
372343
});
373344

374-
// it('Array', function(done) {
375-
376-
// });
377-
378345
it('Object with Header', function (done) {
379346
var node = rclnodejs.createNode('header_subscription');
380347
const Header = 'std_msgs/msg/Header';

0 commit comments

Comments
 (0)