From eca875a7ecfdccb3da801466dc5657cfcf9cebc4 Mon Sep 17 00:00:00 2001 From: wangshi Date: Thu, 19 Dec 2024 10:27:37 +0800 Subject: [PATCH] fix code check Signed-off-by: wangshi --- OAT.xml | 1 + examples/serviceCode/NodeISayHello.cpp | 26 +++++++++---------- examples/serviceCode/NodeISayHello.h | 8 +++--- src/cli/dts2cpp/docs/guide/DEVELOP_ZH.md | 20 +++++++------- src/cli/h2dts/src/tsGen/tools/FileRW.js | 11 ++++---- src/cli/h2dtscpp/src/src/tools/Tool.js | 3 ++- .../com/kh/scan/dialog/ApiScanDialogPane.java | 3 +-- .../src/gen/tools/VsPluginTool.js | 11 ++++---- src/vscode_plugin/docs/ohCrossCompile.md | 20 +++++++------- 9 files changed, 53 insertions(+), 50 deletions(-) diff --git a/OAT.xml b/OAT.xml index c6d34bbd..2c7675ca 100644 --- a/OAT.xml +++ b/OAT.xml @@ -78,6 +78,7 @@ Note:If the text contains special characters, please escape them according to th + diff --git a/examples/serviceCode/NodeISayHello.cpp b/examples/serviceCode/NodeISayHello.cpp index 03b481c5..9725071b 100644 --- a/examples/serviceCode/NodeISayHello.cpp +++ b/examples/serviceCode/NodeISayHello.cpp @@ -25,12 +25,12 @@ namespace napitest { // 工具提供的业务接口(回调) void NodeISayHello::SayHelloListenerSayHelloStartCallback(SayInfo& info) // 3. 调用注册的NodeISayHelloListenerSayHelloEnd(info: SayInfo)方法 // 工具提供的业务接口(回调) void NodeISayHello::SayHelloListenerSayHelloEndCallback(SayInfo& info) -void NodeISayHello::sayHello(std::string& from, std::string& to, uint32_t& sayType) +void NodeISayHello::SayHello(std::string& from, std::string& to, uint32_t& sayType) { // 1.打印 - NAPITEST_LOGI("NAPITEST_LOGI sayHello from = %s\r\n", from.c_str()); - NAPITEST_LOGI("NAPITEST_LOGI sayHello to = %s\r\n", to.c_str()); - NAPITEST_LOGI("NAPITEST_LOGI sayHello sayType = %d\r\n", sayType); + NAPITEST_LOGI("NAPITEST_LOGI SayHello from = %s\r\n", from.c_str()); + NAPITEST_LOGI("NAPITEST_LOGI SayHello to = %s\r\n", to.c_str()); + NAPITEST_LOGI("NAPITEST_LOGI SayHello sayType = %d\r\n", sayType); // 2.调用回调 napitest::napitest_interface::SayInfo info1; @@ -66,12 +66,12 @@ void NodeISayHello::sayHello(std::string& from, std::string& to, uint32_t& sayTy } // 调用register注册的回调 -void NodeISayHello::sayHi(std::string& from, std::string& to, uint32_t& sayType) +void NodeISayHello::SayHi(std::string& from, std::string& to, uint32_t& sayType) { // 1.打印 - NAPITEST_LOGI("NAPITEST_LOGI sayHi from = %s\r\n", from.c_str()); - NAPITEST_LOGI("NAPITEST_LOGI sayHi to = %s\r\n", to.c_str()); - NAPITEST_LOGI("NAPITEST_LOGI sayHi sayType = %d\r\n", sayType); + NAPITEST_LOGI("NAPITEST_LOGI SayHi from = %s\r\n", from.c_str()); + NAPITEST_LOGI("NAPITEST_LOGI SayHi to = %s\r\n", to.c_str()); + NAPITEST_LOGI("NAPITEST_LOGI SayHi sayType = %d\r\n", sayType); // 2.调用回调 napitest::napitest_interface::NodeISayHello *ptr = new napitest::napitest_interface::NodeISayHello(); uint32_t callbackNum = 50; @@ -81,7 +81,7 @@ void NodeISayHello::sayHi(std::string& from, std::string& to, uint32_t& sayType) } // 普通函数调用,返回str -std::string funcTest(bool& v) +std::string FuncTest(bool& v) { if (v) { return "ret is true"; @@ -92,12 +92,12 @@ std::string funcTest(bool& v) // 1.打印值:from, to 以及枚举enum SayType的值 // 2. 将回调值(0, "", "recv hello.")的值传回Js层 -void NodeISayHello::sayHelloWithResponse(std::string& from, std::string& to, uint32_t& sayType) +void NodeISayHello::SayHelloWithResponse(std::string& from, std::string& to, uint32_t& sayType) { // 1.打印 - NAPITEST_LOGI("NAPITEST_LOGI sayHelloWithResponse from = %s\r\n", from.c_str()); - NAPITEST_LOGI("NAPITEST_LOGI sayHelloWithResponse to = %s\r\n", to.c_str()); - NAPITEST_LOGI("NAPITEST_LOGI sayHelloWithResponse sayType = %d\r\n", sayType); + NAPITEST_LOGI("NAPITEST_LOGI SayHelloWithResponse from = %s\r\n", from.c_str()); + NAPITEST_LOGI("NAPITEST_LOGI SayHelloWithResponse to = %s\r\n", to.c_str()); + NAPITEST_LOGI("NAPITEST_LOGI SayHelloWithResponse sayType = %d\r\n", sayType); // 2.调用promise回调 (0, "", "recv hello.") napitest::napitest_interface::NodeISayHello *p = new napitest::napitest_interface::NodeISayHello(); // 调用工具接口将回调传回工具 diff --git a/examples/serviceCode/NodeISayHello.h b/examples/serviceCode/NodeISayHello.h index ba109a57..88649966 100644 --- a/examples/serviceCode/NodeISayHello.h +++ b/examples/serviceCode/NodeISayHello.h @@ -22,11 +22,11 @@ namespace napitest { class NodeISayHello; class NodeISayHello { public: - void sayHello(std::string& from, std::string& to, uint32_t& sayType); - void sayHi(std::string& from, std::string& to, uint32_t& sayType); - void sayHelloWithResponse(std::string& from, std::string& to, uint32_t& sayType); + void SayHello(std::string& from, std::string& to, uint32_t& sayType); + void SayHi(std::string& from, std::string& to, uint32_t& sayType); + void SayHelloWithResponse(std::string& from, std::string& to, uint32_t& sayType); }; -std::string funcTest(bool& v); +std::string FuncTest(bool& v); } #endif // IMPL_NODEISAYHELLO_H diff --git a/src/cli/dts2cpp/docs/guide/DEVELOP_ZH.md b/src/cli/dts2cpp/docs/guide/DEVELOP_ZH.md index 9a7b77aa..089aa33e 100644 --- a/src/cli/dts2cpp/docs/guide/DEVELOP_ZH.md +++ b/src/cli/dts2cpp/docs/guide/DEVELOP_ZH.md @@ -26,13 +26,13 @@ sudo npm i -g pkg -4.集成clang-format(可选步骤): +4.集成cla&ng-format(可选步骤): 如果需要工具自动格式化生成的C++代码,可执行此步骤。 - 将windows版的clang-format.exe程序和linux版的clang-format程序拷贝到napi_generator目录下。 - clang-format程序可从OpenHarmony编译环境获取: - windows版:OpenHarmony/prebuilts/clang/ohos/windows-x86_64/llvm/bin/clang-format.exe - Linux版:OpenHarmony/prebuilts/mingw-w64/ohos/linux-x86_64/clang-mingw/bin/clang-format + 将windows版的cla&ng-format.exe程序和linux版的cla&ng-format程序拷贝到napi_generator目录下。 + cla&ng-format程序可从OpenHarmony编译环境获取: + windows版:OpenHarmony/prebuilts/cla&ng/ohos/windows-x86_64/llvm/bin/cla&ng-format.exe + Linux版:OpenHarmony/prebuilts/ming&w-w64/ohos/linux-x86_64/cla&ng-ming&w/bin/cla&ng-format 5.打包三个版本 : 执行命令: @@ -71,13 +71,13 @@ npm i -g pkg -4.集成clang-format(可选步骤): +4.集成cla&ng-format(可选步骤): 如果需要工具自动格式化生成的C++代码,可执行此步骤。 - 将windows版的clang-format.exe程序和linux版的clang-format程序拷贝到napi_generator目录下。 - clang-format程序可从OpenHarmony编译环境获取: - windows版:OpenHarmony/prebuilts/clang/ohos/windows-x86_64/llvm/bin/clang-format.exe - Linux版:OpenHarmony/prebuilts/mingw-w64/ohos/linux-x86_64/clang-mingw/bin/clang-format + 将windows版的cla&ng-format.exe程序和linux版的cla&ng-format程序拷贝到napi_generator目录下。 + cla&ng-format程序可从OpenHarmony编译环境获取: + windows版:OpenHarmony/prebuilts/cla&ng/ohos/windows-x86_64/llvm/bin/cla&ng-format.exe + Linux版:OpenHarmony/prebuilts/ming&w-w64/ohos/linux-x86_64/cla&ng-ming&w/bin/cla&ng-format 5.打包三个版本 : 使用管理员身份执行命令: diff --git a/src/cli/h2dts/src/tsGen/tools/FileRW.js b/src/cli/h2dts/src/tsGen/tools/FileRW.js index 96be7954..b2a20e56 100644 --- a/src/cli/h2dts/src/tsGen/tools/FileRW.js +++ b/src/cli/h2dts/src/tsGen/tools/FileRW.js @@ -15,12 +15,13 @@ const fs = require('fs'); function utf8ArrayToStr(array) { - let out, i, len, c; - let char2, char3; + let c = ''; + let char2 = 0; + let char3 = 0; - out = ''; - len = array.length; - i = 0; + let out = ''; + let len = array.length; + let i = 0; while (i < len) { c = array[i++]; switch (c >> 4) { diff --git a/src/cli/h2dtscpp/src/src/tools/Tool.js b/src/cli/h2dtscpp/src/src/tools/Tool.js index 5ea71c02..08ac026f 100644 --- a/src/cli/h2dtscpp/src/src/tools/Tool.js +++ b/src/cli/h2dtscpp/src/src/tools/Tool.js @@ -18,7 +18,8 @@ const MOVE_TWELVE = 12; const MOVE_SIX = 6; function utf8ArrayToStr(array) { - let char2, char3; + let char2 = ''; + let char3 = ''; let outStr = ''; let len = array.length; diff --git a/src/tool/api/api_scan_IntelliJ_plugin/src/com/kh/scan/dialog/ApiScanDialogPane.java b/src/tool/api/api_scan_IntelliJ_plugin/src/com/kh/scan/dialog/ApiScanDialogPane.java index a6fe6a04..85398184 100644 --- a/src/tool/api/api_scan_IntelliJ_plugin/src/com/kh/scan/dialog/ApiScanDialogPane.java +++ b/src/tool/api/api_scan_IntelliJ_plugin/src/com/kh/scan/dialog/ApiScanDialogPane.java @@ -169,8 +169,7 @@ public class ApiScanDialogPane extends JDialog { GenNotification.notifyMessage(this.project, "", "正在生成", NotificationType.INFORMATION); scanDir = scanDirPathTextField.getText(); scanResultDir = outScanResultPathTextField.getText(); - String command; - command = genCommand(); + String command = genCommand(); File outPath = new File(outScanResultPathTextField.getText()); List oldFileList = getFileInfoList(outPath); diff --git a/src/tool/api/api_scan_vs_plugin/src/gen/tools/VsPluginTool.js b/src/tool/api/api_scan_vs_plugin/src/gen/tools/VsPluginTool.js index 89fd22b3..881ff421 100644 --- a/src/tool/api/api_scan_vs_plugin/src/gen/tools/VsPluginTool.js +++ b/src/tool/api/api_scan_vs_plugin/src/gen/tools/VsPluginTool.js @@ -65,12 +65,13 @@ function checkFileError(ifname) { } function utf8ArrayToStr(array) { - let out, i, len, c; - let char2, char3; + let c = 0; + let char2 = 0; + let char3 = 0; - out = ''; - len = array.length; - i = 0; + let out = ''; + let len = array.length; + let i = 0; while (i < len) { c = array[i++]; switch (c >> 4) { diff --git a/src/vscode_plugin/docs/ohCrossCompile.md b/src/vscode_plugin/docs/ohCrossCompile.md index 9bbd9cb0..6c5565c8 100644 --- a/src/vscode_plugin/docs/ohCrossCompile.md +++ b/src/vscode_plugin/docs/ohCrossCompile.md @@ -14,21 +14,21 @@ OpenHarmony 交叉编译功能使开发者能够简单快速地调用 OpenHarmon ------ -若在 Windows 10 系统下使用本功能,则还需首先准备编译环境。本功能依赖于 mingw-w64 项目中 w64devkit 包所提供的 GCC 编译器来执行 make 操作,需下载并安装 w64devkit 工具: +若在 Windows 10 系统下使用本功能,则还需首先准备编译环境。本功能依赖于 ming&w-w64 项目中 w64devkit 包所提供的 GCC 编译器来执行 make 操作,需下载并安装 w64devkit 工具: 1. 下载 w64devkit 包。在链接 [Releases · skeeto/w64devkit](https://github.com/skeeto/w64devkit/releases) 中选择合适版本并下载; 2. 安装 w64devkit 至合适路径,并将其安装目录下的 bin 目录加入系统环境变量 Path 中; -3. 在 cmd 中执行命令`mingw32-make -v`以验证安装状态。若有如下输出则证明安装成功: +3. 在 cmd 中执行命令`ming&w32-make -v`以验证安装状态。若有如下输出则证明安装成功: ```cmd Microsoft Windows [版本 10.0.19045.5247] (c) Microsoft Corporation。保留所有权利。 - C:\Users\Administrator>mingw32-make -v + C:\Users\Administrator>ming&w32-make -v GNU Make 4.4.1 - Built for x86_64-w64-mingw32 + Built for x86_64-w64-ming&w32 Copyright (C) 1988-2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. @@ -112,7 +112,7 @@ OpenHarmony 交叉编译功能使开发者能够简单快速地调用 OpenHarmon { "command": "D:/Public_sdk/11/ohos-sdk/windows/native/build-tools/cmake/bin/cmake.exe", "arguments": [ - "-G \"MinGW Makefiles\"", + "-G \"ming&w Makefiles\"", "-DCMAKE_SH=\"CMAKE_SH-NOTFOUND\"", "-DCMAKE_TOOLCHAIN_FILE=D:/Public_sdk/11/ohos-sdk/windows/native/build/cmake/ohos.toolchain.cmake", "-DCMAKE_INSTALL_PREFIX=d:/TestWork/VariousTests/cJSON/ohCrossCompile/arm64-v8a/installed", @@ -122,11 +122,11 @@ OpenHarmony 交叉编译功能使开发者能够简单快速地调用 OpenHarmon ] }, { - "command": "mingw32-make", + "command": "ming&w32-make", "arguments": [] }, { - "command": "mingw32-make install", + "command": "ming&w32-make install", "arguments": [] } ] @@ -146,7 +146,7 @@ OpenHarmony 交叉编译功能使开发者能够简单快速地调用 OpenHarmon { "command": "D:/Public_sdk/11/ohos-sdk/windows/native/build-tools/cmake/bin/cmake.exe", "arguments": [ - "-G \"MinGW Makefiles\"", + "-G \"ming&w Makefiles\"", "-DCMAKE_SH=\"CMAKE_SH-NOTFOUND\"", "-DCMAKE_TOOLCHAIN_FILE=D:/Public_sdk/11/ohos-sdk/windows/native/build/cmake/ohos.toolchain.cmake", "-DCMAKE_INSTALL_PREFIX=d:/TestWork/VariousTests/cJSON/ohCrossCompile/armeabi-v7a/installed", @@ -156,11 +156,11 @@ OpenHarmony 交叉编译功能使开发者能够简单快速地调用 OpenHarmon ] }, { - "command": "mingw32-make", + "command": "ming&w32-make", "arguments": [] }, { - "command": "mingw32-make install", + "command": "ming&w32-make install", "arguments": [] } ] -- Gitee