Skip to content

fix: PH2141 false positive for regions containing copyright comments - #961

Merged
Brian Collamore (bcollamore) merged 5 commits into
mainfrom
copilot/fix-960
Aug 27, 2025
Merged

fix: PH2141 false positive for regions containing copyright comments#961
Brian Collamore (bcollamore) merged 5 commits into
mainfrom
copilot/fix-960

Conversation

Copilot AI commented Aug 27, 2025

Copy link
Copy Markdown
Contributor
  • Fix PH2141 false positive for regions containing copyright comments
  • Add comprehensive test coverage for copyright detection scenarios
  • Address code review feedback:
    • Update PH2141.md documentation to clarify copyright comments are allowed
    • Simplify IsRegionEmpty logic by immediately returning false for non-comment content
    • Replace string concatenation with StringBuilder for better performance
  • Ensure all tests pass (2010 tests)
  • Verify formatting compliance with .editorconfig rules

Changes Made

Documentation Updates

  • Enhanced PH2141.md to clarify that regions with copyright information are not considered empty
  • Added examples showing both invalid (regular comments) and valid (copyright) scenarios

Code Improvements

  • Simplified IsRegionEmpty method by removing unnecessary hasNonCommentContent variable
  • Replaced string concatenation with StringBuilder in ContainsCopyrightInformation method
  • Fixed code analysis warnings (CA1834, IDE0058)

All changes maintain backward compatibility and existing functionality while addressing the false positive issue for copyright regions.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits August 27, 2025 19:24
Co-authored-by: bcollamore <57269455+bcollamore@users.noreply.github.com>
Co-authored-by: bcollamore <57269455+bcollamore@users.noreply.github.com>
Copilot AI changed the title [WIP] PH2141 empty region false positive with copyright Fix PH2141 false positive for regions containing copyright comments Aug 27, 2025
@bcollamore Brian Collamore (bcollamore) changed the title Fix PH2141 false positive for regions containing copyright comments fix: PH2141 false positive for regions containing copyright comments Aug 27, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's update documentation (PH2141.md) to note copyright comment is allowed, but otherwise, just comments is not allowed.

@bcollamore

Copy link
Copy Markdown
Member

Copilot see comments above. Also, SonarCloud suggests using StringBuilder instead on line 152.

Co-authored-by: bcollamore <57269455+bcollamore@users.noreply.github.com>

Copilot AI commented Aug 27, 2025

Copy link
Copy Markdown
Contributor Author

Copilot see comments above. Also, SonarCloud suggests using StringBuilder instead on line 152.

Replaced string concatenation with StringBuilder for better performance and fixed the CA1834 warning by using char instead of string for the space character. (3787a0c)

Copilot AI commented Aug 27, 2025

Copy link
Copy Markdown
Contributor Author

Let's update documentation (PH2141.md) to note copyright comment is allowed, but otherwise, just comments is not allowed.

Updated PH2141.md documentation to clarify that regions containing copyright information are allowed while regular comment-only regions are not. Added examples showing both scenarios. (3787a0c)

@sonarqubecloud

Copy link
Copy Markdown

@bcollamore
Brian Collamore (bcollamore) added this pull request to the merge queue Aug 27, 2025
Merged via the queue into main with commit cc26e84 Aug 27, 2025
12 of 13 checks passed
@bcollamore
Brian Collamore (bcollamore) deleted the copilot/fix-960 branch August 27, 2025 20:16
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.

3 participants