diff --git a/detekt-baseline.xml b/detekt-baseline.xml new file mode 100644 index 0000000..28238d0 --- /dev/null +++ b/detekt-baseline.xml @@ -0,0 +1,74 @@ + + + + + CyclomaticComplexMethod:StopTimeSQL.kt:StopTimeSQL$fun update: Boolean + CyclomaticComplexMethod:StringsCleanerTests.kt:StringsCleanerTests$@Test fun test_cleanRouteLongName + CyclomaticComplexMethod:StringsCleanerTests.kt:StringsCleanerTests$@Test fun test_cleanTripHeadsign + EmptyDefaultConstructor:CommonSQL.kt:CommonSQL + FunctionOnlyReturningConstant:CleanUtilsExt.kt:fun makeALL_CHARS_REGEX_REPLACEMENT + FunctionOnlyReturningConstant:CleanUtilsExt.kt:fun makeALL_FACE_A_REGEX_REPLACEMENT + FunctionOnlyReturningConstant:CleanUtilsExt.kt:fun makeALL_ST_REGEX_REPLACEMENT + LongMethod:StringsCleanerTests.kt:StringsCleanerTests$@Test fun test_cleanRouteLongName + LoopWithTooManyJumpStatements:CharUtils.kt:CharUtils$for + MagicNumber:SourceUtils.kt:SourceUtils$3 + NewLineAtEndOfFile:AgencySQL.kt:org.mtransit.commons.gtfs.sql.AgencySQL.kt + NewLineAtEndOfFile:CaVancouverTransLinkProviderCommons.kt:org.mtransit.commons.provider.CaVancouverTransLinkProviderCommons.kt + NewLineAtEndOfFile:CalendarDateSQL.kt:org.mtransit.commons.gtfs.sql.CalendarDateSQL.kt + NewLineAtEndOfFile:CalendarExceptionType.kt:org.mtransit.commons.gtfs.data.CalendarExceptionType.kt + NewLineAtEndOfFile:CharUtils.kt:org.mtransit.commons.CharUtils.kt + NewLineAtEndOfFile:CleanerTest.kt:org.mtransit.commons.CleanerTest.kt + NewLineAtEndOfFile:CollectionsExtTest.kt:org.mtransit.commons.CollectionsExtTest.kt + NewLineAtEndOfFile:Color.kt:org.mtransit.commons.gtfs.data.Color.kt + NewLineAtEndOfFile:CommonSQL.kt:org.mtransit.commons.gtfs.sql.CommonSQL.kt + NewLineAtEndOfFile:CommonsApp.kt:org.mtransit.commons.CommonsApp.kt + NewLineAtEndOfFile:CommonsMain.kt:org.mtransit.scratch.CommonsMain.kt + NewLineAtEndOfFile:DirectionSQL.kt:org.mtransit.commons.gtfs.sql.DirectionSQL.kt + NewLineAtEndOfFile:FrequencySQL.kt:org.mtransit.commons.gtfs.sql.FrequencySQL.kt + NewLineAtEndOfFile:GTFSCommons.kt:org.mtransit.commons.GTFSCommons.kt + NewLineAtEndOfFile:OneBusAwayProviderCommons.kt:org.mtransit.commons.provider.OneBusAwayProviderCommons.kt + NewLineAtEndOfFile:PrimitivesTxt.kt:org.mtransit.commons.PrimitivesTxt.kt + NewLineAtEndOfFile:Quadruple.kt:org.mtransit.commons.model.Quadruple.kt + NewLineAtEndOfFile:Quintuple.kt:org.mtransit.commons.model.Quintuple.kt + NewLineAtEndOfFile:RTCQuebecProviderCommons.kt:org.mtransit.commons.provider.RTCQuebecProviderCommons.kt + NewLineAtEndOfFile:RegexScratch.kt:org.mtransit.scratch.RegexScratch.kt + NewLineAtEndOfFile:RegexUtils.kt:org.mtransit.commons.RegexUtils.kt + NewLineAtEndOfFile:RouteSQL.kt:org.mtransit.commons.gtfs.sql.RouteSQL.kt + NewLineAtEndOfFile:SQLColumDef.kt:org.mtransit.commons.gtfs.sql.SQLColumDef.kt + NewLineAtEndOfFile:SQLCreateBuilder.kt:org.mtransit.commons.sql.SQLCreateBuilder.kt + NewLineAtEndOfFile:SQLExt.kt:org.mtransit.commons.sql.SQLExt.kt + NewLineAtEndOfFile:SQLInsertBuilder.kt:org.mtransit.commons.sql.SQLInsertBuilder.kt + NewLineAtEndOfFile:SQLJoinBuilder.kt:org.mtransit.commons.sql.SQLJoinBuilder.kt + NewLineAtEndOfFile:SQLTableDef.kt:org.mtransit.commons.gtfs.sql.SQLTableDef.kt + NewLineAtEndOfFile:SQLUtils.kt:org.mtransit.commons.sql.SQLUtils.kt + NewLineAtEndOfFile:Stop.kt:org.mtransit.commons.gtfs.data.Stop.kt + NewLineAtEndOfFile:StopSQL.kt:org.mtransit.commons.gtfs.sql.StopSQL.kt + NewLineAtEndOfFile:StopTime.kt:org.mtransit.commons.gtfs.data.StopTime.kt + NewLineAtEndOfFile:StopTimeSQL.kt:org.mtransit.commons.gtfs.sql.StopTimeSQL.kt + NewLineAtEndOfFile:StringUtils.kt:org.mtransit.commons.StringUtils.kt + NewLineAtEndOfFile:TableSQL.kt:org.mtransit.commons.gtfs.sql.TableSQL.kt + NewLineAtEndOfFile:Text.kt:org.mtransit.commons.gtfs.data.Text.kt + NewLineAtEndOfFile:Time.kt:org.mtransit.commons.gtfs.data.Time.kt + NewLineAtEndOfFile:TripSQL.kt:org.mtransit.commons.gtfs.sql.TripSQL.kt + NewLineAtEndOfFile:Url.kt:org.mtransit.commons.gtfs.data.Url.kt + NewLineAtEndOfFile:WinnipegTransitProviderCommons.kt:org.mtransit.commons.provider.WinnipegTransitProviderCommons.kt + NewLineAtEndOfFile:WordUtils.kt:org.mtransit.commons.WordUtils.kt + ReturnCount:CharUtils.kt:CharUtils$@JvmStatic fun isUppercaseOnly: Boolean + ReturnCount:CommonSQL.kt:CommonSQL$fun insertIntoMainTable: Boolean + ReturnCount:WordUtils.kt:WordUtils$private fun isDelimiter: Boolean + TooGenericExceptionCaught:CommonSQL.kt:CommonSQL$e: Exception + TooGenericExceptionCaught:SourceUtils.kt:SourceUtils$e: Exception + TooGenericExceptionThrown:CommonSQL.kt:CommonSQL$throw Exception("Error while counting routes!") + TooGenericExceptionThrown:CommonSQL.kt:CommonSQL$throw Exception("Error while inserting $mainTableName ID $id!") + TooGenericExceptionThrown:CommonSQL.kt:CommonSQL$throw Exception("No main table!") + TooGenericExceptionThrown:PrimitivesTxt.kt:throw Exception("Invalid timestamp in sec '$this'!") + TooGenericExceptionThrown:RegexUtils.kt:RegexUtils$throw RuntimeException("Platform not set!") + TooGenericExceptionThrown:RouteSQL.kt:RouteSQL$throw Exception("Can't find agency ID!") + TooGenericExceptionThrown:SQLExt.kt:throw Exception("SQL error while executing query '$query'!", e) + TooGenericExceptionThrown:SQLExt.kt:throw Exception("SQL error while executing update '$query'!", e) + TooManyFunctions:CollectionUtils.kt:CollectionUtils + TooManyFunctions:CommonSQL.kt:CommonSQL<MainType> : TableSQL + TooManyFunctions:RegexUtils.kt:RegexUtils + TooManyFunctions:SQLUtils.kt:SQLUtils + + diff --git a/src/main/java/org/mtransit/commons/SourceUtils.kt b/src/main/java/org/mtransit/commons/SourceUtils.kt index ab8d27b..9f715fd 100644 --- a/src/main/java/org/mtransit/commons/SourceUtils.kt +++ b/src/main/java/org/mtransit/commons/SourceUtils.kt @@ -44,6 +44,7 @@ object SourceUtils { "www", ) + @Suppress("PrintStackTrace") // used from JVM & Android @JvmStatic fun getSourceLabel(urlString: String): String { try { @@ -56,6 +57,7 @@ object SourceUtils { } } + @Suppress("PrintStackTrace") // used from JVM & Android @JvmStatic fun getSourceLabel(url: URL): String { try { diff --git a/src/main/java/org/mtransit/commons/gtfs/sql/CalendarDateSQL.kt b/src/main/java/org/mtransit/commons/gtfs/sql/CalendarDateSQL.kt index e8ac429..46370bb 100644 --- a/src/main/java/org/mtransit/commons/gtfs/sql/CalendarDateSQL.kt +++ b/src/main/java/org/mtransit/commons/gtfs/sql/CalendarDateSQL.kt @@ -41,8 +41,14 @@ object CalendarDateSQL : CommonSQL(), TableSQL { override fun getMainTable() = SQLTableDef( T_CALENDAR_DATE, listOf( - SQLColumDef(T_CALENDAR_DATE_K_SERVICE_ID_INT, SQLUtils.INT, primaryKey = !CALENDAR_IN_CALENDAR_DATES, SQLForeignKey(T_SERVICE_IDS, T_SERVICE_IDS_K_ID_INT)), - SQLColumDef(T_CALENDAR_DATE_K_DATE, SQLUtils.INT, primaryKey = !CALENDAR_IN_CALENDAR_DATES), // YYYYMMDD + SQLColumDef( + T_CALENDAR_DATE_K_SERVICE_ID_INT, SQLUtils.INT, + primaryKey = !CALENDAR_IN_CALENDAR_DATES, foreignKey = SQLForeignKey(T_SERVICE_IDS, T_SERVICE_IDS_K_ID_INT) + ), + SQLColumDef( + T_CALENDAR_DATE_K_DATE, SQLUtils.INT, // YYYYMMDD + primaryKey = !CALENDAR_IN_CALENDAR_DATES + ), SQLColumDef(T_CALENDAR_DATE_K_EXCEPTION_TYPE, SQLUtils.INT), // 1: added, 2: removed (MT: +0: default) ), insertAllowReplace = false, diff --git a/src/main/java/org/mtransit/commons/gtfs/sql/StopSQL.kt b/src/main/java/org/mtransit/commons/gtfs/sql/StopSQL.kt index 9b98e96..a4dcaac 100644 --- a/src/main/java/org/mtransit/commons/gtfs/sql/StopSQL.kt +++ b/src/main/java/org/mtransit/commons/gtfs/sql/StopSQL.kt @@ -24,7 +24,7 @@ object StopSQL : CommonSQL(), TableSQL { return statement.executeQuery(sql).use { rs -> buildList { while (rs.next()) { - add(rs.getString(T_STOP_IDS_K_ID)) + add(rs.getString(T_STOP_IDS_K_ID)) } } } @@ -80,7 +80,8 @@ object StopSQL : CommonSQL(), TableSQL { append("${getJoinAlias(T_STOP_K_PARENT_STATION_ID_INT)}.$T_STOP_IDS_K_ID AS ${getAlias(T_STOP_K_PARENT_STATION_ID_INT, T_STOP_IDS_K_ID)} ") append("FROM $T_STOP ") append("JOIN $T_STOP_IDS AS ${getJoinAlias(T_STOP_K_ID_INT)} ON $T_STOP.$T_STOP_K_ID_INT =${getJoinAlias(T_STOP_K_ID_INT)}.$T_STOP_K_ID_INT ") - append("JOIN $T_STOP_IDS AS ${getJoinAlias(T_STOP_K_PARENT_STATION_ID_INT)} ON $T_STOP.$T_STOP_K_PARENT_STATION_ID_INT = ${getJoinAlias(T_STOP_K_PARENT_STATION_ID_INT)}.$T_STOP_K_ID_INT ") + append("JOIN $T_STOP_IDS AS ${getJoinAlias(T_STOP_K_PARENT_STATION_ID_INT)} ") + .append("ON $T_STOP.$T_STOP_K_PARENT_STATION_ID_INT = ${getJoinAlias(T_STOP_K_PARENT_STATION_ID_INT)}.$T_STOP_K_ID_INT ") stopId?.let { append("WHERE ${getJoinAlias(T_STOP_K_ID_INT)}.$T_STOP_IDS_K_ID = '$it'") } diff --git a/src/main/java/org/mtransit/commons/gtfs/sql/TripSQL.kt b/src/main/java/org/mtransit/commons/gtfs/sql/TripSQL.kt index 9b5f0af..1ed7326 100644 --- a/src/main/java/org/mtransit/commons/gtfs/sql/TripSQL.kt +++ b/src/main/java/org/mtransit/commons/gtfs/sql/TripSQL.kt @@ -89,7 +89,8 @@ object TripSQL : CommonSQL(), TableSQL { append("FROM $T_TRIP ") append("JOIN $T_TRIP_IDS ON $T_TRIP.$T_TRIP_K_ID_INT = $T_TRIP_IDS.$T_TRIP_IDS_K_ID_INT ") append("JOIN ${RouteSQL.T_ROUTE_IDS} ON $T_TRIP.${T_TRIP_K_ROUTE_ID_INT} = ${RouteSQL.T_ROUTE_IDS}.${RouteSQL.T_ROUTE_K_ID_INT} ") - append("JOIN ${CalendarDateSQL.T_SERVICE_IDS} ON $T_TRIP.${T_TRIP_K_SERVICE_ID_INT} = ${CalendarDateSQL.T_SERVICE_IDS}.${CalendarDateSQL.T_SERVICE_IDS_K_ID_INT} ") + append("JOIN ${CalendarDateSQL.T_SERVICE_IDS} ") + .append("ON $T_TRIP.${T_TRIP_K_SERVICE_ID_INT} = ${CalendarDateSQL.T_SERVICE_IDS}.${CalendarDateSQL.T_SERVICE_IDS_K_ID_INT} ") tripIds?.let { append("WHERE $T_TRIP_IDS.$T_TRIP_IDS_K_ID IN (${it.joinToString { "'$it'" }}) ") }