From f77ee59fbb19d9a37e927cb08ae0e8c1a5419dc5 Mon Sep 17 00:00:00 2001 From: Teodora Sandu Date: Mon, 4 Jul 2022 14:55:46 +0100 Subject: [PATCH] chore: cleanup iac custom rules analytics --- .../test/iac/local-execution/analytics.ts | 5 -- .../test/iac/local-execution/math-utils.ts | 10 ---- test/jest/unit/iac/math-utils.spec.ts | 50 ------------------- 3 files changed, 65 deletions(-) delete mode 100644 src/cli/commands/test/iac/local-execution/math-utils.ts delete mode 100644 test/jest/unit/iac/math-utils.spec.ts diff --git a/src/cli/commands/test/iac/local-execution/analytics.ts b/src/cli/commands/test/iac/local-execution/analytics.ts index 3d81cb2076..6a1f7642a0 100644 --- a/src/cli/commands/test/iac/local-execution/analytics.ts +++ b/src/cli/commands/test/iac/local-execution/analytics.ts @@ -1,6 +1,5 @@ import { FormattedResult, PerformanceAnalyticsKey, RulesOrigin } from './types'; import * as analytics from '../../../../../lib/analytics'; -import { calculatePercentage } from './math-utils'; import { computeCustomRulesBundleChecksum } from './file-utils'; import { DescribeOptions, DriftAnalysis } from '../../../../../lib/iac/types'; import { driftctlVersion } from '../../../../../lib/iac/drift/driftctl'; @@ -60,10 +59,6 @@ export function addIacAnalytics( opts.rulesOrigin === RulesOrigin.Remote, ); analytics.add('iac-custom-rules-issues-count', issuesFromCustomRulesCount); - analytics.add( - 'iac-custom-rules-issues-percentage', - calculatePercentage(issuesFromCustomRulesCount, totalIssuesCount), - ); analytics.add( 'iac-custom-rules-checksum', computeCustomRulesBundleChecksum(), diff --git a/src/cli/commands/test/iac/local-execution/math-utils.ts b/src/cli/commands/test/iac/local-execution/math-utils.ts deleted file mode 100644 index 0e3d271bd6..0000000000 --- a/src/cli/commands/test/iac/local-execution/math-utils.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Calculate percentage from relative and total amounts. - * @param relativeValue The relative amount. - * @param totalValue The total amount. - * @returns The calculated precentage. - */ -export const calculatePercentage = ( - relativeValue: number, - totalValue: number, -): number => +(totalValue ? (relativeValue / totalValue) * 100 : 0).toFixed(2); diff --git a/test/jest/unit/iac/math-utils.spec.ts b/test/jest/unit/iac/math-utils.spec.ts deleted file mode 100644 index 5d6f40a632..0000000000 --- a/test/jest/unit/iac/math-utils.spec.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { calculatePercentage } from '../../../../src/cli/commands/test/iac/local-execution/math-utils'; - -describe('Math Utils', function() { - describe('calculatePercentage', function() { - it('correctly calculates that 5 is 50% of 10', function() { - const [relativeValue, totalValue] = [5, 10]; - const expectedResult = 50; - - const result = calculatePercentage(relativeValue, totalValue); - - expect(result).toBe(expectedResult); - }); - - it('correctly calculates that 1 is 4.35% of 23', function() { - const [relativeValue, totalValue] = [1, 23]; - const expectedResult = 4.35; - - const result = calculatePercentage(relativeValue, totalValue); - - expect(result).toBe(expectedResult); - }); - - it('correctly calculates that 45 is 300% of 15', function() { - const [relativeValue, totalValue] = [45, 15]; - const expectedResult = 300; - - const result = calculatePercentage(relativeValue, totalValue); - - expect(result).toBe(expectedResult); - }); - - it('returns that 0 is 0% of 1000', function() { - const [relativeValue, totalValue] = [0, 1000]; - const expectedResult = 0; - - const result = calculatePercentage(relativeValue, totalValue); - - expect(result).toBe(expectedResult); - }); - - it('returns 0% when the total value is 0', function() { - const [relativeValue, totalValue] = [1000, 0]; - const expectedResult = 0; - - const result = calculatePercentage(relativeValue, totalValue); - - expect(result).toBe(expectedResult); - }); - }); -});