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

simplify the code for diagnostics severity adjustment #17896

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Martin521
Copy link
Contributor

Description

This PR simplifies the code for adjusting diagnostics severity, without change to the functionality.
It will be needed for "scoped nowarn", where the adjustment logic becomes even more complex, but makes sense also in itself.

@Martin521 Martin521 requested a review from a team as a code owner October 17, 2024 14:25
Copy link
Contributor

github-actions bot commented Oct 17, 2024

⚠️ Release notes required, but author opted out

Warning

Author opted out of release notes, check is disabled for this pull request.
cc @dotnet/fsharp-team-msft

@Martin521
Copy link
Contributor Author

Can somebody add the "no release notes" label?
Thanks

@psfinaki psfinaki added the NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes label Oct 17, 2024
@psfinaki
Copy link
Member

There you go, Martin :) Thanks for splitting the refactoring into a separate PR, that's always helpful.

Copy link
Member

@KevinRansom KevinRansom left a comment

Choose a reason for hiding this comment

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

Thank you, nice bit of cleanup.
A couple of nits, but other than that this is ready to go.


// We use the first line of the file as a fallbackRange for reporting unexpected errors.
// Not ideal, but it's hard to see what else to do.
let fallbackRange = rangeN mainInputFileName 1
let diagnostic = FSharpDiagnostic.CreateFromExceptionAndAdjustEof (diagnostic, severity, fallbackRange, fileInfo, suggestNames, flatErrors, symbolEnv)
let diagnostic = FSharpDiagnostic.CreateFromExceptionAndAdjustEof (diagnostic, sev, fallbackRange, fileInfo, suggestNames, flatErrors, symbolEnv)
Copy link
Member

Choose a reason for hiding this comment

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

It was originally severity, we have always had problems with abbreviations in this codebase, in general avoid them, especially if they were originally unabbreviated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to shadow the original severity. I'll make it adjustedSeverity.

List.contains n options.WarnOn && not (List.contains n options.WarnOff)

| FSharpDiagnosticSeverity.Hidden -> false
member x.AdjustedSeverity(options, severity) =
Copy link
Member

Choose a reason for hiding this comment

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

Should it be AdjustSeverity?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

member x.AdjustSeverity(,) sounds like changing the state of object x, while it is just a pure function.
(Honestly, it shouldn't be a member at all. The whole type extensions doesn't look right. I might tackle that separately. )
Unless there are big objections, I will leave the name for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes
Projects
Status: New
Development

Successfully merging this pull request may close these issues.

3 participants