Make location history dao suspensible (#5552)

* Adjust CoroutineDaoFunctionsIssue to support PagingSource

---------

Co-authored-by: Daniel Shokouhi <dshokouhi@gmail.com>
This commit is contained in:
Timothy
2025-07-17 08:18:49 +02:00
committed by GitHub
parent 00ef90ec15
commit fbe3afadbd
6 changed files with 428 additions and 480 deletions

View File

@ -8,7 +8,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/full/kotlin/io/homeassistant/companion/android/sensors/ActivitySensorManager.kt"
line="228"
line="231"
column="13"/>
</issue>
@ -19,7 +19,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/full/kotlin/io/homeassistant/companion/android/sensors/ActivitySensorManager.kt"
line="233"
line="236"
column="17"/>
</issue>
@ -30,7 +30,7 @@
errorLine2=" ^">
<location
file="src/full/kotlin/io/homeassistant/companion/android/sensors/ActivitySensorManager.kt"
line="251"
line="256"
column="25"/>
</issue>
@ -41,7 +41,7 @@
errorLine2=" ^">
<location
file="src/full/kotlin/io/homeassistant/companion/android/sensors/ActivitySensorManager.kt"
line="259"
line="264"
column="25"/>
</issue>
@ -52,7 +52,7 @@
errorLine2=" ^">
<location
file="src/full/kotlin/io/homeassistant/companion/android/sensors/ActivitySensorManager.kt"
line="267"
line="272"
column="25"/>
</issue>
@ -63,7 +63,7 @@
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/util/DataUriDownloadManager.kt"
line="69"
line="64"
column="9"/>
</issue>
@ -85,7 +85,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt"
line="994"
line="1104"
column="17"/>
</issue>
@ -140,7 +140,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/util/ForegroundServiceLauncher.kt"
line="48"
line="52"
column="33"/>
</issue>
@ -433,7 +433,7 @@
<issue
id="CustomSplashScreen"
message="The application should not provide its own launch screen"
errorLine1="class LaunchActivity : AppCompatActivity(), LaunchView {"
errorLine1="class LaunchActivity :"
errorLine2=" ~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/launch/LaunchActivity.kt"
@ -470,7 +470,7 @@
errorLine2=" ~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/settings/sensor/SensorDetailViewModel.kt"
line="332"
line="337"
column="38"/>
</issue>
@ -613,7 +613,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/sensors/CarSensorManager.kt"
line="262"
line="268"
column="20"/>
</issue>
@ -624,7 +624,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/sensors/CarSensorManager.kt"
line="273"
line="279"
column="33"/>
</issue>
@ -635,7 +635,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/sensors/CarSensorManager.kt"
line="303"
line="309"
column="13"/>
</issue>
@ -646,7 +646,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/settings/SettingsFragment.kt"
line="500"
line="523"
column="17"/>
</issue>
@ -657,7 +657,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/settings/SettingsFragment.kt"
line="500"
line="523"
column="17"/>
</issue>
@ -767,7 +767,7 @@
errorLine2=" ~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/widgets/assist/AssistShortcutViewModel.kt"
line="21"
line="19"
column="21"/>
</issue>
@ -778,7 +778,7 @@
errorLine2=" ~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/settings/shortcuts/ManageShortcutsViewModel.kt"
line="116"
line="117"
column="21"/>
</issue>
@ -1055,19 +1055,19 @@
errorLine2=" ~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/widgets/button/ButtonWidget.kt"
line="299"
line="307"
column="25"/>
</issue>
<issue
id="AvoidAnySerializer"
message="Prefer polymorphic serializer over AnySerializer."
errorLine1=" val dbMap: Map&lt;String, Any?> = kotlinJsonMapper.decodeFromString(MapAnySerializer, buttonWidget.serviceData)"
errorLine2=" ~~~~~~~~~~~~~~~~">
errorLine1=" MapAnySerializer,"
errorLine2=" ~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/widgets/button/ButtonWidgetConfigureActivity.kt"
line="150"
column="90"/>
line="157"
column="29"/>
</issue>
<issue
@ -1077,7 +1077,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/widgets/button/ButtonWidgetConfigureActivity.kt"
line="464"
line="491"
column="49"/>
</issue>
@ -1088,7 +1088,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/settings/shortcuts/ManageShortcutsViewModel.kt"
line="156"
line="166"
column="13"/>
</issue>
@ -1099,7 +1099,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/barcode/BarcodeScannerActivity.kt"
line="144"
line="138"
column="80"/>
</issue>
@ -1121,7 +1121,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/full/kotlin/io/homeassistant/companion/android/settings/sensor/HealthConnectPermissionActivity.kt"
line="15"
line="18"
column="40"/>
</issue>
@ -1132,7 +1132,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/settings/developer/location/views/LocationTrackingView.kt"
line="238"
line="248"
column="45"/>
</issue>
@ -1143,7 +1143,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/vehicle/MapVehicleScreen.kt"
line="131"
line="134"
column="33"/>
</issue>
@ -1154,7 +1154,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt"
line="1453"
line="1539"
column="16"/>
</issue>
@ -1165,7 +1165,7 @@
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt"
line="1583"
line="1669"
column="33"/>
</issue>
@ -1176,30 +1176,30 @@
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt"
line="1583"
line="1669"
column="33"/>
</issue>
<issue
id="UseKtx"
message="Use the KTX extension function `String.toUri` instead?"
errorLine1=" marketIntent.data = Uri.parse(MARKET_PREFIX + if (uri.startsWith(INTENT_PREFIX)) intent.`package`.toString() else uri.removePrefix(APP_PREFIX))"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
errorLine1=" Uri.parse("
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt"
line="1618"
column="41"/>
line="1706"
column="25"/>
</issue>
<issue
id="UseKtx"
message="Use the KTX extension function `String.toUri` instead?"
errorLine1=" marketIntent.data = Uri.parse(MARKET_PREFIX + if (uri.startsWith(INTENT_PREFIX)) intent.`package`.toString() else uri.removePrefix(APP_PREFIX))"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
errorLine1=" Uri.parse("
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt"
line="1618"
column="41"/>
line="1706"
column="25"/>
</issue>
<issue
@ -1209,7 +1209,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt"
line="1658"
line="1753"
column="13"/>
</issue>
@ -1220,7 +1220,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt"
line="1674"
line="1769"
column="13"/>
</issue>
@ -1231,7 +1231,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt"
line="1683"
line="1778"
column="23"/>
</issue>
@ -1242,7 +1242,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt"
line="1683"
line="1778"
column="23"/>
</issue>
@ -1253,7 +1253,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt"
line="1801"
line="1901"
column="68"/>
</issue>
@ -1264,7 +1264,7 @@
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt"
line="1870"
line="1967"
column="37"/>
</issue>
@ -1275,7 +1275,7 @@
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt"
line="1870"
line="1967"
column="37"/>
</issue>
@ -1286,7 +1286,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationFragment.kt"
line="174"
line="171"
column="21"/>
</issue>
@ -1297,30 +1297,30 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/onboarding/integration/MobileAppIntegrationFragment.kt"
line="201"
line="198"
column="49"/>
</issue>
<issue
id="UseKtx"
message="Use the KTX extension function `String.toUri` instead?"
errorLine1=" val intent = Intent(Intent.ACTION_VIEW, Uri.parse(&quot;https://companion.home-assistant.io/docs/integrations/universal-links&quot;))"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
errorLine1=" Uri.parse(&quot;https://companion.home-assistant.io/docs/integrations/universal-links&quot;),"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/nfc/views/NfcNavigationView.kt"
line="96"
column="65"/>
line="95"
column="33"/>
</issue>
<issue
id="UseKtx"
message="Use the KTX extension function `String.toUri` instead?"
errorLine1=" context.startActivity(Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse(&quot;package:${context.packageName}&quot;)))"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
errorLine1=" Uri.parse(&quot;package:${context.packageName}&quot;),"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/settings/sensor/views/SensorDetailView.kt"
line="122"
column="104"/>
line="126"
column="37"/>
</issue>
<issue
@ -1330,7 +1330,7 @@
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/settings/SettingsFragment.kt"
line="319"
line="336"
column="52"/>
</issue>
@ -1341,7 +1341,7 @@
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/settings/SettingsFragment.kt"
line="319"
line="336"
column="52"/>
</issue>
@ -1352,7 +1352,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/settings/SettingsFragment.kt"
line="340"
line="357"
column="52"/>
</issue>
@ -1363,7 +1363,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/settings/SettingsFragment.kt"
line="340"
line="357"
column="52"/>
</issue>
@ -1374,7 +1374,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/settings/SettingsFragment.kt"
line="533"
line="556"
column="21"/>
</issue>
@ -1385,7 +1385,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/full/kotlin/io/homeassistant/companion/android/settings/wear/SettingsWearActivity.kt"
line="203"
line="209"
column="22"/>
</issue>
@ -1396,7 +1396,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/full/kotlin/io/homeassistant/companion/android/settings/wear/views/SettingsWearHomeView.kt"
line="125"
line="121"
column="61"/>
</issue>
@ -1407,7 +1407,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/webview/WebViewPresenterImpl.kt"
line="131"
line="139"
column="27"/>
</issue>
@ -1418,21 +1418,10 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/webview/WebViewPresenterImpl.kt"
line="380"
line="411"
column="13"/>
</issue>
<issue
id="UseKtx"
message="Use the KTX extension function `String.toUri` instead?"
errorLine1=" Uri.parse(&quot;package:${activity?.packageName}&quot;),"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/settings/websocket/WebsocketSettingFragment.kt"
line="77"
column="41"/>
</issue>
<issue
id="ContentDescription"
message="Missing `contentDescription` attribute on image"
@ -1462,7 +1451,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/widgets/entity/EntityWidgetConfigureActivity.kt"
line="141"
line="148"
column="38"/>
</issue>
@ -1473,7 +1462,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/widgets/template/TemplateWidgetConfigureActivity.kt"
line="97"
line="99"
column="38"/>
</issue>

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Insert"
errorLine2=" ^">
<location
@ -14,7 +14,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Update"
errorLine2=" ^">
<location
@ -25,7 +25,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;SELECT * from authentication_list WHERE Host = :key&quot;)"
errorLine2=" ^">
<location
@ -36,7 +36,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;SELECT * FROM button_widgets WHERE id = :id&quot;)"
errorLine2=" ^">
<location
@ -47,7 +47,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;DELETE FROM camera_tiles where id = :id&quot;)"
errorLine2=" ^">
<location
@ -58,7 +58,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;SELECT * FROM camera_widgets WHERE id = :id&quot;)"
errorLine2=" ^">
<location
@ -69,7 +69,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;SELECT * FROM favorite_cache where id = :id&quot;)"
errorLine2=" ^">
<location
@ -80,7 +80,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;SELECT * FROM favorite_cache ORDER BY id ASC&quot;)"
errorLine2=" ^">
<location
@ -91,7 +91,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Insert(onConflict = OnConflictStrategy.REPLACE)"
errorLine2=" ^">
<location
@ -102,7 +102,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;DELETE FROM favorite_cache where id = :id&quot;)"
errorLine2=" ^">
<location
@ -113,7 +113,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;DELETE FROM favorite_cache&quot;)"
errorLine2=" ^">
<location
@ -124,40 +124,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
errorLine1=" @Insert(onConflict = OnConflictStrategy.REPLACE)"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/location/LocationHistoryDao.kt"
line="12"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
errorLine1=" @Query(&quot;SELECT * FROM location_history ORDER BY id DESC&quot;)"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/location/LocationHistoryDao.kt"
line="15"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
errorLine1=" @Query(&quot;SELECT * FROM location_history WHERE result IN (:results) ORDER BY id DESC&quot;)"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/location/LocationHistoryDao.kt"
line="18"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;SELECT * FROM media_player_controls_widgets WHERE id = :id&quot;)"
errorLine2=" ^">
<location
@ -168,7 +135,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Insert(onConflict = OnConflictStrategy.REPLACE)"
errorLine2=" ^">
<location
@ -179,7 +146,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;SELECT * FROM notification_history WHERE id = :id&quot;)"
errorLine2=" ^">
<location
@ -190,7 +157,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;SELECT * FROM notification_history ORDER BY received DESC&quot;)"
errorLine2=" ^">
<location
@ -201,7 +168,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;SELECT * FROM notification_history ORDER BY received DESC LIMIT (:amount)&quot;)"
errorLine2=" ^">
<location
@ -212,7 +179,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;SELECT * FROM Sensors WHERE id = :id&quot;)"
errorLine2=" ^">
<location
@ -223,7 +190,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;SELECT * FROM Sensors WHERE id = :id AND server_id = :serverId&quot;)"
errorLine2=" ^">
<location
@ -234,7 +201,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Transaction"
errorLine2=" ^">
<location
@ -245,53 +212,31 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Transaction"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
line="30"
line="32"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Transaction"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
line="44"
line="50"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Insert(onConflict = OnConflictStrategy.IGNORE)"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
line="52"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
errorLine1=" @Insert(onConflict = OnConflictStrategy.REPLACE)"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
line="55"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
errorLine1=" @Insert(onConflict = OnConflictStrategy.REPLACE)"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
line="58"
@ -300,7 +245,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Insert(onConflict = OnConflictStrategy.REPLACE)"
errorLine2=" ^">
<location
@ -311,31 +256,31 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Insert(onConflict = OnConflictStrategy.REPLACE)"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
line="64"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Insert(onConflict = OnConflictStrategy.REPLACE)"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
line="67"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;DELETE FROM sensor_settings WHERE sensor_id = :sensorId AND name = :settingName&quot;)"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
line="81"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
errorLine1=" @Query(&quot;DELETE FROM sensor_settings WHERE sensor_id = :sensorId AND name IN (:settingNames)&quot;)"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
line="84"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
errorLine1=" @Update"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
line="87"
@ -344,8 +289,8 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
errorLine1=" @Query(&quot;DELETE FROM sensor_attributes WHERE sensor_id = :sensorId&quot;)"
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;DELETE FROM sensor_settings WHERE sensor_id = :sensorId AND name IN (:settingNames)&quot;)"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
@ -355,8 +300,8 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
errorLine1=" @Transaction"
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Update"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
@ -366,40 +311,62 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;DELETE FROM sensor_attributes WHERE sensor_id = :sensorId&quot;)"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
line="96"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Transaction"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
line="99"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;UPDATE sensor_settings SET value = :value WHERE sensor_id = :sensorId AND name = :settingName&quot;)"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
line="102"
line="108"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Transaction"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
line="137"
line="145"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Transaction"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/sensor/SensorDao.kt"
line="150"
line="158"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;SELECT * FROM servers WHERE id = :id&quot;)"
errorLine2=" ^">
<location
@ -410,7 +377,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;SELECT * FROM servers WHERE webhook_id = :webhookId&quot;)"
errorLine2=" ^">
<location
@ -421,7 +388,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;SELECT * FROM servers ORDER BY `list_order` ASC&quot;)"
errorLine2=" ^">
<location
@ -432,40 +399,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
errorLine1=" @Insert(onConflict = OnConflictStrategy.REPLACE)"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/settings/SettingsDao.kt"
line="13"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
errorLine1=" @Query(&quot;SELECT * FROM settings WHERE id = :id&quot;)"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/settings/SettingsDao.kt"
line="16"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
errorLine1=" @Update"
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/settings/SettingsDao.kt"
line="22"
column="5"/>
</issue>
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;SELECT * FROM static_widget WHERE id = :id&quot;)"
errorLine2=" ^">
<location
@ -476,7 +410,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;SELECT * FROM template_widgets WHERE id = :id&quot;)"
errorLine2=" ^">
<location
@ -487,7 +421,7 @@
<issue
id="CoroutineDaoFunction"
message="DAO functions should suspend or return a Flow."
message="DAO functions should suspend, return a Flow, or return a PagingSource."
errorLine1=" @Query(&quot;DELETE FROM thermostat_tiles where id = :id&quot;)"
errorLine2=" ^">
<location
@ -503,18 +437,18 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/database/AppDatabase.kt"
line="932"
line="1034"
column="17"/>
</issue>
<issue
id="MissingPermission"
message="Missing permissions required by NotificationManagerCompat.notify: android.permission.POST_NOTIFICATIONS"
errorLine1=" NotificationManagerCompat.from(context).notify(DISABLED_LOCATION_WARN_ID, DISABLED_LOCATION_WARN_ID.hashCode(), notificationBuilder.build())"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
errorLine1=" NotificationManagerCompat.from("
errorLine2=" ^">
<location
file="src/main/kotlin/io/homeassistant/companion/android/common/util/DisabledLocationHandler.kt"
line="112"
line="139"
column="17"/>
</issue>
@ -536,7 +470,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/common/sensors/SensorReceiverBase.kt"
line="385"
line="398"
column="9"/>
</issue>
@ -613,7 +547,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/common/sensors/BluetoothSensorManager.kt"
line="150"
line="178"
column="47"/>
</issue>
@ -624,7 +558,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/common/sensors/BluetoothSensorManager.kt"
line="156"
line="185"
column="46"/>
</issue>
@ -635,7 +569,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/common/sensors/BluetoothSensorManager.kt"
line="164"
line="194"
column="46"/>
</issue>
@ -646,7 +580,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/common/sensors/BluetoothSensorManager.kt"
line="173"
line="204"
column="46"/>
</issue>
@ -675,23 +609,23 @@
<issue
id="ObsoleteSdkInt"
message="Unnecessary; `SDK_INT` is always >= 29"
errorLine1=" (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q &amp;&amp; context.packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_RADIO_ACCESS)) ->"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
errorLine1=" Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q &amp;&amp;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/common/sensors/PhoneStateSensorManager.kt"
line="129"
column="14"/>
line="130"
column="17"/>
</issue>
<issue
id="ObsoleteSdkInt"
message="Unnecessary; `SDK_INT` is always >= 24"
errorLine1=" (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N &amp;&amp; context.packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_RADIO_ACCESS)) ->"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
errorLine1=" Build.VERSION.SDK_INT >= Build.VERSION_CODES.N &amp;&amp;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/common/sensors/PhoneStateSensorManager.kt"
line="131"
column="14"/>
line="143"
column="17"/>
</issue>
<issue
@ -778,7 +712,7 @@
errorLine2=" ~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/common/sensors/SensorManager.kt"
line="295"
line="312"
column="61"/>
</issue>
@ -789,19 +723,19 @@
errorLine2=" ~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/common/data/websocket/impl/WebSocketCoreImpl.kt"
line="227"
line="233"
column="65"/>
</issue>
<issue
id="AvoidAnySerializer"
message="Prefer polymorphic serializer over AnySerializer."
errorLine1=" val result = connection?.send(kotlinJsonMapper.encodeToString(MapAnySerializer, outbound))"
errorLine2=" ~~~~~~~~~~~~~~~~">
errorLine1=" kotlinJsonMapper.encodeToString(MapAnySerializer, outbound),"
errorLine2=" ~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/common/data/websocket/impl/WebSocketCoreImpl.kt"
line="266"
column="95"/>
line="273"
column="69"/>
</issue>
<issue
@ -877,7 +811,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/common/LocalStorageImpl.kt"
line="64"
line="63"
column="9"/>
</issue>
@ -888,7 +822,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/common/LocalStorageImpl.kt"
line="72"
line="71"
column="9"/>
</issue>
@ -899,7 +833,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/io/homeassistant/companion/android/common/notifications/NotificationFunctions.kt"
line="204"
line="184"
column="20"/>
</issue>

View File

@ -10,7 +10,7 @@ import androidx.room.Query
interface LocationHistoryDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun add(item: LocationHistoryItem): Long
suspend fun add(item: LocationHistoryItem): Long
@Query("SELECT * FROM location_history ORDER BY id DESC")
fun getAll(): PagingSource<Int, LocationHistoryItem>

View File

@ -19,9 +19,9 @@ object CoroutineDaoFunctionsIssue {
@JvmField
val ISSUE = Issue.Companion.create(
id = "CoroutineDaoFunction",
briefDescription = "DAO functions should suspend or return a Flow",
explanation = """All functions in a DAO should suspend or return a Flow to ensure
|they can be executed properly in coroutines
briefDescription = "DAO functions should suspend, return a Flow, or return a PagingSource",
explanation = """All functions in a DAO should suspend, return a Flow, or return a PagingSource
|to ensure they can be executed properly in coroutines
""".trimMargin(),
category = Category.Companion.CORRECTNESS,
severity = Severity.ERROR,
@ -50,12 +50,12 @@ object CoroutineDaoFunctionsIssue {
}
private fun checkMethod(context: JavaContext, method: UMethod) {
if (!method.isSuspend() && !method.isReturningFlow()) {
if (!method.isSuspend() && !method.isReturningFlow() && !method.isPagingSource()) {
context.report(
ISSUE,
method,
context.getLocation(method),
"DAO functions should suspend or return a Flow.",
"DAO functions should suspend, return a Flow, or return a PagingSource.",
)
}
}
@ -73,3 +73,6 @@ private fun UMethod.isSuspend(): Boolean {
private fun UMethod.isReturningFlow(): Boolean {
return returnType?.canonicalText?.startsWith("kotlinx.coroutines.flow.Flow") == true
}
private fun UMethod.isPagingSource(): Boolean {
return returnType?.canonicalText?.startsWith("androidx.paging.PagingSource") == true
}

View File

@ -22,6 +22,14 @@ class CoroutineDaoFunctionsIssueTest {
""",
).indented()
private val pagingSource = kotlin(
"""
package androidx.paging
interface PagingSource<K, V>
""",
).indented()
@Test
fun `Given a DAO when function is not suspending and does not return a Flow then CoroutineDaoFunction issue is raised`() {
lint().issues(CoroutineDaoFunctionsIssue.ISSUE)
@ -43,7 +51,7 @@ class CoroutineDaoFunctionsIssueTest {
)
.run()
.expect(
"""src/io/homeassistan/companion/android/TestDao.kt:7: Error: DAO functions should suspend or return a Flow. [CoroutineDaoFunction]
"""src/io/homeassistan/companion/android/TestDao.kt:7: Error: DAO functions should suspend, return a Flow, or return a PagingSource. [CoroutineDaoFunction]
fun test()
~~~~~~~~~~
1 error""",
@ -97,4 +105,29 @@ class CoroutineDaoFunctionsIssueTest {
.run()
.expectClean()
}
@Test
fun `Given a DAO when function is not suspending and does return a PagingSource then no issues`() {
lint().issues(CoroutineDaoFunctionsIssue.ISSUE)
.allowMissingSdk()
.files(
pagingSource,
flow,
kotlin(
"""
package io.homeassistan.companion.android
import androidx.paging.PagingSource
import kotlinx.coroutines.flow.Flow
@Dao
interface TestDao {
fun test(): PagingSource<Int, String>
}
""",
).indented(),
)
.run()
.expectClean()
}
}