Modify rule S106: fix name of print method

This commit is contained in:
Antonio Aversa 2024-07-31 17:48:18 +02:00 committed by Marharyta
parent 430ebc0ad0
commit 458d45228a

View File

@ -1,4 +1,4 @@
:language_std_outputs: std::cout, std::cerr, printf, std::print
:language_std_outputs: print
== Why is this an issue?
@ -8,9 +8,9 @@ If you are using Flutter, you can use `debugPrint` or surround print calls with
=== Code examples
The following noncompliant code:
==== Noncompliant code example
[source,dart,diff-id=1,diff-type=noncompliant]
[source,dart]
----
void doSomething(int x) {
// ...
@ -19,12 +19,11 @@ void doSomething(int x) {
}
----
Could be replaced by:
==== Compliant solution
[source,dart,diff-id=1,diff-type=compliant]
[source,dart]
----
void doSomething(int x)
{
void doSomething(int x) {
// ...
debugPrint('debug: $x');
// ...
@ -33,10 +32,9 @@ void doSomething(int x)
or
[source,dart,diff-id=1,diff-type=compliant]
[source,dart]
----
void doSomething(int x)
{
void doSomething(int x) {
// ...
if (kDebugMode) {
print('debug: $x');
@ -47,10 +45,9 @@ void doSomething(int x)
or
[source,dart,diff-id=1,diff-type=compliant]
[source,dart]
----
void doSomething(int x)
{
void doSomething(int x) {
// ...
log('log: $x');
// ...
@ -62,3 +59,26 @@ void doSomething(int x)
* 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[]