!507 Fix var is used instead of let or const inspection

Merge pull request !507 from butter/master
This commit is contained in:
openharmony_ci 2022-11-28 02:27:21 +00:00 committed by Gitee
commit a6bffde2ff
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 43 additions and 42 deletions

View File

@ -48,7 +48,7 @@ function registerDeviceListCallback() {
if (numDevices === 0) { if (numDevices === 0) {
if (discoveredDevices > 0) { if (discoveredDevices > 0) {
prompt.showToast({ prompt.showToast({
message: "registerDeviceListCallback dicovered " + discoveredDevices + " devices, need to authenticate" message: "registerDeviceListCallback discovered " + discoveredDevices + " devices, need to authenticate"
}); });
} else { } else {
prompt.showToast({ prompt.showToast({

View File

@ -18,10 +18,10 @@ import RemoteDeviceModel from '../../../model/RemoteDeviceModel.js';
import rpc from "@ohos.rpc"; import rpc from "@ohos.rpc";
import prompt from '@system.prompt'; import prompt from '@system.prompt';
var mRemote; let mRemote;
var DEVICE_LIST_LOCALHOST; let DEVICE_LIST_LOCALHOST;
var connectedAbility; let connectedAbility;
var localDeviceId = ""; const localDeviceId = "";
export default { export default {
data: { data: {
@ -43,16 +43,16 @@ export default {
let self = this; let self = this;
this.remoteDeviceModel.registerDeviceListCallback(() => { this.remoteDeviceModel.registerDeviceListCallback(() => {
console.info('registerDeviceListCallback, callback entered'); console.info('registerDeviceListCallback, callback entered');
var list = []; const list = [];
list[0] = DEVICE_LIST_LOCALHOST; list[0] = DEVICE_LIST_LOCALHOST;
var deviceList; let deviceList;
if (self.remoteDeviceModel.discoverList.length > 0) { if (self.remoteDeviceModel.discoverList.length > 0) {
deviceList = self.remoteDeviceModel.discoverList; deviceList = self.remoteDeviceModel.discoverList;
} else { } else {
deviceList = self.remoteDeviceModel.deviceList; deviceList = self.remoteDeviceModel.deviceList;
} }
console.info('on remote device updated, count=' + deviceList.length); console.info('on remote device updated, count=' + deviceList.length);
for (var i = 0; i < deviceList.length; i++) { for (let i = 0; i < deviceList.length; i++) {
console.info('device ' + i + '/' + deviceList.length + ' deviceId=' console.info('device ' + i + '/' + deviceList.length + ' deviceId='
+ deviceList[i].deviceId + ' deviceName=' + deviceList[i].deviceName + ' deviceType=' + deviceList[i].deviceId + ' deviceName=' + deviceList[i].deviceName + ' deviceType='
+ deviceList[i].deviceType); + deviceList[i].deviceType);
@ -74,7 +74,7 @@ export default {
onStartLocalAbilityClick() { onStartLocalAbilityClick() {
console.info('[dmsDemo] onStartLocalAbilityClick begin'); console.info('[dmsDemo] onStartLocalAbilityClick begin');
console.info('[dmsDemo] onStartLocalAbilityClick deviceId is ' + localDeviceId); console.info('[dmsDemo] onStartLocalAbilityClick deviceId is ' + localDeviceId);
var wantValue = { const wantValue = {
bundleName: 'ohos.dms.jsDemo', bundleName: 'ohos.dms.jsDemo',
abilityName: 'ohos.dms.jsDemo.LocalAbility', abilityName: 'ohos.dms.jsDemo.LocalAbility',
deviceId: localDeviceId, deviceId: localDeviceId,
@ -103,8 +103,8 @@ export default {
} }
if (this.remoteDeviceModel.discoverList.length > 0) { if (this.remoteDeviceModel.discoverList.length > 0) {
console.info('[dmsDemo] start to device'); console.info('[dmsDemo] start to device');
var name = null; let name = null;
for (var i = 0; i < this.remoteDeviceModel.discoverList.length; i++) { for (let i = 0; i < this.remoteDeviceModel.discoverList.length; i++) {
if (this.remoteDeviceModel.discoverList[i].deviceId === e.value) { if (this.remoteDeviceModel.discoverList[i].deviceId === e.value) {
name = this.remoteDeviceModel.discoverList[i].deviceName; name = this.remoteDeviceModel.discoverList[i].deviceName;
break; break;
@ -119,7 +119,7 @@ export default {
let self = this; let self = this;
this.remoteDeviceModel.authDevice(e.value, () => { this.remoteDeviceModel.authDevice(e.value, () => {
console.info('[dmsDemo] onRadioChangeForStart auth and online finished'); console.info('[dmsDemo] onRadioChangeForStart auth and online finished');
for (i = 0; i < self.remoteDeviceModel.deviceList.length; i++) { for (let i = 0; i < self.remoteDeviceModel.deviceList.length; i++) {
if (self.remoteDeviceModel.deviceList[i].deviceName === name) { if (self.remoteDeviceModel.deviceList[i].deviceName === name) {
this.startRemoteAbility(self.remoteDeviceModel.deviceList[i].deviceId, this.startRemoteAbility(self.remoteDeviceModel.deviceList[i].deviceId,
self.remoteDeviceModel.deviceList[i].deviceName); self.remoteDeviceModel.deviceList[i].deviceName);
@ -128,7 +128,7 @@ export default {
}); });
} else { } else {
console.info('[dmsDemo] onRadioChangeForStart start to authed device'); console.info('[dmsDemo] onRadioChangeForStart start to authed device');
for (i = 0; i < this.remoteDeviceModel.deviceList.length; i++) { for (let i = 0; i < this.remoteDeviceModel.deviceList.length; i++) {
if (this.remoteDeviceModel.deviceList[i].deviceId === e.value) { if (this.remoteDeviceModel.deviceList[i].deviceId === e.value) {
this.startRemoteAbility(this.remoteDeviceModel.deviceList[i].deviceId, this.startRemoteAbility(this.remoteDeviceModel.deviceList[i].deviceId,
this.remoteDeviceModel.deviceList[i].deviceName); this.remoteDeviceModel.deviceList[i].deviceName);
@ -140,10 +140,10 @@ export default {
startRemoteAbility(deviceId, deviceName) { startRemoteAbility(deviceId, deviceName) {
this.$element('dialogForStartAbility').close(); this.$element('dialogForStartAbility').close();
var params; let params;
console.info('[dmsDemo] featureAbility.startAbility deviceId=' + deviceId console.info('[dmsDemo] featureAbility.startAbility deviceId=' + deviceId
+ ' deviceName=' + deviceName); + ' deviceName=' + deviceName);
var wantValue = { const wantValue = {
bundleName: 'ohos.dms.jsDemo', bundleName: 'ohos.dms.jsDemo',
abilityName: 'ohos.dms.jsDemo.RemoteAbility', abilityName: 'ohos.dms.jsDemo.RemoteAbility',
deviceId: deviceId, deviceId: deviceId,
@ -190,8 +190,8 @@ export default {
} }
if (this.remoteDeviceModel.discoverList.length > 0) { if (this.remoteDeviceModel.discoverList.length > 0) {
console.info('[dmsDemo] onRadioChangeForContinue to device'); console.info('[dmsDemo] onRadioChangeForContinue to device');
var name = null; let name = null;
for (var i = 0; i < this.remoteDeviceModel.discoverList.length; i++) { for (let i = 0; i < this.remoteDeviceModel.discoverList.length; i++) {
if (this.remoteDeviceModel.discoverList[i].deviceId === e.value) { if (this.remoteDeviceModel.discoverList[i].deviceId === e.value) {
name = this.remoteDeviceModel.discoverList[i].deviceName; name = this.remoteDeviceModel.discoverList[i].deviceName;
break; break;
@ -308,8 +308,8 @@ export default {
} }
if (this.remoteDeviceModel.discoverList.length > 0) { if (this.remoteDeviceModel.discoverList.length > 0) {
console.info('[dmsDemo] onRadioChangeForConnect to device'); console.info('[dmsDemo] onRadioChangeForConnect to device');
var name = null; let name = null;
for (var i = 0; i < this.remoteDeviceModel.discoverList.length; i++) { for (let i = 0; i < this.remoteDeviceModel.discoverList.length; i++) {
if (this.remoteDeviceModel.discoverList[i].deviceId === e.value) { if (this.remoteDeviceModel.discoverList[i].deviceId === e.value) {
name = this.remoteDeviceModel.discoverList[i].deviceName; name = this.remoteDeviceModel.discoverList[i].deviceName;
break; break;

View File

@ -15,7 +15,7 @@
import deviceManager from '@ohos.distributedHardware.deviceManager'; import deviceManager from '@ohos.distributedHardware.deviceManager';
var SUBSCRIBE_ID = 100; let SUBSCRIBE_ID = 100;
export default class RemoteDeviceModel { export default class RemoteDeviceModel {
deviceList = []; deviceList = [];
@ -49,14 +49,14 @@ export default class RemoteDeviceModel {
registerDeviceListCallback_(callback) { registerDeviceListCallback_(callback) {
console.info('[dmsDemo] registerDeviceListCallback'); console.info('[dmsDemo] registerDeviceListCallback');
this.callback = callback; this.callback = callback;
if (this.#deviceManager == undefined) { if (this.#deviceManager === undefined) {
console.error('[dmsDemo] deviceManager has not initialized'); console.error('[dmsDemo] deviceManager has not initialized');
this.callback(); this.callback();
return; return;
} }
console.info('[dmsDemo] getTrustedDeviceListSync begin'); console.info('[dmsDemo] getTrustedDeviceListSync begin');
var list = this.#deviceManager.getTrustedDeviceListSync(); const list = this.#deviceManager.getTrustedDeviceListSync();
console.info('[dmsDemo] getTrustedDeviceListSync end, deviceList=' + JSON.stringify(list)); console.info('[dmsDemo] getTrustedDeviceListSync end, deviceList=' + JSON.stringify(list));
if (typeof (list) != 'undefined' && typeof (list.length) != 'undefined') { if (typeof (list) != 'undefined' && typeof (list.length) != 'undefined') {
this.deviceList = list; this.deviceList = list;
@ -70,7 +70,7 @@ export default class RemoteDeviceModel {
registerServiceDieCallback(); registerServiceDieCallback();
SUBSCRIBE_ID = Math.floor(65536 * Math.random()); SUBSCRIBE_ID = Math.floor(65536 * Math.random());
var info = { const info = {
subscribeId: SUBSCRIBE_ID, subscribeId: SUBSCRIBE_ID,
mode: 0xAA, mode: 0xAA,
medium: 2, medium: 2,
@ -99,7 +99,7 @@ export default class RemoteDeviceModel {
break; break;
case 2: case 2:
if (self.deviceList.length > 0) { if (self.deviceList.length > 0) {
for (var i = 0; i < self.deviceList.length; i++) { for (let i = 0; i < self.deviceList.length; i++) {
if (self.deviceList[i].deviceId === data.device.deviceId) { if (self.deviceList[i].deviceId === data.device.deviceId) {
self.deviceList[i] = data.device; self.deviceList[i] = data.device;
break; break;
@ -111,9 +111,9 @@ export default class RemoteDeviceModel {
break; break;
case 1: case 1:
if (self.deviceList.length > 0) { if (self.deviceList.length > 0) {
var list = []; const list = [];
for (var i = 0; i < self.deviceList.length; i++) { for (let i = 0; i < self.deviceList.length; i++) {
if (self.deviceList[i].deviceId != data.device.deviceId) { if (self.deviceList[i].deviceId !== data.device.deviceId) {
list[i] = data.device; list[i] = data.device;
} }
} }
@ -133,7 +133,7 @@ export default class RemoteDeviceModel {
console.info('[dmsDemo] deviceFound data=' + JSON.stringify(data)); console.info('[dmsDemo] deviceFound data=' + JSON.stringify(data));
console.info('[dmsDemo] deviceFound self.deviceList=' + self.deviceList); console.info('[dmsDemo] deviceFound self.deviceList=' + self.deviceList);
console.info('[dmsDemo] deviceFound self.deviceList.length=' + self.deviceList.length); console.info('[dmsDemo] deviceFound self.deviceList.length=' + self.deviceList.length);
for (var i = 0; i < self.discoverList.length; i++) { for (let i = 0; i < self.discoverList.length; i++) {
if (self.discoverList[i].deviceId === data.device.deviceId) { if (self.discoverList[i].deviceId === data.device.deviceId) {
console.info('[dmsDemo] device founded, ignored'); console.info('[dmsDemo] device founded, ignored');
return; return;
@ -158,7 +158,7 @@ export default class RemoteDeviceModel {
authDevice(deviceId, callback) { authDevice(deviceId, callback) {
console.info('[dmsDemo] authDevice ' + deviceId); console.info('[dmsDemo] authDevice ' + deviceId);
for (var i = 0; i < this.discoverList.length; i++) { for (let i = 0; i < this.discoverList.length; i++) {
if (this.discoverList[i].deviceId === deviceId) { if (this.discoverList[i].deviceId === deviceId) {
console.info('[dmsDemo] device founded, ignored'); console.info('[dmsDemo] device founded, ignored');
let extraInfo = { let extraInfo = {

View File

@ -18,12 +18,12 @@ import Ability from '@ohos.application.Ability'
import RemoteDeviceModel from '../Model/RemoteDeviceModel' import RemoteDeviceModel from '../Model/RemoteDeviceModel'
import rpc from '@ohos.rpc' import rpc from '@ohos.rpc'
var printLog = '[MainAbility]' const printLog = '[MainAbility]';
var remoteDeviceModel = new RemoteDeviceModel const remoteDeviceModel = new RemoteDeviceModel;
var messageProxy = null let messageProxy = null;
var connectedAbility let connectedAbility;
var options = { const options = {
onConnect: async function (elementName, proxy) { onConnect: async function (elementName, proxy) {
showLog(printLog + "service extension ability connect success") showLog(printLog + "service extension ability connect success")
if (proxy === null) { if (proxy === null) {
@ -39,7 +39,7 @@ var options = {
onFailed: function () { onFailed: function () {
showLog(printLog + "service extension ability connect fail") showLog(printLog + "service extension ability connect fail")
} }
} };
function ConnectRemoteAbility() { function ConnectRemoteAbility() {
showLog(printLog + "connect service extension ability begin") showLog(printLog + "connect service extension ability begin")
@ -87,7 +87,7 @@ function showLog(logMessage) {
function RegisterDeviceListCallback() { function RegisterDeviceListCallback() {
remoteDeviceModel.registerDeviceListCallback(() => { remoteDeviceModel.registerDeviceListCallback(() => {
let deviceSize = remoteDeviceModel.deviceList.length let deviceSize = remoteDeviceModel.deviceList.length
for (var i = 0; i < deviceSize; i++) { for (let i = 0; i < deviceSize; i++) {
globalThis.DeviceIdList.push(remoteDeviceModel.deviceList[i].deviceId) globalThis.DeviceIdList.push(remoteDeviceModel.deviceList[i].deviceId)
} }
}) })

View File

@ -15,7 +15,7 @@
import deviceManager from '@ohos.distributedHardware.deviceManager'; import deviceManager from '@ohos.distributedHardware.deviceManager';
var SUBSCRIBE_ID = 100; const SUBSCRIBE_ID = 100;
export default class RemoteDeviceModel { export default class RemoteDeviceModel {
deviceList = []; deviceList = [];
@ -56,7 +56,7 @@ export default class RemoteDeviceModel {
} }
console.info('[ServiceExtensionDemo] getTrustedDeviceListSync begin'); console.info('[ServiceExtensionDemo] getTrustedDeviceListSync begin');
var list = this.MyDeviceManager.getTrustedDeviceListSync(); const list = this.MyDeviceManager.getTrustedDeviceListSync();
console.info('[ServiceExtensionDemo] getTrustedDeviceListSync end, deviceList=' + JSON.stringify(list)); console.info('[ServiceExtensionDemo] getTrustedDeviceListSync end, deviceList=' + JSON.stringify(list));
if (typeof (list) != 'undefined' && typeof (list.length) != 'undefined') { if (typeof (list) != 'undefined' && typeof (list.length) != 'undefined') {
this.deviceList = list; this.deviceList = list;
@ -67,7 +67,7 @@ export default class RemoteDeviceModel {
getTrustDeviceList(callback) { getTrustDeviceList(callback) {
console.info('[ServiceExtensionDemo] getTrustDeviceListSync begin'); console.info('[ServiceExtensionDemo] getTrustDeviceListSync begin');
var list = this.MyDeviceManager.getTrustedDeviceListSync(); const list = this.MyDeviceManager.getTrustedDeviceListSync();
console.info('[ServiceExtensionDemo] getTrustedDeviceListSync end, deviceList=' + JSON.stringify(list)); console.info('[ServiceExtensionDemo] getTrustedDeviceListSync end, deviceList=' + JSON.stringify(list));
if (typeof (list) != 'undefined' && typeof (list.length) != 'undefined') { if (typeof (list) != 'undefined' && typeof (list.length) != 'undefined') {
this.deviceList = list; this.deviceList = list;

View File

@ -16,7 +16,8 @@
import rpc from '@ohos.rpc'; import rpc from '@ohos.rpc';
import ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'; import ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility';
var printLog = '[ServiceExtension]'
const printLog = '[ServiceExtension]';
class MyServiceExtensionAbilityStub extends rpc.RemoteObject { class MyServiceExtensionAbilityStub extends rpc.RemoteObject {
constructor(des) { constructor(des) {

View File

@ -162,7 +162,7 @@ struct StartAbility {
}) })
Button() { Button() {
Text('StartAbilityPromiseKSB004跨设备跨应用对端FA的visable为false无法拉起') Text('StartAbilityPromiseKSB004跨设备跨应用对端FA的visible为false无法拉起')
.fontSize($r('app.float.font_20')) .fontSize($r('app.float.font_20'))
.width('100%') .width('100%')
.fontColor(Color.White) .fontColor(Color.White)

View File

@ -26,7 +26,7 @@ const PERMISSION_REJECT = -1
class ContentStorage { class ContentStorage {
} }
var g_object = distributedObject.createDistributedObject({name:undefined}); const g_object = distributedObject.createDistributedObject({name: undefined});
export default class MainAbility extends Ability { export default class MainAbility extends Ability {