CodeQL documentation

Missing ‘this’ qualifier

ID: js/missing-this-qualifier
Kind: problem
Security severity: 
Severity: error
Precision: high
   - maintainability
   - correctness
   - methods
Query suites:
   - javascript-security-and-quality.qls

Click to see the query in the CodeQL repository

JavaScript methods can call other methods of the same class instance through the use of the this keyword. In other object-oriented languages such as Java, the use of the this keyword for such method calls is optional. It is however not optional in JavaScript. If the this keyword is left out, the call is a regular function call.


Add the this keyword as the receiver of the call.


In the following example, the call to setAudioProperties will call an undeclared global function, and not the method defined later in the class.

class Audio3D {
    // ...
    // ...

    // ...  

The problem can be fixed by adding the this keyword to the call: this.setAudioProperties().


  • © GitHub, Inc.
  • Terms
  • Privacy