
Improvement identified in #2790. Add a prefix to the diff-id when it is used multiple times in different "how to fix it in XYZ" sections to avoid ambiguity and pedantically follow the spec: > A single and unique diff-id should be used only once for each type of code example as shown in the description of a rule. Obvious typos around `diff-id` were fixed.
36 lines
721 B
Plaintext
36 lines
721 B
Plaintext
== How to fix it in OkHttp
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,kotlin,diff-id=11,diff-type=noncompliant]
|
|
----
|
|
import okhttp3.ConnectionSpec;
|
|
import okhttp3.TlsVersion;
|
|
|
|
fun main(args: Array<String>) {
|
|
ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
|
|
.tlsVersions(TlsVersion.TLS_1_1) // Noncompliant
|
|
.build();
|
|
}
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,kotlin,diff-id=11,diff-type=compliant]
|
|
----
|
|
import okhttp3.ConnectionSpec;
|
|
import okhttp3.TlsVersion;
|
|
|
|
fun main(args: Array<String>) {
|
|
ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
|
|
.tlsVersions(TlsVersion.TLS_1_2)
|
|
.build();
|
|
}
|
|
----
|
|
|
|
=== How does this work?
|
|
|
|
include::../../common/fix/fix.adoc[]
|