From f795096676f08901b798b644c23f80e2c65efaef Mon Sep 17 00:00:00 2001 From: Roman Semenov Date: Fri, 18 Oct 2024 02:01:44 +0400 Subject: [PATCH] Fix remaining CodeQL reports (#28142) --- apps/demos/utils/interactive/link-repos.js | 38 ---------------- apps/demos/utils/interactive/repos-helper.js | 43 ------------------- .../src/version-utils.ts | 8 +++- .../testing/helpers/vectormaputils-tester.js | 8 ++-- 4 files changed, 11 insertions(+), 86 deletions(-) delete mode 100644 apps/demos/utils/interactive/link-repos.js delete mode 100644 apps/demos/utils/interactive/repos-helper.js diff --git a/apps/demos/utils/interactive/link-repos.js b/apps/demos/utils/interactive/link-repos.js deleted file mode 100644 index 694dada42ac2..000000000000 --- a/apps/demos/utils/interactive/link-repos.js +++ /dev/null @@ -1,38 +0,0 @@ -/* eslint-disable no-console */ -const path = require('path'); -const promptsQuestions = require('./prompts-questions'); -const repositoriesHelper = require('./repos-helper'); - -const nodeModulesDir = path.join(__dirname, '..', '..', 'node_modules'); - -const mainRoutine = async () => { - const response = await promptsQuestions.askLinkRepositories(); - const repositories = []; - await repositoriesHelper.processRepositoriesAsync( - response.repositories, - async (repositoryName) => { - const repositoryPath = await repositoriesHelper.getRepositoryPath(repositoryName); - repositories.push({ name: repositoryName, path: repositoryPath }); - }, - ); - repositories.forEach((repository) => { - console.log(`Processing the \`${repository.name}\` repository...`); - - if (repository.name === 'devextreme' && response.build) { - // eslint-disable-next-line no-param-reassign - repository.path = path.join(repository.path, 'artifacts', 'npm', response.build); - } - - repositoriesHelper.processRepository( - response.command, - repository.name, - repository.path, - nodeModulesDir, - ); - console.log(`Processed: ${repository.path}`); - }); - console.log(`Finished ${response.command}ing repositories...`); -}; - -// eslint-disable-next-line no-return-await -(async () => await mainRoutine())(); diff --git a/apps/demos/utils/interactive/repos-helper.js b/apps/demos/utils/interactive/repos-helper.js deleted file mode 100644 index b20cdc81de91..000000000000 --- a/apps/demos/utils/interactive/repos-helper.js +++ /dev/null @@ -1,43 +0,0 @@ -/* eslint-disable no-console */ -const fs = require('fs'); -const { systemSync } = require('../shared/child-process-utils'); -const promptsQuestions = require('./prompts-questions'); -const { updateConfig, init } = require('../shared/config-helper'); - -const processRepositoriesAsync = async (repositories, callback) => { - // eslint-disable-next-line no-return-await - repositories.forEach(async (repository) => await callback(repository)); -}; - -const processRepository = (command, repositoryName, repositoryPath, nodeModulesDir) => { - if (!fs.existsSync(repositoryPath)) { - console.error(`Directory '${repositoryPath}' does not exist. Please make sure you built the '${repositoryName}' repository.`); - return; - } - if (command === 'unlink') { - systemSync(`cd ${nodeModulesDir} && npm unlink --no-save ${repositoryName}`); - systemSync(`cd ${repositoryPath} && npm unlink `); - } else { - systemSync(`cd ${nodeModulesDir} && npm link ${repositoryPath}`); - } -}; - -const getRepositoryPathByName = async (repositoryName) => { - const config = init(); - let repositoryPath = config[repositoryName].trim(); - if (!repositoryPath) { - const response = await promptsQuestions.askRepositoryPath(repositoryName); - // eslint-disable-next-line no-multi-assign - repositoryPath = config[repositoryName] = response.path; - updateConfig(config); - } - return repositoryPath; -}; - -const getRepositoryPath = async (repositoryName) => getRepositoryPathByName(repositoryName); - -module.exports = { - getRepositoryPath, - processRepositoriesAsync, - processRepository, -}; diff --git a/packages/devextreme-monorepo-tools/src/version-utils.ts b/packages/devextreme-monorepo-tools/src/version-utils.ts index ce6861413919..c1a24ab9c291 100644 --- a/packages/devextreme-monorepo-tools/src/version-utils.ts +++ b/packages/devextreme-monorepo-tools/src/version-utils.ts @@ -7,11 +7,15 @@ export function validateVersion(version: string | undefined): string { } export function formatVersion(version: string | undefined): string | undefined { - if (version?.length && version.length > 1000) { + if (version === undefined) { + return undefined; + } + + if (version.length > 1000) { throw new Error("version string is too long"); } - return version?.match(/(\d+\.\d+\.\d+)(\D|$)/)?.[1]; + return version.match(/(\d+\.\d+\.\d+)(\D|$)/)?.[1]; } const MSECS_IN_MIN = 1000 * 60; diff --git a/packages/devextreme/testing/helpers/vectormaputils-tester.js b/packages/devextreme/testing/helpers/vectormaputils-tester.js index 210b1d845db1..da90e9c094fe 100644 --- a/packages/devextreme/testing/helpers/vectormaputils-tester.js +++ b/packages/devextreme/testing/helpers/vectormaputils-tester.js @@ -65,10 +65,12 @@ function getRequestInfo(url) { require('http').createServer(function(request, response) { const info = getRequestInfo(request.url); - const action = actions[info.action]; response.writeHead(200, { 'Content-Type': 'text/plain' }); - if(action && typeof action === 'function') { - action(info.arg, callback); + if(Object.hasOwn(actions, info.action)) { + const action = actions[info.action]; + if(typeof action === 'function') { + action(info.arg, callback); + } } function callback(data) { response.end(JSON.stringify(data));