Skip to content

Commit

Permalink
Update all non-major dependencies (except core Kotlin) (#930)
Browse files Browse the repository at this point in the history
* Update all non-major dependencies (except core Kotlin)
* Update detekt.yml
* Update detekt.yml: add `--continue` flag
* Fix detekt findings

Co-authored-by: Peter Trifanov <[email protected]>
  • Loading branch information
renovate[bot] and petertrr authored Jul 18, 2022
1 parent 9fb144c commit 044514b
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ jobs:
arguments: |
detektAll
--build-cache
--continue
-PgprUser=${{ github.actor }}
-PgprKey=${{ secrets.GITHUB_TOKEN }}
- name: Upload SARIF to Github
if: ${{ always() }}
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: build/detekt-sarif-reports/detekt-merged.sarif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import org.springframework.security.authorization.AuthenticatedReactiveAuthoriza
import org.springframework.security.authorization.AuthorizationDecision
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity
import org.springframework.security.config.web.server.ServerHttpSecurity
import org.springframework.security.core.userdetails.ReactiveUserDetailsService
import org.springframework.security.core.userdetails.UserDetails
import org.springframework.security.crypto.factory.PasswordEncoderFactories
import org.springframework.security.crypto.password.PasswordEncoder
Expand Down Expand Up @@ -139,27 +138,23 @@ class WebSecurityConfig(
.httpBasic { httpBasicSpec ->
// Authenticate by comparing received basic credentials with existing one from DB
httpBasicSpec.authenticationManager(
UserDetailsRepositoryReactiveAuthenticationManager(
object : ReactiveUserDetailsService {
// Looking for user in DB by received source and name
override fun findByUsername(username: String): Mono<UserDetails> {
require(username.contains("@")) {
"Provided user information should keep the following form: oauth2Source@username"
}
val user: Mono<StringResponse> = webClient.get()
.uri("/internal/users/$username")
.retrieve()
.onStatus({ it.is4xxClientError }) {
Mono.error(ResponseStatusException(it.statusCode()))
}
.toEntity()

return user.map {
objectMapper.readValue(it.body, UserDetails::class.java)
}
UserDetailsRepositoryReactiveAuthenticationManager { username ->
// Looking for user in DB by received source and name
require(username.contains("@")) {
"Provided user information should keep the following form: oauth2Source@username"
}
val user: Mono<StringResponse> = webClient.get()
.uri("/internal/users/$username")
.retrieve()
.onStatus({ it.is4xxClientError }) {
Mono.error(ResponseStatusException(it.statusCode()))
}
.toEntity()

user.map {
objectMapper.readValue(it.body, UserDetails::class.java)
}
)
}
)
}
.logout {
Expand Down
3 changes: 3 additions & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ naming:
excludes: ['**/resources/**']
active: true
ignoreOverridden: true
NoNameShadowing:
# Different rule (in Diktat) checks that implicit lambda hasn't been shadowed.
active: false
NonBooleanPropertyPrefixedWithIs:
active: true
ObjectPropertyNaming:
Expand Down
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ ktor = "2.0.3"
okio = "3.2.0"
serialization = "1.3.3"
kotlinx-datetime = "0.4.0"
kotlinx-coroutines = "1.6.3"
kotlin-wrappers = "1.0.0-pre.354"
spring = "5.3.21"
kotlinx-coroutines = "1.6.4"
kotlin-wrappers = "1.0.0-pre.357"
spring = "5.3.22"
spring-boot = "2.7.1"
spring-security = "5.7.2"
spring-cloud = "3.1.3"
spring-cloud-kubernetes = "2.1.3"
junit = "5.8.2"
diktat = "1.2.1"
detekt = "1.20.0"
detekt = "1.21.0"
liquibase-core = "4.13.0"
docker-java = "3.2.13"
jgit = "6.2.0.202206071550-r"
reactor = "1.1.6"
reactor = "1.1.7"
mockito-kotlin = "4.0.0"
slf4j = "1.7.36"
logback = "1.2.11"
Expand All @@ -33,7 +33,7 @@ reckon = "0.16.1"
commons-compress = "1.21"
picocli = "4.6.3"
zip4j = "2.11.1"
ktoml = "0.2.12"
ktoml = "0.2.13"
springdoc = "1.6.9"
kotlinx-cli = "0.3.5"
spotless = "6.8.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ fun initializeHttpClient(
// therefore, adding sendWithoutRequest is required
sendWithoutRequest { true }
credentials {
BasicAuthCredentials(username = authorization.userInformation, password = authorization.token ?: "")
BasicAuthCredentials(username = authorization.userInformation, password = authorization.token.orEmpty())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ internal class ContestController(
}.map { testFilesContent ->
testFilesContent.copy(
language = testSuite.language,
tags = test.tagsAsList() ?: emptyList(),
tags = test.tagsAsList().orEmpty(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class ExecutionController(private val executionService: ExecutionService,
?.map {
it.testRootPath
}
?: emptyList()
.orEmpty()

/**
* @param execution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class UserDetailsService(
if (!user.isPresent) {
val sourceMsg = source?.let {
" and source=$source"
} ?: ""
}.orEmpty()
logger.warn("Couldn't find user with name=$username$sourceMsg in DB!")
}
user.isPresent
Expand All @@ -67,7 +67,7 @@ class UserDetailsService(
@Suppress("UnsafeCallOnNullableType")
private fun User.toIdentitySourceAwareUserDetails(): IdentitySourceAwareUserDetails = IdentitySourceAwareUserDetails(
username = this.name!!,
password = this.password ?: "",
password = this.password.orEmpty(),
authorities = this.role,
identitySource = this.source,
id = this.id!!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ class AgentsControllerTest {
transactionTemplate.execute {
agentStatusRepository
.findAll()
.filter { it.state == AgentState.IDLE && it.agent.containerId == "container-2" }
.size == 1
.count { it.state == AgentState.IDLE && it.agent.containerId == "container-2" } == 1
}!!
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Test(
pluginName,
testSuite.id!!,
hash,
tagsAsList() ?: emptyList(),
tagsAsList().orEmpty(),
additionalFilesAsList(),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,17 @@ class TestExecution(
startTime?.toEpochSecond(ZoneOffset.UTC),
endTime?.toEpochSecond(ZoneOffset.UTC),
test.testSuite.name,
test.tags?.split(";")?.filter { it.isNotBlank() } ?: emptyList(),
tagsList(),
unmatched,
matched,
expected,
unexpected,
null,
execution.id,
)

private fun tagsList() = test.tags
?.split(";")
?.filter { it.isNotBlank() }
.orEmpty()
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ abstract class AbstractFileBasedStorage<K>(
return Mono.fromCallable {
contentPath.parent.createDirectoriesIfRequired()
contentPath.createFile()
}.flatMap {
}.flatMap { _ ->
content.map { byteBuffer ->
contentPath.outputStream(StandardOpenOption.APPEND).use { os ->
Channels.newChannel(os).use { it.write(byteBuffer) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ class IdentitySourceAwareUserDetails(
authorities?.split(',')
?.filter { it.isNotBlank() }
?.map { SimpleGrantedAuthority(it) }
?: emptyList()
.orEmpty()
)
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private fun projectStatisticMenu() = FC<ProjectStatisticMenuProps> { props ->
className = ClassName("col-xl col-md-6 mb-4")
val data = latestExecutionStatisticDtos?.map {
DataPieChart(it.testSuiteName, it.countTest, randomColor())
} ?: emptyList()
}.orEmpty()
pieChart(
data.toTypedArray()
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ class OrganizationView : AbstractView<OrganizationProps, OrganizationViewState>(
div {
className = ClassName("col-3")
userBoard {
users = state.usersInOrganization ?: emptyList()
users = state.usersInOrganization.orEmpty()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class KubernetesManager(
}
.take(10)
.firstOrNull { it.isNotEmpty() }
?: emptyList()
.orEmpty()
}

override fun start(executionId: Long) {
Expand Down

0 comments on commit 044514b

Please sign in to comment.