Skip to content

Commit 568e1a1

Browse files
authored
Format the codebase (#1012)
Fix: #1011
1 parent e69a22c commit 568e1a1

19 files changed

+215
-189
lines changed

CONTRIBUTORS.md

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,63 @@
1-
rclnodejs contributors (sorted alphabetically)
2-
==============================================
1+
# rclnodejs contributors (sorted alphabetically)
2+
3+
- **[Alaa El Jawad](https://github.com/ejalaa12), [Ian McElroy](https://github.com/imcelroy)**
34

4-
* **[Alaa El Jawad](https://github.com/ejalaa12), [Ian McElroy](https://github.com/imcelroy)**
55
- Fix compatibility with ROS2 parameters array types
66
- Unit tests for all parameter types
77
- Handle concurrent ROS2 client calls, with unit tests
88

9-
* **[Alex Mikhalev](https://github.com/amikhalev)**
10-
* Fix build for AMENT_PREFIX_PATH with multiple entries
11-
12-
* **[Felix Divo](https://github.com/felixdivo)**
13-
* Code cleanup of index.js, tests cases & message generation
14-
* Improved shutdown behavior
15-
* Fixed compilation warnings
16-
17-
* **[Hanyia](https://github.com/hanyia)**
18-
* Benchmark test script
19-
20-
* **[Kenny Yuan](https://github.com/kenny-y)**
21-
* Message features: JS generation, typed arrays, plain JS object, compound msgs, many others...
22-
* npm publish scripts
23-
* Mac support
24-
25-
* **[Matt Richard](https://github.com/mattrichard)**
26-
* ROS2 Actions
27-
* Guard conditions
28-
* Node utility methods (countPublishers/subscribers...)
29-
* TypeScript improvements
30-
* Node 12 compatibility
31-
32-
* **[Minggang Wang](https://github.com/minggangw)**
33-
* Author, lead developer, maintainer
34-
* Core, CI
35-
36-
* **[Martins Mozeiko](https://github.com/martins-mozeiko)**
37-
* QoS new/delete fix
38-
39-
* **[Qiuzhong](https://github.com/qiuzhong)**
40-
* Test coverage for actions, topics, multi-array messages, cross platform, security
41-
* Converted from setTimeout to ROS2 Timer
42-
43-
* **[Teo Koon Peng](https://github.com/koonpeng)**
44-
* TypeScript improvements
45-
* Added Client#waitForService
46-
* Code style improvements, e.g., Prettier formatting
47-
* Improved code generation smarts and efficiency
48-
49-
* **[Wayne Parrott](https://github.com/wayneparrott)**
50-
* TypeScript support with interface generation
51-
* ROS2 parameter support
52-
* ROS2 lifecycle node
53-
* Rate class
54-
* Node class hierarchy
9+
- **[Alex Mikhalev](https://github.com/amikhalev)**
10+
11+
- Fix build for AMENT_PREFIX_PATH with multiple entries
12+
13+
- **[Felix Divo](https://github.com/felixdivo)**
14+
15+
- Code cleanup of index.js, tests cases & message generation
16+
- Improved shutdown behavior
17+
- Fixed compilation warnings
18+
19+
- **[Hanyia](https://github.com/hanyia)**
20+
21+
- Benchmark test script
22+
23+
- **[Kenny Yuan](https://github.com/kenny-y)**
24+
25+
- Message features: JS generation, typed arrays, plain JS object, compound msgs, many others...
26+
- npm publish scripts
27+
- Mac support
28+
29+
- **[Matt Richard](https://github.com/mattrichard)**
30+
31+
- ROS2 Actions
32+
- Guard conditions
33+
- Node utility methods (countPublishers/subscribers...)
34+
- TypeScript improvements
35+
- Node 12 compatibility
36+
37+
- **[Minggang Wang](https://github.com/minggangw)**
38+
39+
- Author, lead developer, maintainer
40+
- Core, CI
41+
42+
- **[Martins Mozeiko](https://github.com/martins-mozeiko)**
43+
44+
- QoS new/delete fix
45+
46+
- **[Qiuzhong](https://github.com/qiuzhong)**
47+
48+
- Test coverage for actions, topics, multi-array messages, cross platform, security
49+
- Converted from setTimeout to ROS2 Timer
50+
51+
- **[Teo Koon Peng](https://github.com/koonpeng)**
52+
53+
- TypeScript improvements
54+
- Added Client#waitForService
55+
- Code style improvements, e.g., Prettier formatting
56+
- Improved code generation smarts and efficiency
57+
58+
- **[Wayne Parrott](https://github.com/wayneparrott)**
59+
- TypeScript support with interface generation
60+
- ROS2 parameter support
61+
- ROS2 lifecycle node
62+
- Rate class
63+
- Node class hierarchy

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
[![npm](https://img.shields.io/npm/v/rclnodejs.svg)](https://www.npmjs.com/package/rclnodejs)[![Coverage Status](https://coveralls.io/repos/github/RobotWebTools/rclnodejs/badge.svg?branch=develop)](https://coveralls.io/github/RobotWebTools/rclnodejs?branch=develop)[![npm](https://img.shields.io/npm/dm/rclnodejs)](https://www.npmjs.com/package/rclnodejs)[![GitHub license](https://img.shields.io/github/license/RobotWebTools/rclnodejs.svg)](https://github.com/RobotWebTools/rclnodejs/blob/develop/LICENSE)[![node](https://img.shields.io/node/v/rclnodejs.svg)](https://nodejs.org/en/download/releases/)[![npm type definitions](https://img.shields.io/npm/types/rclnodejs)](https://www.npmjs.com/package/rclnodejs)[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
44

55
| **ROS Distro\*** | **Linux** | **Windows** |
6-
| :--------------: | :------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------: |
7-
| Jazzy | ![GitHub Workflow Status](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-build-and-test.yml/badge.svg?branch=jazzy) | ![GitHub Workflow Status](https://github.com/RobotWebTools/rclnodejs/actions/workflows/windows-build-and-test.yml/badge.svg?branch=jazzy) |
6+
| :--------------: | :------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------: |
7+
| Jazzy | ![GitHub Workflow Status](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-build-and-test.yml/badge.svg?branch=jazzy) | ![GitHub Workflow Status](https://github.com/RobotWebTools/rclnodejs/actions/workflows/windows-build-and-test.yml/badge.svg?branch=jazzy) |
88
| Humble | ![GitHub Workflow Status](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-build-and-test.yml/badge.svg?branch=humble-hawksbill) | ![GitHub Workflow Status](https://github.com/RobotWebTools/rclnodejs/actions/workflows/windows-build-and-test.yml/badge.svg?branch=humble-hawksbill) |
99

1010
\* rclnodejs development and maintenance is limited to the ROS 2 LTS releases and the Rolling development branch
@@ -106,9 +106,9 @@ Your `tsconfig.json` file should include the following compiler options:
106106
"compilerOptions": {
107107
"module": "commonjs",
108108
"moduleResolution": "node",
109-
"target": "es6"
109+
"target": "es6",
110110
// your additional options here
111-
}
111+
},
112112
}
113113
```
114114

lib/lifecycle_publisher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const Publisher = require('./publisher.js');
2727
*/
2828
class LifecyclePublisher extends Publisher {
2929
constructor(handle, typeClass, topic, options) {
30-
super(handle, typeClass, /*topic=*/'', options);
30+
super(handle, typeClass, /*topic=*/ '', options);
3131

3232
this._enabled = false;
3333
this._loggger = Logging.getLogger('LifecyclePublisher');

lib/node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class Node extends rclnodejs.ShadowNode {
116116
// override cli parameterOverrides with those specified in options
117117
if (options.parameterOverrides.length > 0) {
118118
for (const parameter of options.parameterOverrides) {
119-
if (!parameter instanceof Parameter) {
119+
if ((!parameter) instanceof Parameter) {
120120
throw new TypeError(
121121
'Parameter-override must be an instance of Parameter.'
122122
);
@@ -1696,7 +1696,7 @@ Node.getDefaultOptions = function () {
16961696
isRaw: false,
16971697
qos: QoS.profileDefault,
16981698
contentFilter: undefined,
1699-
willCheckConsistency: false
1699+
willCheckConsistency: false,
17001700
};
17011701
};
17021702

lib/service.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,19 @@ class Service extends Entity {
7575

7676
const plainObj = request.toPlainObject(this.typedArrayEnabled);
7777
const response = new Response(this, headerHandle);
78-
Promise.resolve(this._callback(plainObj, response)).then((responseToReturn) => {
79-
80-
if (!response.sent && responseToReturn) {
81-
responseToReturn = new this._typeClass.Response(responseToReturn);
82-
const rawResponse = responseToReturn.serialize();
83-
rclnodejs.sendResponse(this._handle, rawResponse, headerHandle);
78+
Promise.resolve(this._callback(plainObj, response)).then(
79+
(responseToReturn) => {
80+
if (!response.sent && responseToReturn) {
81+
responseToReturn = new this._typeClass.Response(responseToReturn);
82+
const rawResponse = responseToReturn.serialize();
83+
rclnodejs.sendResponse(this._handle, rawResponse, headerHandle);
84+
}
85+
86+
debug(
87+
`Service has processed the ${this._serviceName} request and sent the response.`
88+
);
8489
}
85-
86-
debug(
87-
`Service has processed the ${this._serviceName} request and sent the response.`
88-
);
89-
});
90+
);
9091
}
9192

9293
static createService(nodeHandle, serviceName, typeClass, options, callback) {

lib/time_source.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class TimeSource {
102102
* @return {undefined}
103103
*/
104104
attachNode(node) {
105-
if (!node instanceof rclnodejs.ShadowNode) {
105+
if ((!node) instanceof rclnodejs.ShadowNode) {
106106
throw new TypeError('Invalid argument, must be type of Node');
107107
}
108108

rosidl_gen/message_translator.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ function toPlainObject(message, enableTypedArray = true) {
149149
// TODO(Kenny): make sure Int64 & Uint64 type can be copied here
150150
obj[name] = message[name];
151151
}
152-
} else if (def.fields[i].type.isArray && def.fields[i].type.type === 'Constants') {
152+
} else if (
153+
def.fields[i].type.isArray &&
154+
def.fields[i].type.type === 'Constants'
155+
) {
153156
// For a constants array, because its field is empty we just return an empty array here.
154157
obj[name] = [];
155158
} else {

rosidl_gen/packages.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ async function generateMsgForSrv(filePath, interfaceInfo, pkgMap) {
148148
await fsp.writeFile(path.join(packagePath, responseMsgName), arr[1]);
149149
let requestInfo = Object.assign({}, interfaceInfo);
150150
requestInfo.filePath = path.join(packagePath, requestMsgName);
151-
requestInfo.interfaceName = requestInfo.interfaceName + "_Request"
151+
requestInfo.interfaceName = requestInfo.interfaceName + '_Request';
152152
let responseInfo = Object.assign({}, interfaceInfo);
153153
responseInfo.filePath = path.join(packagePath, responseMsgName);
154-
responseInfo.interfaceName = responseInfo.interfaceName + "_Response"
154+
responseInfo.interfaceName = responseInfo.interfaceName + '_Response';
155155

156156
addInterfaceInfo(requestInfo, 'messages', pkgMap);
157157
addInterfaceInfo(responseInfo, 'messages', pkgMap);
@@ -199,7 +199,7 @@ async function findAmentPackagesInDirectory(dir) {
199199
const rosFiles = Array.prototype.flat ? files.flat() : flat(files);
200200
const pkgMap = new Map();
201201
await Promise.all(
202-
rosFiles.map(filePath => addInterfaceInfos(filePath, dir, pkgMap))
202+
rosFiles.map((filePath) => addInterfaceInfos(filePath, dir, pkgMap))
203203
);
204204
return pkgMap;
205205
}

rosidl_gen/primitive_types.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ const StringRefStruct = StructType({
2828

2929
function initString(str, own = false) {
3030
if (own) {
31-
if (!str instanceof Buffer) {
31+
if ((!str) instanceof Buffer) {
3232
throw new TypeError(
3333
'Invalid argument: should provide a Node Buffer to bindingsStringInit()'
3434
);
3535
}
3636
rclnodejs.initString(str);
3737
} else {
38-
if (!str instanceof StringRefStruct) {
38+
if ((!str) instanceof StringRefStruct) {
3939
throw new TypeError(
4040
'Invalid argument: should provide a type of StringRefStruct'
4141
);

rostsd_gen/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ function isInternalServiceEventMsgInterface(rosMsgInterface) {
363363
let subFolder = rosMsgInterface.type().subFolder;
364364
// Some package puts .srv files under srvs/, e.g., slam_toolbox.
365365
return (
366-
(subFolder == 'srv' || subFolder == 'srvs' || subFolder == 'action')
367-
&& name.endsWith('_Event')
366+
(subFolder == 'srv' || subFolder == 'srvs' || subFolder == 'action') &&
367+
name.endsWith('_Event')
368368
);
369369
}
370370

0 commit comments

Comments
 (0)