From b4bf557731910c687c714c021eb644eed4318b20 Mon Sep 17 00:00:00 2001 From: Sander Verweij Date: Sat, 20 Jul 2024 16:56:16 +0200 Subject: [PATCH] fix: applies suggestions from code review --- src/config-utl/extract-depcruise-config/merge-configs.mjs | 1 - src/enrich/summarize/summarize-modules.mjs | 1 - src/main/rule-set/assert-validity.mjs | 5 ++--- src/report/dot/index.mjs | 4 ++-- src/report/dot/theming.mjs | 7 +++---- test/cli/index.spec.mjs | 1 - 6 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/config-utl/extract-depcruise-config/merge-configs.mjs b/src/config-utl/extract-depcruise-config/merge-configs.mjs index 6ed06001c..673e1590e 100644 --- a/src/config-utl/extract-depcruise-config/merge-configs.mjs +++ b/src/config-utl/extract-depcruise-config/merge-configs.mjs @@ -1,5 +1,4 @@ import { isDeepStrictEqual } from "node:util"; - import { uniqBy, uniqWith } from "#utl/array-util.mjs"; function extendNamedRule(pExtendedRule, pForbiddenArrayBase) { diff --git a/src/enrich/summarize/summarize-modules.mjs b/src/enrich/summarize/summarize-modules.mjs index d93a6acf7..0f2ef18d9 100644 --- a/src/enrich/summarize/summarize-modules.mjs +++ b/src/enrich/summarize/summarize-modules.mjs @@ -1,7 +1,6 @@ import isSameViolation from "./is-same-violation.mjs"; import { findRuleByName } from "#graph-utl/rule-set.mjs"; import compare from "#graph-utl/compare.mjs"; - import { uniqWith } from "#utl/array-util.mjs"; function cutNonTransgressions(pModule) { diff --git a/src/main/rule-set/assert-validity.mjs b/src/main/rule-set/assert-validity.mjs index ebca7f719..af17da0e2 100644 --- a/src/main/rule-set/assert-validity.mjs +++ b/src/main/rule-set/assert-validity.mjs @@ -3,7 +3,6 @@ import safeRegex from "safe-regex"; import { assertCruiseOptionsValid } from "../options/assert-validity.mjs"; import { normalizeToREAsString } from "../helpers.mjs"; import configurationSchema from "#configuration-schema"; - import { has, get } from "#utl/object-util.mjs"; const ajv = new Ajv(); @@ -29,8 +28,8 @@ function assertSchemaCompliance(pSchema, pConfiguration) { } function hasPath(pObject, pSection, pCondition) { - // pCondition can be nested properties, so we use _.has instead - // of elvis operators + // pCondition can be nested properties, so we use a bespoke + // 'has' function instead of simple elvis operators return has(pObject, pSection) && has(pObject[pSection], pCondition); } diff --git a/src/report/dot/index.mjs b/src/report/dot/index.mjs index 0868ebd09..dbd4fd66a 100644 --- a/src/report/dot/index.mjs +++ b/src/report/dot/index.mjs @@ -151,8 +151,8 @@ function pryReporterOptionsFromResults(pGranularity, pResults) { const lFallbackReporterOptions = pResults?.summary?.optionsUsed?.reporterOptions?.dot; - // using _.get here because the reporter options will contain nested - // properties, which it handles for us + // using a bespoke 'get' function here because the reporter options will + // contain nested properties, which it handles for us return get( pResults, GRANULARITY2REPORTER_OPTIONS.get(pGranularity), diff --git a/src/report/dot/theming.mjs b/src/report/dot/theming.mjs index a9369effc..8649d5318 100644 --- a/src/report/dot/theming.mjs +++ b/src/report/dot/theming.mjs @@ -17,10 +17,9 @@ function moduleOrDependencyMatchesCriteria(pSchemeEntry, pModule) { // To get the criterion treat that key as a string and not as a path // eslint-disable-next-line security/detect-object-injection const lCriterion = pSchemeEntry.criteria[pKey]; - // we use _.get here because in the criteria you can enter - // nested keys like "rules[0].severity" : "error", and _.get handles - // that for us - // console.error(pSchemeEntry.criteria, pKey, pc.bold(lCriterion)); + // we use a bespoke 'get' here because in the criteria you can enter + // nested keys like "rules[0].severity" : "error", and that function + // handles those for us const lModuleKey = get(pModule, pKey); if (!(lModuleKey || has(pModule, pKey))) { diff --git a/test/cli/index.spec.mjs b/test/cli/index.spec.mjs index 6a3c7918b..431c5ca65 100644 --- a/test/cli/index.spec.mjs +++ b/test/cli/index.spec.mjs @@ -203,7 +203,6 @@ function setModuleType(pTestPairs, pModuleType) { function runFileBasedTests(pModuleType) { setModuleType(TEST_PAIRS, pModuleType).forEach((pPair) => { - // if (pPair.description === "regular dot with default theme") it(pPair.description, async () => { const lExitCode = await cli([pPair.dirOrFile], pPair.options);