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):
varmyObj=getData();console.log(myObj);// badconsole.debug("myObj:",myObj);// badUse this rule by referencing it:
<ruleref="category/ecmascript/performance.xml/AvoidConsoleStatements"/>