30 lines
547 B
Plaintext
30 lines
547 B
Plaintext
[source,ruby,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
if a >= 0 && a < 10
|
|
doFirstThing()
|
|
doTheThing()
|
|
elsif a >= 10 && a < 20
|
|
doTheOtherThing()
|
|
elsif a >= 20 && a < 50
|
|
doFirstThing()
|
|
doTheThing() # Noncompliant; duplicates first condition
|
|
else
|
|
doTheRest()
|
|
end
|
|
----
|
|
|
|
[source,ruby,diff-id=2,diff-type=noncompliant]
|
|
----
|
|
case i
|
|
when 1
|
|
doFirstThing()
|
|
doSomething()
|
|
when 2
|
|
doSomethingDifferent()
|
|
when 3 # Noncompliant; duplicates case 1's implementation
|
|
doFirstThing()
|
|
doSomething()
|
|
else
|
|
doTheRest()
|
|
end
|
|
---- |