Skip to content

Fix analyzer RCS1208 #1462

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

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

Fix analyzer RCS1208 #1462

wants to merge 5 commits into from

Conversation

josefpihrt
Copy link
Collaborator

fixes #1454

@josefpihrt josefpihrt self-assigned this May 8, 2024
@BenjaminBrienen
Copy link
Contributor

Would this fix this issue?

public void Setup(MarkdownPipelineBuilder pipeline)
{
	if (pipeline.BlockParsers.Find<HeadingBlockParser>() is HeadingBlockParser headingBlockParser)
	{
		// Install a hook on the HeadingBlockParser when a HeadingBlock is actually processed
		headingBlockParser.Closed -= HeadingBlockParser_Closed;
		headingBlockParser.Closed += HeadingBlockParser_Closed;
	}
	if (pipeline.BlockParsers.FindExact<ParagraphBlockParser>() is ParagraphBlockParser paragraphBlockParser) // Reduce 'if' nesting RCS1208
	{
		// Install a hook on the ParagraphBlockParser when a HeadingBlock is actually processed as a Setex heading
		paragraphBlockParser.Closed -= HeadingBlockParser_Closed;
		paragraphBlockParser.Closed += HeadingBlockParser_Closed;
	}
}

@josefpihrt
Copy link
Collaborator Author

I'm not sure that I'm following you.

@BenjaminBrienen
Copy link
Contributor

BenjaminBrienen commented May 1, 2025

It suggests to invert that second if-block even though it wouldn't improve readability. This PR seems to add the concept of a "last if-block" and allows them.

@josefpihrt
Copy link
Collaborator Author

Tbh, I was working on this fix couple of months ago and the only thing I recall is that fix is almost impossible so I gave up 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RCS1208 False-positive on flat if statement with multiple conditions
2 participants