Rules that flag suboptimal code.
Table of Contents
AvoidConsoleStatements
Since: PMD 7.5.0
Priority: Medium (3)
Using the console for logging in production might negatively impact performance. In addition, logging could expose sensitive data.
This rule is defined by the following XPath expression:
//FunctionCall[PropertyGet
[Name[1][@Identifier = 'console']]
[Name[2][@Identifier]]
]
|
//FunctionCall[PropertyGet
[PropertyGet[1]
[Name[1][@Identifier = 'window']]
[Name[2][@Identifier = 'console']]
]
[Name[1][@Identifier]]
]
Example(s):
var myObj = getData();
console.log(myObj); // bad
console.debug("myObj:", myObj); // bad
Use this rule by referencing it:
<rule ref="category/ecmascript/performance.xml/AvoidConsoleStatements" />