C#: Increase precision of cs/useless-gethashcode-call.#19010
Merged
michaelnebel merged 4 commits intogithub:mainfrom Mar 14, 2025
Merged
C#: Increase precision of cs/useless-gethashcode-call.#19010michaelnebel merged 4 commits intogithub:mainfrom
cs/useless-gethashcode-call.#19010michaelnebel merged 4 commits intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR increases the precision of the cs/useless-gethashcode-call query by excluding calls to GetHashCode on uint, long, and ulong from being flagged. It also converts the tests to inline tests and updates the change note accordingly.
- Updated change note file to document the refined behavior.
- Modified the test file to flag only calls on int, short, ushort, byte, and sbyte.
Reviewed Changes
Copilot reviewed 2 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| csharp/ql/src/change-notes/2025-03-13-useless-gethashcode-call.md | Adds a change note specifying the increased precision. |
| csharp/ql/test/query-tests/Useless Code/IntGetHashCode/IntGetHashCode.cs | Converts tests to inline tests with alerts for specific types. |
Files not reviewed (3)
- csharp/ql/src/Useless code/IntGetHashCode.ql: Language not supported
- csharp/ql/test/query-tests/Useless Code/IntGetHashCode/IntGetHashCode.expected: Language not supported
- csharp/ql/test/query-tests/Useless Code/IntGetHashCode/IntGetHashCode.qlref: Language not supported
Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more
Contributor
Author
|
DCA looks good. |
tamasvajk
approved these changes
Mar 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As this table indicates, only
byte,sbyte,short,ushortandintcan use the identity function forGetHashCode(and they indeed do so) as the return type ofGetHashCodeisint.In this PR we update the
cs/useless-gethashcode-callto exclude calls toGetHashCodeonuint,longandulongand convert the tests to inline tests.