Skip to content

Commit f82847c

Browse files
enable spotbugs for db-destinations CDK submodule (#36702)
1 parent 8c4095c commit f82847c

File tree

7 files changed

+42
-54
lines changed

7 files changed

+42
-54
lines changed

airbyte-cdk/java/airbyte-cdk/db-destinations/build.gradle

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ compileKotlin.compilerOptions.allWarningsAsErrors = false
1212
compileTestFixturesKotlin.compilerOptions.allWarningsAsErrors = false
1313
compileTestKotlin.compilerOptions.allWarningsAsErrors = false
1414

15-
spotbugsTest.enabled = false
16-
spotbugsTestFixtures.enabled = false
17-
1815
dependencies {
1916
api 'org.apache.commons:commons-csv:1.10.0'
2017

airbyte-cdk/java/airbyte-cdk/db-destinations/src/testFixtures/kotlin/io/airbyte/cdk/integrations/standardtest/destination/DestinationAcceptanceTest.kt

+10-13
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ import org.slf4j.Logger
7979
import org.slf4j.LoggerFactory
8080

8181
abstract class DestinationAcceptanceTest {
82-
protected lateinit var TEST_SCHEMAS: HashSet<String>
82+
protected var TEST_SCHEMAS: HashSet<String> = HashSet()
8383

8484
private lateinit var testEnv: TestDestinationEnv
8585

@@ -1606,13 +1606,11 @@ abstract class DestinationAcceptanceTest {
16061606
val actualStateMessage =
16071607
destinationOutput
16081608
.stream()
1609-
.filter { m: io.airbyte.protocol.models.v0.AirbyteMessage? ->
1610-
m!!.type == io.airbyte.protocol.models.v0.AirbyteMessage.Type.STATE
1611-
}
1609+
.filter { it.type == Type.STATE }
16121610
.findFirst()
1613-
.map { msg: io.airbyte.protocol.models.v0.AirbyteMessage? ->
1611+
.map { msg: AirbyteMessage ->
16141612
// Modify state message to remove destination stats.
1615-
val clone = msg!!.state
1613+
val clone = msg.state
16161614
clone.destinationStats = null
16171615
msg.state = clone
16181616
msg
@@ -1628,10 +1626,10 @@ abstract class DestinationAcceptanceTest {
16281626
@Throws(Exception::class)
16291627
private fun runSync(
16301628
config: JsonNode,
1631-
messages: List<io.airbyte.protocol.models.v0.AirbyteMessage>,
1632-
catalog: io.airbyte.protocol.models.v0.ConfiguredAirbyteCatalog,
1629+
messages: List<AirbyteMessage>,
1630+
catalog: ConfiguredAirbyteCatalog,
16331631
runNormalization: Boolean
1634-
): List<io.airbyte.protocol.models.v0.AirbyteMessage?> {
1632+
): List<AirbyteMessage> {
16351633
val destinationConfig =
16361634
WorkerDestinationConfig()
16371635
.withConnectionId(UUID.randomUUID())
@@ -1664,11 +1662,10 @@ abstract class DestinationAcceptanceTest {
16641662
)
16651663
destination.notifyEndOfInput()
16661664

1667-
val destinationOutput: MutableList<io.airbyte.protocol.models.v0.AirbyteMessage?> =
1668-
ArrayList()
1665+
val destinationOutput: MutableList<AirbyteMessage> = ArrayList()
16691666
while (!destination.isFinished()) {
1670-
destination.attemptRead().ifPresent { m: io.airbyte.protocol.models.AirbyteMessage ->
1671-
destinationOutput.add(convertProtocolObject(m, AirbyteMessage::class.java))
1667+
destination.attemptRead().ifPresent {
1668+
destinationOutput.add(convertProtocolObject(it, AirbyteMessage::class.java))
16721669
}
16731670
}
16741671

airbyte-cdk/java/airbyte-cdk/db-destinations/src/testFixtures/kotlin/io/airbyte/cdk/integrations/standardtest/destination/TestingNamespaces.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ object TestingNamespaces {
4949
generateSuffix()
5050
}
5151

52-
fun generateFromOriginal(toOverwrite: String?, oldPrefix: String?, newPrefix: String?): String {
53-
return toOverwrite!!.replace(oldPrefix!!, newPrefix!!)
52+
fun generateFromOriginal(toOverwrite: String, oldPrefix: String, newPrefix: String): String {
53+
return toOverwrite.replace(oldPrefix, newPrefix)
5454
}
5555

5656
/**

airbyte-cdk/java/airbyte-cdk/db-destinations/src/testFixtures/kotlin/io/airbyte/cdk/integrations/standardtest/destination/typing_deduping/JdbcSqlGeneratorIntegrationTest.kt

+15-15
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ abstract class JdbcSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
5858
private fun insertRecords(
5959
tableName: Name,
6060
columnNames: List<String>,
61-
records: List<JsonNode>?,
61+
records: List<JsonNode>,
6262
vararg columnsToParseJson: String
6363
) {
6464
var insert =
@@ -69,7 +69,7 @@ abstract class JdbcSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
6969
.map { columnName: String? -> DSL.field(DSL.quotedName(columnName)) }
7070
.toList()
7171
)
72-
for (record in records!!) {
72+
for (record in records) {
7373
insert =
7474
insert.values(
7575
columnNames
@@ -103,10 +103,10 @@ abstract class JdbcSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
103103
}
104104

105105
@Throws(Exception::class)
106-
override fun createRawTable(streamId: StreamId?) {
106+
override fun createRawTable(streamId: StreamId) {
107107
database.execute(
108108
dslContext
109-
.createTable(DSL.name(streamId!!.rawNamespace, streamId.rawName))
109+
.createTable(DSL.name(streamId.rawNamespace, streamId.rawName))
110110
.column(COLUMN_NAME_AB_RAW_ID, SQLDataType.VARCHAR(36).nullable(false))
111111
.column(COLUMN_NAME_AB_EXTRACTED_AT, timestampWithTimeZoneType.nullable(false))
112112
.column(COLUMN_NAME_AB_LOADED_AT, timestampWithTimeZoneType)
@@ -117,10 +117,10 @@ abstract class JdbcSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
117117
}
118118

119119
@Throws(Exception::class)
120-
override fun createV1RawTable(v1RawTable: StreamId?) {
120+
override fun createV1RawTable(v1RawTable: StreamId) {
121121
database.execute(
122122
dslContext
123-
.createTable(DSL.name(v1RawTable!!.rawNamespace, v1RawTable.rawName))
123+
.createTable(DSL.name(v1RawTable.rawNamespace, v1RawTable.rawName))
124124
.column(COLUMN_NAME_AB_ID, SQLDataType.VARCHAR(36).nullable(false))
125125
.column(COLUMN_NAME_EMITTED_AT, timestampWithTimeZoneType.nullable(false))
126126
.column(COLUMN_NAME_DATA, structType.nullable(false))
@@ -129,9 +129,9 @@ abstract class JdbcSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
129129
}
130130

131131
@Throws(Exception::class)
132-
public override fun insertRawTableRecords(streamId: StreamId?, records: List<JsonNode>?) {
132+
public override fun insertRawTableRecords(streamId: StreamId, records: List<JsonNode>) {
133133
insertRecords(
134-
DSL.name(streamId!!.rawNamespace, streamId.rawName),
134+
DSL.name(streamId.rawNamespace, streamId.rawName),
135135
JavaBaseConstants.V2_RAW_TABLE_COLUMN_NAMES,
136136
records,
137137
COLUMN_NAME_DATA,
@@ -140,9 +140,9 @@ abstract class JdbcSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
140140
}
141141

142142
@Throws(Exception::class)
143-
override fun insertV1RawTableRecords(streamId: StreamId?, records: List<JsonNode>?) {
143+
override fun insertV1RawTableRecords(streamId: StreamId, records: List<JsonNode>) {
144144
insertRecords(
145-
DSL.name(streamId!!.rawNamespace, streamId.rawName),
145+
DSL.name(streamId.rawNamespace, streamId.rawName),
146146
LEGACY_RAW_TABLE_COLUMNS,
147147
records,
148148
COLUMN_NAME_DATA
@@ -152,14 +152,14 @@ abstract class JdbcSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
152152
@Throws(Exception::class)
153153
override fun insertFinalTableRecords(
154154
includeCdcDeletedAt: Boolean,
155-
streamId: StreamId?,
155+
streamId: StreamId,
156156
suffix: String?,
157-
records: List<JsonNode>?
157+
records: List<JsonNode>
158158
) {
159159
val columnNames =
160160
if (includeCdcDeletedAt) FINAL_TABLE_COLUMN_NAMES_CDC else FINAL_TABLE_COLUMN_NAMES
161161
insertRecords(
162-
DSL.name(streamId!!.finalNamespace, streamId.finalName + suffix),
162+
DSL.name(streamId.finalNamespace, streamId.finalName + suffix),
163163
columnNames,
164164
records,
165165
COLUMN_NAME_AB_META,
@@ -170,7 +170,7 @@ abstract class JdbcSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
170170
}
171171

172172
@Throws(Exception::class)
173-
override fun dumpRawTableRecords(streamId: StreamId?): List<JsonNode> {
173+
override fun dumpRawTableRecords(streamId: StreamId): List<JsonNode> {
174174
return database.queryJsons(
175175
dslContext
176176
.selectFrom(DSL.name(streamId!!.rawNamespace, streamId.rawName))
@@ -179,7 +179,7 @@ abstract class JdbcSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
179179
}
180180

181181
@Throws(Exception::class)
182-
override fun dumpFinalTableRecords(streamId: StreamId?, suffix: String?): List<JsonNode> {
182+
override fun dumpFinalTableRecords(streamId: StreamId, suffix: String?): List<JsonNode> {
183183
return database.queryJsons(
184184
dslContext
185185
.selectFrom(DSL.name(streamId!!.finalNamespace, streamId.finalName + suffix))

airbyte-cdk/java/airbyte-cdk/db-destinations/src/testFixtures/kotlin/io/airbyte/cdk/integrations/standardtest/destination/typing_deduping/JdbcTypingDedupingTest.kt

+4-10
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,13 @@ abstract class JdbcTypingDedupingTest : BaseTypingDedupingTest() {
7676
}
7777

7878
@Throws(Exception::class)
79-
override fun dumpRawTableRecords(
80-
streamNamespace: String?,
81-
streamName: String?
82-
): List<JsonNode> {
79+
override fun dumpRawTableRecords(streamNamespace: String?, streamName: String): List<JsonNode> {
8380
var streamNamespace = streamNamespace
8481
if (streamNamespace == null) {
8582
streamNamespace = getDefaultSchema(config!!)
8683
}
8784
val tableName =
88-
concatenateRawTableName(
89-
streamNamespace,
90-
Names.toAlphanumericAndUnderscore(streamName!!)
91-
)
85+
concatenateRawTableName(streamNamespace, Names.toAlphanumericAndUnderscore(streamName))
9286
val schema = rawSchema
9387
return database!!.queryJsons(DSL.selectFrom(DSL.name(schema, tableName)).sql)
9488
}
@@ -109,14 +103,14 @@ abstract class JdbcTypingDedupingTest : BaseTypingDedupingTest() {
109103
}
110104

111105
@Throws(Exception::class)
112-
override fun teardownStreamAndNamespace(streamNamespace: String?, streamName: String?) {
106+
override fun teardownStreamAndNamespace(streamNamespace: String?, streamName: String) {
113107
var streamNamespace = streamNamespace
114108
if (streamNamespace == null) {
115109
streamNamespace = getDefaultSchema(config!!)
116110
}
117111
database!!.execute(
118112
DSL.dropTableIfExists(
119-
DSL.name(rawSchema, concatenateRawTableName(streamNamespace, streamName!!))
113+
DSL.name(rawSchema, concatenateRawTableName(streamNamespace, streamName))
120114
)
121115
.sql
122116
)

airbyte-cdk/java/airbyte-cdk/typing-deduping/src/testFixtures/kotlin/io/airbyte/integrations/base/destination/typing_deduping/BaseSqlGeneratorIntegrationTest.kt

+9-9
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,23 @@ abstract class BaseSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
9696
@Throws(Exception::class) protected abstract fun createNamespace(namespace: String?)
9797

9898
/** Create a raw table using the StreamId's rawTableId. */
99-
@Throws(Exception::class) protected abstract fun createRawTable(streamId: StreamId?)
99+
@Throws(Exception::class) protected abstract fun createRawTable(streamId: StreamId)
100100

101101
/** Creates a raw table in the v1 format */
102-
@Throws(Exception::class) protected abstract fun createV1RawTable(v1RawTable: StreamId?)
102+
@Throws(Exception::class) protected abstract fun createV1RawTable(v1RawTable: StreamId)
103103

104104
@Throws(Exception::class)
105-
protected abstract fun insertRawTableRecords(streamId: StreamId?, records: List<JsonNode>?)
105+
protected abstract fun insertRawTableRecords(streamId: StreamId, records: List<JsonNode>)
106106

107107
@Throws(Exception::class)
108-
protected abstract fun insertV1RawTableRecords(streamId: StreamId?, records: List<JsonNode>?)
108+
protected abstract fun insertV1RawTableRecords(streamId: StreamId, records: List<JsonNode>)
109109

110110
@Throws(Exception::class)
111111
protected abstract fun insertFinalTableRecords(
112112
includeCdcDeletedAt: Boolean,
113-
streamId: StreamId?,
113+
streamId: StreamId,
114114
suffix: String?,
115-
records: List<JsonNode>?
115+
records: List<JsonNode>
116116
)
117117

118118
/**
@@ -125,11 +125,11 @@ abstract class BaseSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
125125
* destination as a string.
126126
*/
127127
@Throws(Exception::class)
128-
protected abstract fun dumpRawTableRecords(streamId: StreamId?): List<JsonNode>
128+
protected abstract fun dumpRawTableRecords(streamId: StreamId): List<JsonNode>
129129

130130
@Throws(Exception::class)
131131
protected abstract fun dumpFinalTableRecords(
132-
streamId: StreamId?,
132+
streamId: StreamId,
133133
suffix: String?
134134
): List<JsonNode>
135135

@@ -1574,7 +1574,7 @@ abstract class BaseSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
15741574
}
15751575

15761576
@Throws(Exception::class)
1577-
protected fun dumpV1RawTableRecords(streamId: StreamId?): List<JsonNode> {
1577+
protected fun dumpV1RawTableRecords(streamId: StreamId): List<JsonNode> {
15781578
return dumpRawTableRecords(streamId)
15791579
}
15801580

airbyte-cdk/java/airbyte-cdk/typing-deduping/src/testFixtures/kotlin/io/airbyte/integrations/base/destination/typing_deduping/BaseTypingDedupingTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ abstract class BaseTypingDedupingTest {
9090
@Throws(Exception::class)
9191
protected abstract fun dumpRawTableRecords(
9292
streamNamespace: String?,
93-
streamName: String?
93+
streamName: String
9494
): List<JsonNode>
9595

9696
/**
@@ -136,7 +136,7 @@ abstract class BaseTypingDedupingTest {
136136
* airbyte.<streamNamespace>_<streamName>; DROP SCHEMA IF EXISTS <streamNamespace>`.
137137
*/
138138
@Throws(Exception::class)
139-
protected abstract fun teardownStreamAndNamespace(streamNamespace: String?, streamName: String?)
139+
protected abstract fun teardownStreamAndNamespace(streamNamespace: String?, streamName: String)
140140

141141
protected abstract val sqlGenerator: SqlGenerator
142142
get

0 commit comments

Comments
 (0)