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

Compute fix kind from metatadata #2799

Closed
Tracked by #2797
ematipico opened this issue May 10, 2024 · 1 comment · Fixed by #2889
Closed
Tracked by #2797

Compute fix kind from metatadata #2799

ematipico opened this issue May 10, 2024 · 1 comment · Fixed by #2889
Assignees
Labels
good first issue Good for newcomers S-Help-wanted Status: you're familiar with the code base and want to help the project

Comments

@ematipico
Copy link
Member

ematipico commented May 10, 2024

The RuleAction now accepts an applicability field, determining whether the action is safe/unsafe.

However, we also provide the same information to our RuleMeta, which is fix_kind.

Once #2798 is completed, we can retrieve the fix_kind using ctx.metadata().fix_kind.

The idea is to create a method inside FixKind called into_applicability that returns Applicability. This method should panic (use .expect()) if the fix kind isn't provided via macro.

The field applicability should become private (remove pub), however do that at the end. I suggest to create a new method called new inside RuleAction, and then progressively phase out the manual construction of the struct

impl RuleAction {
	pub fn new(category: ActionCategory, applicability: Applicability, message: MarkupBuf, mutation: BatchMutation) -> Self {
		Self {
			category,
			applicability,
			message,
			mutation
		}
	}
}

As a rule, we should have:

        Some(JsRuleAction {
            category: ActionCategory::QuickFix,
            applicability: ctx.metadata().to_applicability(),
            message: markup! { "" }.to_owned(),
            mutation,
        })
@ematipico ematipico added good first issue Good for newcomers S-Help-wanted Status: you're familiar with the code base and want to help the project labels May 10, 2024
@dyc3
Copy link
Contributor

dyc3 commented May 12, 2024

I can pick this up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers S-Help-wanted Status: you're familiar with the code base and want to help the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants