Skip to content

Go: Update tags for high precision quality queries #19763

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

Merged
merged 3 commits into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
ql/go/ql/src/InconsistentCode/ConstantLengthComparison.ql
ql/go/ql/src/InconsistentCode/InconsistentLoopOrientation.ql
ql/go/ql/src/InconsistentCode/LengthComparisonOffByOne.ql
ql/go/ql/src/InconsistentCode/MissingErrorCheck.ql
ql/go/ql/src/InconsistentCode/MistypedExponentiation.ql
ql/go/ql/src/InconsistentCode/UnhandledCloseWritableHandle.ql
ql/go/ql/src/InconsistentCode/WhitespaceContradictsPrecedence.ql
ql/go/ql/src/InconsistentCode/WrappedErrorAlwaysNil.ql
ql/go/ql/src/RedundantCode/CompareIdenticalValues.ql
ql/go/ql/src/RedundantCode/DeadStoreOfField.ql
ql/go/ql/src/RedundantCode/DeadStoreOfLocal.ql
ql/go/ql/src/RedundantCode/DuplicateBranches.ql
ql/go/ql/src/RedundantCode/DuplicateCondition.ql
ql/go/ql/src/RedundantCode/DuplicateSwitchCase.ql
ql/go/ql/src/RedundantCode/ExprHasNoEffect.ql
ql/go/ql/src/RedundantCode/ImpossibleInterfaceNilCheck.ql
ql/go/ql/src/RedundantCode/NegativeLengthCheck.ql
ql/go/ql/src/RedundantCode/RedundantExpr.ql
ql/go/ql/src/RedundantCode/RedundantRecover.ql
ql/go/ql/src/RedundantCode/SelfAssignment.ql
ql/go/ql/src/RedundantCode/ShiftOutOfRange.ql
ql/go/ql/src/RedundantCode/UnreachableStatement.ql
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
ql/go/ql/src/InconsistentCode/ConstantLengthComparison.ql
ql/go/ql/src/InconsistentCode/InconsistentLoopOrientation.ql
ql/go/ql/src/InconsistentCode/LengthComparisonOffByOne.ql
ql/go/ql/src/InconsistentCode/MissingErrorCheck.ql
ql/go/ql/src/InconsistentCode/MistypedExponentiation.ql
ql/go/ql/src/InconsistentCode/UnhandledCloseWritableHandle.ql
ql/go/ql/src/InconsistentCode/WhitespaceContradictsPrecedence.ql
ql/go/ql/src/InconsistentCode/WrappedErrorAlwaysNil.ql
ql/go/ql/src/RedundantCode/CompareIdenticalValues.ql
ql/go/ql/src/RedundantCode/DeadStoreOfField.ql
ql/go/ql/src/RedundantCode/DeadStoreOfLocal.ql
ql/go/ql/src/RedundantCode/DuplicateBranches.ql
ql/go/ql/src/RedundantCode/DuplicateCondition.ql
ql/go/ql/src/RedundantCode/DuplicateSwitchCase.ql
ql/go/ql/src/RedundantCode/ExprHasNoEffect.ql
ql/go/ql/src/RedundantCode/ImpossibleInterfaceNilCheck.ql
ql/go/ql/src/RedundantCode/NegativeLengthCheck.ql
ql/go/ql/src/RedundantCode/RedundantExpr.ql
ql/go/ql/src/RedundantCode/RedundantRecover.ql
ql/go/ql/src/RedundantCode/SelfAssignment.ql
ql/go/ql/src/RedundantCode/ShiftOutOfRange.ql
ql/go/ql/src/RedundantCode/UnreachableStatement.ql
5 changes: 4 additions & 1 deletion go/ql/src/InconsistentCode/ConstantLengthComparison.ql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
* @kind problem
* @problem.severity warning
* @id go/constant-length-comparison
* @tags correctness
* @tags quality
* reliability
* correctness
* external/cwe/cwe-129
* @precision high
*/

Expand Down
4 changes: 3 additions & 1 deletion go/ql/src/InconsistentCode/InconsistentLoopOrientation.ql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
* @kind problem
* @problem.severity error
* @id go/inconsistent-loop-direction
* @tags correctness
* @tags quality
* reliability
* correctness
* external/cwe/cwe-835
* @precision very-high
*/
Expand Down
5 changes: 2 additions & 3 deletions go/ql/src/InconsistentCode/LengthComparisonOffByOne.ql
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
* @kind problem
* @problem.severity error
* @id go/index-out-of-bounds
* @tags reliability
* @tags quality
* reliability
* correctness
* logic
* quality
* external/cwe/cwe-193
* @precision high
*/
Expand Down
8 changes: 4 additions & 4 deletions go/ql/src/InconsistentCode/MissingErrorCheck.ql
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* @kind problem
* @problem.severity warning
* @id go/missing-error-check
* @tags reliability
* correctness
* logic
* quality
* @tags quality
* reliability
* error-handling
* external/cwe/cwe-252
* @precision high
*/

Expand Down
5 changes: 4 additions & 1 deletion go/ql/src/InconsistentCode/MistypedExponentiation.ql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
* @kind problem
* @problem.severity warning
* @id go/mistyped-exponentiation
* @tags correctness
* @tags quality
* reliability
* correctness
* external/cwe/cwe-480
* @precision high
*/

Expand Down
9 changes: 4 additions & 5 deletions go/ql/src/InconsistentCode/UnhandledCloseWritableHandle.ql
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
* @problem.severity warning
* @precision high
* @id go/unhandled-writable-file-close
* @tags maintainability
* correctness
* call
* defer
* quality
* @tags quality
* reliability
* error-handling
* external/cwe/cwe-252
*/

import go
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/**
* @name Whitespace contradicts operator precedence
* @description Nested expressions where the formatting contradicts the grouping enforced by operator precedence
* are difficult to read and may even indicate a bug.
* are difficult to read and may indicate a bug.
* @kind problem
* @problem.severity warning
* @id go/whitespace-contradicts-precedence
* @tags maintainability
* @tags quality
* reliability
* correctness
* external/cwe/cwe-783
* @precision very-high
Expand Down
7 changes: 3 additions & 4 deletions go/ql/src/InconsistentCode/WrappedErrorAlwaysNil.ql
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
* @kind problem
* @problem.severity warning
* @id go/unexpected-nil-value
* @tags reliability
* correctness
* logic
* quality
* @tags quality
* reliability
* error-handling
* @precision high
*/

Expand Down
4 changes: 3 additions & 1 deletion go/ql/src/RedundantCode/CompareIdenticalValues.ql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
* @kind problem
* @problem.severity warning
* @id go/comparison-of-identical-expressions
* @tags correctness
* @tags quality
* reliability
* correctness
* external/cwe/cwe-570
* external/cwe/cwe-571
* @precision very-high
Expand Down
4 changes: 3 additions & 1 deletion go/ql/src/RedundantCode/DeadStoreOfField.ql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* @kind problem
* @problem.severity warning
* @id go/useless-assignment-to-field
* @tags maintainability
* @tags quality
* maintainability
* useless-code
* external/cwe/cwe-563
* @precision very-high
*/
Expand Down
4 changes: 3 additions & 1 deletion go/ql/src/RedundantCode/DeadStoreOfLocal.ql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
* @kind problem
* @problem.severity warning
* @id go/useless-assignment-to-local
* @tags maintainability
* @tags quality
* maintainability
* useless-code
* external/cwe/cwe-563
* @precision very-high
*/
Expand Down
3 changes: 2 additions & 1 deletion go/ql/src/RedundantCode/DuplicateBranches.ql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* @problem.severity warning
* @precision very-high
* @id go/duplicate-branches
* @tags maintainability
* @tags quality
* reliability
* correctness
* external/cwe/cwe-561
*/
Expand Down
3 changes: 2 additions & 1 deletion go/ql/src/RedundantCode/DuplicateCondition.ql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* @kind problem
* @problem.severity error
* @id go/duplicate-condition
* @tags maintainability
* @tags quality
* reliability
* correctness
* external/cwe/cwe-561
* @precision very-high
Expand Down
3 changes: 2 additions & 1 deletion go/ql/src/RedundantCode/DuplicateSwitchCase.ql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* @kind problem
* @problem.severity error
* @id go/duplicate-switch-case
* @tags maintainability
* @tags quality
* reliability
* correctness
* external/cwe/cwe-561
* @precision very-high
Expand Down
3 changes: 2 additions & 1 deletion go/ql/src/RedundantCode/ExprHasNoEffect.ql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* @kind problem
* @problem.severity warning
* @id go/useless-expression
* @tags maintainability
* @tags quality
* reliability
* correctness
* external/cwe/cwe-480
* external/cwe/cwe-561
Expand Down
5 changes: 4 additions & 1 deletion go/ql/src/RedundantCode/ImpossibleInterfaceNilCheck.ql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
* @kind problem
* @problem.severity warning
* @id go/impossible-interface-nil-check
* @tags correctness
* @tags quality
* reliability
* correctness
* external/cwe/cwe-570
* @precision high
*/

Expand Down
6 changes: 4 additions & 2 deletions go/ql/src/RedundantCode/NegativeLengthCheck.ql
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
* @problem.severity warning
* @precision very-high
* @id go/negative-length-check
* @tags correctness
* quality
* @tags quality
* reliability
* correctness
* external/cwe/cwe-571
*/

import go
Expand Down
4 changes: 3 additions & 1 deletion go/ql/src/RedundantCode/RedundantExpr.ql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* @kind problem
* @problem.severity warning
* @id go/redundant-operation
* @tags correctness
* @tags quality
* reliability
* correctness
* external/cwe/cwe-480
* external/cwe/cwe-561
* @precision very-high
Expand Down
5 changes: 3 additions & 2 deletions go/ql/src/RedundantCode/RedundantRecover.ql
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
* @kind problem
* @problem.severity warning
* @id go/redundant-recover
* @tags maintainability
* @tags quality

This comment was marked as resolved.

* reliability
* correctness
* quality
* external/cwe/cwe-248
* @precision high
*/

Expand Down
4 changes: 3 additions & 1 deletion go/ql/src/RedundantCode/SelfAssignment.ql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* @kind problem
* @problem.severity warning
* @id go/redundant-assignment
* @tags correctness
* @tags quality
* reliability
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this more in the maintainability / useless-code category?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It depends. I compared the qhelp for the equivalent query for a few languages and some took the "this line does nothing, just delete it" approach, and others took the "this is probably a sign that you meant to write something else, there's probably a bug" approach. We should be consistent, I suppose. I'll raise it with the team.

Copy link
Member

Choose a reason for hiding this comment

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

@owen-mc I think that explanation makes sense with regards to what finding a self-assignment in the code might mean. That said, wouldn't correctness and useless-code be the appropriate tags then?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is fine to keep it as it is - let's merge 😄 .

* correctness
* external/cwe/cwe-480
* external/cwe/cwe-561
* @precision high
Expand Down
4 changes: 3 additions & 1 deletion go/ql/src/RedundantCode/ShiftOutOfRange.ql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* @problem.severity warning
* @id go/shift-out-of-range
* @precision very-high
* @tags correctness
* @tags quality
* reliability
* correctness
* external/cwe/cwe-197
*/

Expand Down
3 changes: 2 additions & 1 deletion go/ql/src/RedundantCode/UnreachableStatement.ql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* @kind problem
* @problem.severity warning
* @id go/unreachable-statement
* @tags maintainability
* @tags quality
* reliability
* correctness
* external/cwe/cwe-561
* @precision very-high
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
category: queryMetadata
---
* The tag `quality` has been added to multiple Go quality queries for consistency. They have all been given a tag for one of the two top-level categories `reliability` or `maintainability`, and a tag for a sub-category. See [Query file metadata and alert message style guide](https://github.com/github/codeql/blob/main/docs/query-metadata-style-guide.md#quality-query-sub-category-tags) for more information about these categories.
* The tag `external/cwe/cwe-129` has been added to `go/constant-length-comparison`.
* The tag `external/cwe/cwe-193` has been added to `go/index-out-of-bounds`.
* The tag `external/cwe/cwe-197` has been added to `go/shift-out-of-range`.
* The tag `external/cwe/cwe-248` has been added to `go/redundant-recover`.
* The tag `external/cwe/cwe-252` has been added to `go/missing-error-check` and `go/unhandled-writable-file-close`.
* The tag `external/cwe/cwe-480` has been added to `go/mistyped-exponentiation`.
* The tag `external/cwe/cwe-570` has been added to `go/impossible-interface-nil-check` and `go/comparison-of-identical-expressions`.
* The tag `external/cwe/cwe-571` has been added to `go/negative-length-check` and `go/comparison-of-identical-expressions`.
* The tag `external/cwe/cwe-783` has been added to `go/whitespace-contradicts-precedence`.
* The tag `external/cwe/cwe-835` has been added to `go/inconsistent-loop-direction`.
* The tag `error-handling` has been added to `go/missing-error-check`, `go/unhandled-writable-file-close`, and `go/unexpected-nil-value`.
* The tag `useless-code` has been added to `go/useless-assignment-to-field`, `go/useless-assignment-to-local`, `go/useless-expression`, and `go/unreachable-statement`.
* The tag `logic` has been removed from `go/index-out-of-bounds` and `go/unexpected-nil-value`.
* The tags `call` and `defer` have been removed from `go/unhandled-writable-file-close`.
* The tags `correctness` and `quality` have been reordered in `go/missing-error-check` and `go/unhandled-writable-file-close`.
* The tag `maintainability` has been changed to `reliability` for `go/unhandled-writable-file-close`.
* The tag order has been standardized to have `quality` first, followed by the top-level category (`reliability` or `maintainability`), then sub-category tags, and finally CWE tags.
* The description text has been updated in `go/whitespace-contradicts-precedence` to change "may even indicate" to "may indicate".