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

feat(problem-matchers): Add warnings to problem matchers #288

Merged

Conversation

Wondrous27
Copy link
Contributor

@Wondrous27 Wondrous27 commented Jun 10, 2023

Summary

This PR enables warning annotations as an alternative to errors. If the severity is not specified in the problem matcher, it defaults to error. Only values accepted for severity is error and warning case-insenitive, but unfortunately cfn-lint does not output any of those. It only produces a single letter for the type of the problem. Therefore, we can't directly use the matched group in the severity field. After some digging around, I've found that we can specify the severity field in the same level as owner. We can specify two owners, one for warnings and informational and one for errors.

I also took the liberty of including the error code in the message to make it more convenient to search the issue in cfn-lint rules. I can revert it back if you'd like. With these changes the message displayed in the annotations will change from

Parameter EnvName is missing required property Type
to
E2001 Parameter EnvName is missing required property Type

For some reason code field does not get displayed in the annotation message even if it gets matched properly. I have the same issue with eslint and could not find any open issues about that.

Other Information

I'm not a regex guru, there is probably much better way to do it but this is what I came up with: https://regex101.com/r/Qo5sGX/1 It creates an additional group from the whole text in addition to previous groups

Relevant docs:
https://github.com/actions/runner/blob/main/docs/adrs/0276-problem-matchers.md#supported-severity-levels
https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md#single-line-matchers

cfn-lint

@ScottBrenner ScottBrenner requested a review from NickLiffen June 10, 2023 15:36
@ScottBrenner ScottBrenner added the enhancement New feature or request label Jun 10, 2023
@ScottBrenner ScottBrenner enabled auto-merge (squash) June 10, 2023 15:48
Copy link
Owner

@ScottBrenner ScottBrenner left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@ScottBrenner ScottBrenner merged commit 537e014 into ScottBrenner:main Jun 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants