
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
82 lines
1.5 KiB
Plaintext
82 lines
1.5 KiB
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,csharp]
|
|
----
|
|
public class Foo
|
|
{
|
|
private string name = "foobar"; // Noncompliant
|
|
|
|
public string DefaultName { get; } = "foobar"; // Noncompliant
|
|
|
|
public Foo(string value = "foobar") // Noncompliant
|
|
{
|
|
var something = value ?? "foobar"; // Noncompliant
|
|
}
|
|
}
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,csharp]
|
|
----
|
|
public class Foo
|
|
{
|
|
private const string Foobar = "foobar";
|
|
|
|
private string name = Foobar;
|
|
|
|
public string DefaultName { get; } = Foobar;
|
|
|
|
public Foo(string value = Foobar)
|
|
{
|
|
var something = value ?? Foobar;
|
|
}
|
|
}
|
|
----
|
|
|
|
=== Exceptions
|
|
|
|
The following are ignored:
|
|
|
|
* literals with fewer than 5 characters
|
|
* literals matching one of the parameter names
|
|
* literals used in attributes
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Define a constant instead of using the literal "{string}" {number} times.
|
|
|
|
|
|
include::../parameters.adoc[]
|
|
|
|
=== Highlighting
|
|
|
|
primary: the class
|
|
|
|
secondaries: all instances of the string literal
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 21 Mar 2018, 15:11:26 Amaury Levé wrote:
|
|
Could you review this sub-task please?
|
|
|
|
=== on 21 Mar 2018, 15:33:08 Ann Campbell wrote:
|
|
I think a brief code example would be helpful for the second item, [~amaury.leve].
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|