:language_std_outputs: print

== Why is this an issue?

include::../description.adoc[]

If you are using Flutter, you can use `debugPrint` or surround print calls with a check for `kDebugMode`.

=== Code examples

==== Noncompliant code example

[source,dart]
----
void doSomething(int x) {
  // ...
  print('debug: $x');
  // ...
}
----

==== Compliant solution

[source,dart]
----
void doSomething(int x) {
  // ...
  debugPrint('debug: $x');
  // ...
}
----

or

[source,dart]
----
void doSomething(int x) {
  // ...
  if (kDebugMode) {
    print('debug: $x');
  }
  // ...
}
----

or

[source,dart]
----
void doSomething(int x) {
  // ...
  log('log: $x');
  // ...
}
----

== Resources

* OWASP - https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/[Top 10 2021 Category A9 - Security Logging and Monitoring Failures]
* OWASP - https://owasp.org/www-project-top-ten/2017/A3_2017-Sensitive_Data_Exposure[Top 10 2017 Category A3 - Sensitive Data Exposure]
* Dart Docs - https://dart.dev/tools/linter-rules/avoid_print[Dart Linter rule - avoid_print]
* Flutter API Docs - https://api.flutter.dev/flutter/foundation/kDebugMode-constant.html[kDebugMode top-level constant]

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

* Don't invoke 'print' in production code.

=== Highlighting

The identifier of the `print` method, without argument list.

'''
== Comments And Links
(visible only on this page)

include::../comments-and-links.adoc[]

endif::env-github,rspecator-view[]
