Skip to content

Commit 1ce3617

Browse files
authored
Reduce warnings during build, in IDE and in GitHub UI (#501)
1 parent a6719ad commit 1ce3617

File tree

26 files changed

+70
-83
lines changed

26 files changed

+70
-83
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
# SINGLE-JOB
2424
#
2525
verify:
26-
runs-on: ubuntu-latest
26+
runs-on: ubuntu-latest
2727
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
2828

2929
steps:
@@ -44,7 +44,7 @@ jobs:
4444
#
4545
build:
4646
needs: [verify]
47-
runs-on: ubuntu-latest
47+
runs-on: ubuntu-latest
4848

4949
# Definition of the build matrix
5050
strategy:
@@ -56,20 +56,20 @@ jobs:
5656

5757
steps:
5858

59-
- name: 1. Check out code
60-
uses: actions/checkout@v2 # https://github.com/actions/checkout
59+
- name: 1. Check out code
60+
uses: actions/checkout@v2 # https://github.com/actions/checkout
6161

62-
- name: 2. Set up Java 11
63-
uses: actions/setup-java@v1 # https://github.com/actions/setup-java
64-
with:
65-
java-version: 11
62+
- name: 2. Set up Java 11
63+
uses: actions/setup-java@v1 # https://github.com/actions/setup-java
64+
with:
65+
java-version: 11
6666

67-
- name: 3. Build with Kotlin ${{ matrix.kotlin }} and mock-maker ${{ matrix.mock-maker }}
68-
run: |
69-
ops/mockMakerInline.sh
70-
./gradlew build -PtestKotlinVersion=${{ matrix.kotlin }}
71-
env:
72-
MOCK_MAKER: ${{ matrix.mock-maker }}
67+
- name: 3. Build with Kotlin ${{ matrix.kotlin }} and mock-maker ${{ matrix.mock-maker }}
68+
run: |
69+
ops/mockMakerInline.sh
70+
./gradlew build -PtestKotlinVersion=${{ matrix.kotlin }}
71+
env:
72+
MOCK_MAKER: ${{ matrix.mock-maker }}
7373

7474
#
7575
# Release job, only for pushes to the main development branch
@@ -85,21 +85,21 @@ jobs:
8585

8686
steps:
8787

88-
- name: Check out code
89-
uses: actions/checkout@v2 # https://github.com/actions/checkout
90-
with:
91-
fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci
92-
93-
- name: Set up Java 11
94-
uses: actions/setup-java@v1
95-
with:
96-
java-version: 11
97-
98-
- name: Build and release
99-
run: ./gradlew githubRelease publishToSonatype closeAndReleaseStagingRepository releaseSummary
100-
env:
101-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
102-
NEXUS_TOKEN_USER: ${{secrets.NEXUS_TOKEN_USER}}
103-
NEXUS_TOKEN_PWD: ${{secrets.NEXUS_TOKEN_PWD}}
104-
PGP_KEY: ${{secrets.PGP_KEY}}
105-
PGP_PWD: ${{secrets.PGP_PWD}}
88+
- name: Check out code
89+
uses: actions/checkout@v2 # https://github.com/actions/checkout
90+
with:
91+
fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci
92+
93+
- name: Set up Java 11
94+
uses: actions/setup-java@v1
95+
with:
96+
java-version: 11
97+
98+
- name: Build and release
99+
run: ./gradlew githubRelease publishToSonatype closeAndReleaseStagingRepository releaseSummary
100+
env:
101+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
102+
NEXUS_TOKEN_USER: ${{secrets.NEXUS_TOKEN_USER}}
103+
NEXUS_TOKEN_PWD: ${{secrets.NEXUS_TOKEN_PWD}}
104+
PGP_KEY: ${{secrets.PGP_KEY}}
105+
PGP_PWD: ${{secrets.PGP_PWD}}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Mockito-Kotlin
2+
23
[ ![Download](https://maven-badges.herokuapp.com/maven-central/org.mockito.kotlin/mockito-kotlin/badge.svg) ](https://maven-badges.herokuapp.com/maven-central/org.mockito.kotlin/mockito-kotlin)
34
[![Nexus Snapshot](https://img.shields.io/nexus/s/org.mockito.kotlin/mockito-kotlin?server=https%3A%2F%2Fs01.oss.sonatype.org%2F)](https://s01.oss.sonatype.org/content/repositories/snapshots/org/mockito/kotlin/mockito-kotlin/)
45

@@ -56,7 +57,7 @@ keeping the base module at a recent version.
5657

5758
- `./gradlew check` runs the checks including tests.
5859

59-
Usually it is enough to test only using the default Kotlin versions;
60+
Usually it is enough to test only using the default Kotlin versions;
6061
CI will test against multiple versions.
6162
If you want to test using a different Kotlin version locally,
6263
add the `-PtestKotlinVersion=1.2.3` argument to the Gradle invocation while running the tests.

mockito-kotlin/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ dependencies {
2222
testImplementation 'junit:junit:4.13.2'
2323
testImplementation 'com.nhaarman:expect.kt:1.0.1'
2424

25-
testImplementation "org.jetbrains.kotlin:kotlin-stdlib"
26-
testImplementation "org.jetbrains.kotlin:kotlin-test"
25+
testImplementation "org.jetbrains.kotlin:kotlin-stdlib"
26+
testImplementation "org.jetbrains.kotlin:kotlin-test"
2727
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0'
2828

2929
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0"

mockito-kotlin/src/main/kotlin/org/mockito/kotlin/ArgumentCaptor.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ class ArgumentCaptorHolder5<out A, out B, out C, out D, out E>(
9393
operator fun component5() = fifth
9494
}
9595

96-
9796
/**
9897
* Creates 4 [KArgumentCaptor]s for given types.
9998
*/

mockito-kotlin/src/main/kotlin/org/mockito/kotlin/KInOrder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ package org.mockito.kotlin
2828
import org.mockito.InOrder
2929
import org.mockito.verification.VerificationMode
3030

31-
interface KInOrder: InOrder {
31+
interface KInOrder : InOrder {
3232
/**
3333
* Verifies certain suspending behavior <b>happened once</b> in order.
3434
*

mockito-kotlin/src/main/kotlin/org/mockito/kotlin/KStubbing.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import org.mockito.stubbing.OngoingStubbing
3333
import org.mockito.stubbing.Stubber
3434
import kotlin.reflect.KClass
3535

36-
3736
inline fun <T : Any> stubbing(
3837
mock: T,
3938
stubbing: KStubbing<T>.(T) -> Unit
@@ -47,7 +46,7 @@ inline fun <T : Any> T.stub(stubbing: KStubbing<T>.(T) -> Unit): T {
4746

4847
class KStubbing<out T : Any>(val mock: T) {
4948
init {
50-
if(!mockingDetails(mock).isMock) throw NotAMockException("Stubbing target is not a mock!")
49+
if (!mockingDetails(mock).isMock) throw NotAMockException("Stubbing target is not a mock!")
5150
}
5251

5352
fun <R> on(methodCall: R): OngoingStubbing<R> = Mockito.`when`(methodCall)
@@ -90,4 +89,4 @@ class KStubbing<out T : Any>(val mock: T) {
9089
fun Stubber.on(methodCall: T.() -> Unit) {
9190
this.`when`(mock).methodCall()
9291
}
93-
}
92+
}

mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Matchers.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ inline fun <reified T : Any> anyVararg(): T {
5656
}
5757

5858
fun <T : Any> anyVararg(clazz: KClass<T>): T {
59-
return ArgumentMatchers.argThat(VarargMatcher(clazz.java))?: createInstance(clazz)
59+
return ArgumentMatchers.argThat(VarargMatcher(clazz.java)) ?: createInstance(clazz)
6060
}
6161

62-
private class VarargMatcher<T>(private val clazz: Class<T>) : ArgumentMatcher<T>{
62+
private class VarargMatcher<T>(private val clazz: Class<T>) : ArgumentMatcher<T> {
6363
override fun matches(t: T): Boolean = true
6464

6565
// In Java >= 12 you can do clazz.arrayClass()
@@ -148,4 +148,3 @@ fun <T : Any> notNull(): T? {
148148
inline fun <reified T : Any> refEq(value: T, vararg excludeFields: String): T {
149149
return ArgumentMatchers.refEq<T>(value, *excludeFields) ?: createInstance()
150150
}
151-

mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Mocking.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import org.mockito.MockSettings
3030
import org.mockito.Mockito
3131
import org.mockito.listeners.InvocationListener
3232
import org.mockito.mock.SerializableMode
33+
import org.mockito.quality.Strictness
3334
import org.mockito.stubbing.Answer
3435
import kotlin.DeprecationLevel.ERROR
3536
import kotlin.reflect.KClass
@@ -175,7 +176,7 @@ fun withSettings(
175176
if (stubOnly) stubOnly()
176177
useConstructor?.let { useConstructor(*it.args) }
177178
outerInstance?.let { outerInstance(it) }
178-
if (lenient) lenient()
179+
if (lenient) strictness(Strictness.LENIENT)
179180
}
180181

181182
class UseConstructor private constructor(val args: Array<Any>) {

mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Mockito.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ fun <T> reset(vararg mocks: T) {
3838

3939
fun mockingDetails(toInspect: Any): MockingDetails {
4040
return Mockito.mockingDetails(toInspect)!!
41-
}
41+
}

mockito-kotlin/src/main/kotlin/org/mockito/kotlin/OngoingStubbing.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import org.mockito.stubbing.Answer
3434
import org.mockito.stubbing.OngoingStubbing
3535
import kotlin.reflect.KClass
3636

37-
3837
/**
3938
* Enables stubbing methods. Use it when you want the mock to return particular value when particular method is called.
4039
*

0 commit comments

Comments
 (0)