From 02384310ce397e894103e8f0154e5b36109a3200 Mon Sep 17 00:00:00 2001 From: Azlam <43767972+azlam-abdulsalam@users.noreply.github.com> Date: Sat, 2 Mar 2024 13:53:30 +1100 Subject: [PATCH] refactor(sfp): remove usage of var [CodeFactor] Apply fixes Co-authored-by: codefactor-io --- packages/sfp-cli/src/core/artifacts/ArtifactFetcher.ts | 8 ++++---- packages/sfp-cli/src/core/metadata/MetadataFiles.ts | 2 +- .../core/package/generators/SfpPackageContentGenerator.ts | 8 ++++---- .../packageFormatConvertors/SourceToMDAPIConvertor.ts | 8 ++++---- .../src/core/package/packageMerger/PackageMergeManager.ts | 8 ++++---- packages/sfp-cli/src/core/utils/Fileutils.ts | 8 ++++---- .../sfp-cli/src/impl/changelog/ReleaseChangelogUpdater.ts | 2 +- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/sfp-cli/src/core/artifacts/ArtifactFetcher.ts b/packages/sfp-cli/src/core/artifacts/ArtifactFetcher.ts index 292998355..a75a6035f 100644 --- a/packages/sfp-cli/src/core/artifacts/ArtifactFetcher.ts +++ b/packages/sfp-cli/src/core/artifacts/ArtifactFetcher.ts @@ -207,10 +207,10 @@ export default class ArtifactFetcher { } private static makefolderid(length): string { - var result = ''; - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var charactersLength = characters.length; - for (var i = 0; i < length; i++) { + let result = ''; + let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + let charactersLength = characters.length; + for (let i = 0; i < length; i++) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; diff --git a/packages/sfp-cli/src/core/metadata/MetadataFiles.ts b/packages/sfp-cli/src/core/metadata/MetadataFiles.ts index cffbea0d6..88e715bea 100644 --- a/packages/sfp-cli/src/core/metadata/MetadataFiles.ts +++ b/packages/sfp-cli/src/core/metadata/MetadataFiles.ts @@ -114,7 +114,7 @@ export default class MetadataFiles { } public loadComponents(srcFolder: string, checkIgnore = true): void { - var metadataFiles: string[] = FileUtils.getAllFilesSync(srcFolder); + let metadataFiles: string[] = FileUtils.getAllFilesSync(srcFolder); let keys = Object.keys(METADATA_INFO); if (Array.isArray(metadataFiles) && metadataFiles.length > 0) { metadataFiles.forEach((metadataFile) => { diff --git a/packages/sfp-cli/src/core/package/generators/SfpPackageContentGenerator.ts b/packages/sfp-cli/src/core/package/generators/SfpPackageContentGenerator.ts index 2ee30b326..5c8866bc6 100644 --- a/packages/sfp-cli/src/core/package/generators/SfpPackageContentGenerator.ts +++ b/packages/sfp-cli/src/core/package/generators/SfpPackageContentGenerator.ts @@ -290,10 +290,10 @@ export default class SfpPackageContentGenerator { } private static makefolderid(length): string { - var result = ''; - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var charactersLength = characters.length; - for (var i = 0; i < length; i++) { + let result = ''; + let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + let charactersLength = characters.length; + for (let i = 0; i < length; i++) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; diff --git a/packages/sfp-cli/src/core/package/packageFormatConvertors/SourceToMDAPIConvertor.ts b/packages/sfp-cli/src/core/package/packageFormatConvertors/SourceToMDAPIConvertor.ts index 102fc7161..2ea148361 100644 --- a/packages/sfp-cli/src/core/package/packageFormatConvertors/SourceToMDAPIConvertor.ts +++ b/packages/sfp-cli/src/core/package/packageFormatConvertors/SourceToMDAPIConvertor.ts @@ -40,11 +40,11 @@ export default class SourceToMDAPIConvertor { } private makefolderid(length): string { - var result = ''; - var characters = + let result = ''; + let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var charactersLength = characters.length; - for (var i = 0; i < length; i++) { + let charactersLength = characters.length; + for (let i = 0; i < length; i++) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; diff --git a/packages/sfp-cli/src/core/package/packageMerger/PackageMergeManager.ts b/packages/sfp-cli/src/core/package/packageMerger/PackageMergeManager.ts index a8cb955e9..fafb3db19 100644 --- a/packages/sfp-cli/src/core/package/packageMerger/PackageMergeManager.ts +++ b/packages/sfp-cli/src/core/package/packageMerger/PackageMergeManager.ts @@ -139,11 +139,11 @@ export default class PackageMergeManager { } private makefolderid(length): string { - var result = ''; - var characters = + let result = ''; + let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var charactersLength = characters.length; - for (var i = 0; i < length; i++) { + let charactersLength = characters.length; + for (let i = 0; i < length; i++) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; diff --git a/packages/sfp-cli/src/core/utils/Fileutils.ts b/packages/sfp-cli/src/core/utils/Fileutils.ts index b121332b0..7b4f29845 100644 --- a/packages/sfp-cli/src/core/utils/Fileutils.ts +++ b/packages/sfp-cli/src/core/utils/Fileutils.ts @@ -193,10 +193,10 @@ export default class FileUtils { } } public static makefolderid(length): string { - var result = ''; - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var charactersLength = characters.length; - for (var i = 0; i < length; i++) { + let result = ''; + let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + let charactersLength = characters.length; + for (let i = 0; i < length; i++) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; diff --git a/packages/sfp-cli/src/impl/changelog/ReleaseChangelogUpdater.ts b/packages/sfp-cli/src/impl/changelog/ReleaseChangelogUpdater.ts index 2e2505f8b..77ab236ee 100644 --- a/packages/sfp-cli/src/impl/changelog/ReleaseChangelogUpdater.ts +++ b/packages/sfp-cli/src/impl/changelog/ReleaseChangelogUpdater.ts @@ -5,7 +5,7 @@ import OrgsUpdater from './OrgsUpdater'; import ReadPackageChangelog from './ReadPackageChangelog'; import * as fs from 'fs-extra'; import SfpPackage from '../../core/package/SfpPackage'; -var hash = require('object-hash'); +let hash = require('object-hash'); export default class ReleaseChangelogUpdater { constructor(