From 4219e88c8bd207b16681e74ea7430ade85df31f4 Mon Sep 17 00:00:00 2001 From: Kyle Capehart Date: Tue, 26 Nov 2024 04:00:11 -0500 Subject: [PATCH] check git history for .cls files instead of .cls-meta.xml (#903) * check git history for .cls files instead of .cls-meta.xml * Look first for not-xml file, then for xml file * changelog --------- Co-authored-by: Nicolas Vuillamy --- CHANGELOG.md | 4 ++++ src/common/metadata-utils/index.ts | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01da14a85..f4711854e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ Note: Can be used with `sfdx plugins:install sfdx-hardis@beta` and docker image `hardisgroupcom/sfdx-hardis@beta` +## [5.8.1] 2024-11-26 + +- Fix [hardis:org:diagnose:unused-apex-classes](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unused-apex-classes/): Use .cls file, not cls-meta.xml file to get creation date from git + ## [5.8.0] 2024-11-25 - New monitoring command [hardis:org:diagnose:unused-connected-apps](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unused-connected-apps/) to detect Connected Apps that are not used anymore and might be disabled or deleted. diff --git a/src/common/metadata-utils/index.ts b/src/common/metadata-utils/index.ts index 2dc80d249..1e3edef6d 100644 --- a/src/common/metadata-utils/index.ts +++ b/src/common/metadata-utils/index.ts @@ -437,14 +437,19 @@ Issue tracking: https://github.com/forcedotcom/cli/issues/2426`) const metadataType = metadataTypes[0]; // Look for matching file in sources - const globExpression = `**/${metadataType.directoryName}/**/${packageXmlName}.${metadataType.suffix || ""}-meta.xml`; + const globExpressions = [ + `**/${metadataType.directoryName}/**/${packageXmlName}.${metadataType.suffix || ""}`, // Works for not-xml files + `**/${metadataType.directoryName}/**/${packageXmlName}.${metadataType.suffix || ""}-meta.xml` // Works for all XML files + ] for (const packageDirectory of packageDirectories) { - const sourceFiles = await glob(globExpression, { - cwd: packageDirectory.fullPath, - }); - if (sourceFiles.length > 0) { - const metaFile = path.join(packageDirectory.path, sourceFiles[0]); - return metaFile; + for (const globExpression of globExpressions) { + const sourceFiles = await glob(globExpression, { + cwd: packageDirectory.fullPath, + }); + if (sourceFiles.length > 0) { + const metaFile = path.join(packageDirectory.path, sourceFiles[0]); + return metaFile; + } } } return null;