68 lines
1.2 KiB
Plaintext
68 lines
1.2 KiB
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
=== Exceptions
|
|
|
|
No issue will be raised on:
|
|
|
|
* duplicated string in decorators
|
|
* strings with less than 5 characters
|
|
* strings with only letters, numbers and underscores
|
|
|
|
|
|
== How to fix it
|
|
|
|
include::../howtofix.adoc[]
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
With the default threshold of 3:
|
|
|
|
[source,python,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
def run():
|
|
prepare("action1") # Noncompliant - "action1" is duplicated 3 times
|
|
execute("action1")
|
|
release("action1")
|
|
|
|
@app.route("/api/users/", methods=['GET', 'POST', 'PUT'])
|
|
def users():
|
|
pass
|
|
|
|
@app.route("/api/projects/", methods=['GET', 'POST', 'PUT']) # Compliant - strings inside decorators are ignored
|
|
def projects():
|
|
pass
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,python,diff-id=1,diff-type=compliant]
|
|
----
|
|
ACTION_1 = "action1"
|
|
|
|
def run():
|
|
prepare(ACTION_1)
|
|
execute(ACTION_1)
|
|
release(ACTION_1)
|
|
----
|
|
|
|
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[]
|