Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

class-declaration-abstractness-changed #974

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions packages/concerto-analysis/src/comparers/class-declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,17 @@ const classDeclarationTypeChanged: ComparerFactory = (context) => ({
if (aType === bType) {
return;
}
context.report({

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing type-change report shouldn't be removed. Instead, the if statement above should be inverted (aType !== bType or whatever) and the report should be put in there.

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).`,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The severity can't simply be expressed in the message but must be defined here:

You'll need to create two different keys: one for abstract to concrete, and one for concrete to abstract.

Copy link
Author

@Mamatha1718 Mamatha1718 Dec 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the rules, and change the severity to changeKey.
The pull request is ready for review.
please let me know if any changes need.

element: a
});
}
}
});

Expand Down