rspec/rules/S1192/go/rule.adoc
2023-10-11 11:41:24 +02:00

56 lines
1.1 KiB
Plaintext

== Why is this an issue?
include::../description.adoc[]
=== Exceptions
To prevent generating some false-positives, literals having 5 or less characters are excluded as well as literals containing only letters, digits and '_'.
== How to fix it
include::../howtofix.adoc[]
=== Code examples
==== Noncompliant code example
With the default threshold of 3:
[source,go,diff-id=1,diff-type=noncompliant]
----
func run() {
prepare("This should be a constant") // Noncompliant; 'This should ...' is duplicated 3 times
execute("This should be a constant")
release("This should be a constant")
}
----
==== Compliant solution
[source,go,diff-id=1,diff-type=compliant]
----
const ACTION = "This should be a constant"
func run() {
prepare(ACTION)
execute(ACTION)
release(ACTION)
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../parameters.adoc[]
include::../highlighting.adoc[]
'''
endif::env-github,rspecator-view[]