From eb1fde0c7807e5a3b54d9246744d4db460a6dccc Mon Sep 17 00:00:00 2001 From: Mamatha1718 Date: Sat, 21 Dec 2024 22:36:07 +0530 Subject: [PATCH 1/2] class-declaration-abstractness-changed --- .../src/comparers/class-declarations.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/concerto-analysis/src/comparers/class-declarations.ts b/packages/concerto-analysis/src/comparers/class-declarations.ts index 9da52b59b..859eee2d7 100644 --- a/packages/concerto-analysis/src/comparers/class-declarations.ts +++ b/packages/concerto-analysis/src/comparers/class-declarations.ts @@ -54,11 +54,17 @@ const classDeclarationTypeChanged: ComparerFactory = (context) => ({ if (aType === bType) { return; } - context.report({ - key: 'class-declaration-type-changed', - message: `The ${aType} "${a.getName()}" changed type from ${aType} to ${bType}`, - element: a - }); + + const isAbstract = (declaration) => declaration.isAbstract(); + if (isAbstract(a) !== isAbstract(b)) { + const changeType = isAbstract(a) ? 'abstract to concrete' : 'concrete to abstract'; + const changeSeverity = isAbstract(a) ? 'minor' : 'major'; + context.report({ + key: 'class-declaration-abstractness-changed', + message: `The class "${a.getName()}" changed from ${changeType} (${changeSeverity} change).`, + element: a + }); + } } }); From b358dd9f5ab7813b615444194efdb3495307d1a4 Mon Sep 17 00:00:00 2001 From: Mamatha1718 Date: Sun, 22 Dec 2024 10:20:24 +0530 Subject: [PATCH 2/2] class-declaration-abstractness-changed with adding rules --- packages/concerto-analysis/src/compare-config.ts | 2 ++ .../src/comparers/class-declarations.ts | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/concerto-analysis/src/compare-config.ts b/packages/concerto-analysis/src/compare-config.ts index 511f660dc..25581c9c5 100644 --- a/packages/concerto-analysis/src/compare-config.ts +++ b/packages/concerto-analysis/src/compare-config.ts @@ -53,6 +53,8 @@ export const defaultCompareConfig: CompareConfig = { 'optional-property-added': CompareResult.PATCH, 'required-property-removed': CompareResult.MAJOR, 'optional-property-removed': CompareResult.MAJOR, + 'class-declaration-abstract-to-concrete': CompareResult.MINOR, + 'class-declaration-concrete-to-abstract': CompareResult.MAJOR, 'namespace-changed': CompareResult.ERROR, 'enum-value-added': CompareResult.PATCH, 'enum-value-removed': CompareResult.MAJOR, diff --git a/packages/concerto-analysis/src/comparers/class-declarations.ts b/packages/concerto-analysis/src/comparers/class-declarations.ts index 859eee2d7..a00190a70 100644 --- a/packages/concerto-analysis/src/comparers/class-declarations.ts +++ b/packages/concerto-analysis/src/comparers/class-declarations.ts @@ -54,14 +54,22 @@ const classDeclarationTypeChanged: ComparerFactory = (context) => ({ if (aType === bType) { return; } - + if(aType !== bType){ + context.report({ + key: `class-declaration-type-changed`, + message: `The ${aType} "${a.getName()}" changed from ${aType} to ${bType}`, + element: a + }); + } + + //add Logic for abstractness changes const isAbstract = (declaration) => declaration.isAbstract(); if (isAbstract(a) !== isAbstract(b)) { const changeType = isAbstract(a) ? 'abstract to concrete' : 'concrete to abstract'; - const changeSeverity = isAbstract(a) ? 'minor' : 'major'; + const changeKey =isAbstract(a) ? `class-declaration-abstract-to-concrete` : `class-declaration-concrete-to-abstract`; context.report({ - key: 'class-declaration-abstractness-changed', - message: `The class "${a.getName()}" changed from ${changeType} (${changeSeverity} change).`, + key: changeKey, + message: `The class "${a.getName()}" changed from ${changeType}.`, element: a }); }