rspec/rules/S1116/dart/rule.adoc

86 lines
1.4 KiB
Plaintext
Raw Permalink Normal View History

2024-07-10 16:04:44 +02:00
== Why is this an issue?
include::../description.adoc[]
=== Code examples
==== Noncompliant code example
2024-07-11 15:00:51 +02:00
[source,dart,diff-id=1,diff-type=noncompliant]
2024-07-10 16:04:44 +02:00
----
void doSomething() {
; // Noncompliant - was used as a kind of TODO marker
2024-07-10 16:04:44 +02:00
}
2024-07-11 15:00:51 +02:00
----
2024-07-10 16:04:44 +02:00
2024-07-11 15:00:51 +02:00
[source,dart,diff-id=2,diff-type=noncompliant]
----
void f() {
if (complicated.expression.foo()); // Noncompliant - the condition doesn't apply to bar
2024-07-11 15:00:51 +02:00
bar();
}
2024-07-10 16:04:44 +02:00
----
[source,dart,diff-id=3,diff-type=noncompliant]
----
void f() {
if (complicated.expression.foo())
bar();
else ; // Noncompliant else is empty
buzz();
}
----
2024-07-10 16:04:44 +02:00
==== Compliant solution
2024-07-11 15:00:51 +02:00
[source,dart,diff-id=1,diff-type=compliant]
2024-07-10 16:04:44 +02:00
----
void doSomething() {
}
2024-07-11 15:00:51 +02:00
----
2024-07-10 16:04:44 +02:00
2024-07-11 15:00:51 +02:00
[source,dart,diff-id=2,diff-type=compliant]
----
void f() {
if (complicated.expression.foo()) {
bar();
}
2024-07-10 16:04:44 +02:00
}
----
[source,dart,diff-id=3,diff-type=compliant]
----
void f() {
if (complicated.expression.foo())
bar();
else
buzz();
}
----
2024-07-10 16:04:44 +02:00
== Resources
* Dart Docs - https://dart.dev/tools/linter-rules/empty_statements[Dart Linter rule - empty_statements]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
* Unnecessary empty statement.
=== Highlighting
The `;` character.
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]