54 lines
813 B
Plaintext
54 lines
813 B
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
include::../howtofix.adoc[]
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,dart,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
class StringUtils { // Noncompliant
|
|
|
|
static String concatenate(String s1, String s2) {
|
|
return s1 + s2;
|
|
}
|
|
|
|
}
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,dart,diff-id=1,diff-type=compliant]
|
|
----
|
|
class StringUtils { // Compliant
|
|
|
|
StringUtils._() {
|
|
throw Exception('Utility class');
|
|
}
|
|
|
|
static String concatenate(String s1, String s2) {
|
|
return s1 + s2;
|
|
}
|
|
|
|
}
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Hide this public constructor.
|
|
|
|
Add a private constructor to hide the implicit public one.
|
|
|
|
'''
|
|
|
|
endif::env-github,rspecator-view[]
|