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

Razor mappings: Ensure we check if the mapped span is valid #9305

Merged
merged 1 commit into from
May 21, 2024

Conversation

costin-zaharia-sonarsource
Copy link
Member

Related to #9288

Copy link

sonarcloud bot commented May 21, 2024

Quality Gate Passed Quality Gate passed for 'Sonar .NET Java Plugin'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented May 21, 2024

Comment on lines +124 to +125
&& (!GeneratedCodeRecognizer.IsRazor(token.SyntaxTree) || mappedLineSpan.HasMappedPath)
&& IsInSameFile(mappedLineSpan)

Choose a reason for hiding this comment

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

I assume that in razor files, if mappedLineSpan.HasMappedPath is false, IsInSameFile(mappedLineSpan) is false as well. Therefore the mappedLineSpan.HasMappedPath check might be redundant. Can you confirm this? If so, I would remove

Suggested change
&& (!GeneratedCodeRecognizer.IsRazor(token.SyntaxTree) || mappedLineSpan.HasMappedPath)
&& IsInSameFile(mappedLineSpan)
&& IsInSameFile(mappedLineSpan)

and add a comment about the mappedLineSpan.HasMappedPath being redundant.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, but I would keep it since it is way faster to check this than to do string comparisons (although we cannot completely remove those).

So we reduce the data set a bit here, and later even more.

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

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.

None yet

2 participants