A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/3307 below:

[apex] Avoid debug statements since it impact performance · Issue #3307 · pmd/pmd · GitHub

Proposed Rule Name: AvoidDebugStatements

Proposed Category: Performance

Description:

As demonstrated by @keirbowden in his blog, the usage of debug statements generates a negative impact in the application performance even when debug traces are not set.

Taking into account that this technique is usually implemented temporarily and should not reach production environments it seems important to flag their usage to mitigate performance issues (especially taking into consideration that most of what is achieved with a System.debug statement can also be done using the Apex Replay Debugger and checkpoints).

Obviously there are exception where it may be needed and for those use cases the PMD warning suppression mechanism could be used to explicitly indicate that is actually needed (like the AvoidGlobalModifier one).

Code Sample:

Should be flagged

public class Foo {
  public void debugMe() {
    System.debug(LoggingLevel.ERROR, 'please flag me');
  }
}

Good to go

@SuppressWarnings('PMD.AvoidDebugStatements')
public class LoggingManager {
  public static void log(System.LoggingLevel level, Object data) {
    System.debug(level, data);
  }
}
public class Foo {
  public void debugMe() {
    LoggingManager.log(LoggingLevel.ERROR, 'wont flag');
  }
}

gianfrancoZuardi, WyrnCael, JesusIglesias-S4G, FBS4G, FranciscoSimonS4G and 15 more


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4