-
Notifications
You must be signed in to change notification settings - Fork 1.9k
JS: Promote js/suspicious-method-name-declaration to the Code Quality suite.
#19741
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
Napalys
merged 5 commits into
github:main
from
Napalys:js/quality/suspicious_method_names
Jun 12, 2025
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
41f4236
JS: expanded `suspicious-method-name-declaration` test suite
Napalys 60e3b0c
JS: Update `qhelp` and added more examples.
Napalys c5a1421
JS: promote `suspicious-method-name-declaration` to quality query.
Napalys 7b91a57
JS: add change note.
Napalys e6d2691
Update javascript/ql/src/Declarations/SuspiciousMethodNameDeclaration…
Napalys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
javascript/ql/integration-tests/query-suite/javascript-code-quality.qls.expected
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
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
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
6 changes: 3 additions & 3 deletions
6
javascript/ql/src/Declarations/examples/SuspiciousMethodNameDeclaration.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| declare class Point { | ||
| // BAD: Using 'constructor' in an interface creates a method, not a constructor signature | ||
| interface Point { | ||
| x: number; | ||
| y: number; | ||
| constructor(x : number, y: number); | ||
| constructor(x: number, y: number); // This is just a method named "constructor" | ||
| } | ||
|
|
6 changes: 6 additions & 0 deletions
6
javascript/ql/src/Declarations/examples/SuspiciousMethodNameDeclarationClass.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // BAD: Using 'new' in a class creates a method, not a constructor | ||
| class Point { | ||
| x: number; | ||
| y: number; | ||
| new(x: number, y: number) {}; // This is just a method named "new" | ||
| } |
9 changes: 9 additions & 0 deletions
9
javascript/ql/src/Declarations/examples/SuspiciousMethodNameDeclarationClassFixed.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // GOOD: Using 'constructor' for constructors in classes | ||
| class Point { | ||
| x: number; | ||
| y: number; | ||
| constructor(x: number, y: number) { // This is a proper constructor | ||
| this.x = x; | ||
| this.y = y; | ||
| } | ||
| } |
2 changes: 2 additions & 0 deletions
2
javascript/ql/src/Declarations/examples/SuspiciousMethodNameDeclarationFixed.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| // GOOD: Using 'new' for constructor signatures in interfaces | ||
| interface Point { | ||
| x: number; | ||
| y: number; | ||
| new(x: number, y: number): Point; // This is a proper constructor signature | ||
| } |
4 changes: 4 additions & 0 deletions
4
javascript/ql/src/Declarations/examples/SuspiciousMethodNameDeclarationFunction.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // BAD: Using 'function' as a method name is confusing | ||
| interface Calculator { | ||
| function(a: number, b: number): number; // This is just a method named "function" | ||
| } |
4 changes: 4 additions & 0 deletions
4
javascript/ql/src/Declarations/examples/SuspiciousMethodNameDeclarationFunctionFixed.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // GOOD: Using descriptive method names instead of 'function' | ||
| interface Calculator { | ||
| calculate(a: number, b: number): number; // Clear, descriptive method name | ||
| } |
4 changes: 4 additions & 0 deletions
4
javascript/ql/src/change-notes/2025-06-12-suspicious-method-name.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: queryMetadata | ||
| --- | ||
| * Added `reliability` tag to the `js/suspicious-method-name-declaration` query. |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.