Skip to content

Commit

Permalink
fix: ktlint upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
bayang committed Jul 15, 2023
1 parent ec9f714 commit 5430a7e
Show file tree
Hide file tree
Showing 91 changed files with 596 additions and 587 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[{*.kts,*.kt}]
ktlint_standard_no-wildcard-imports = disabled
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ plugins {
kotlin("plugin.allopen") version kotlinVersion
kotlin("kapt") version kotlinVersion
id("com.github.node-gradle.node") version "3.5.1"
id("org.jlleitschuh.gradle.ktlint") version "11.3.2"
id("org.jlleitschuh.gradle.ktlint") version "11.5.0"
}

configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
version.set("0.50.0")
outputToConsole.set(true)
coloredOutput.set(true)
disabledRules.set(setOf("no-wildcard-imports", "parameter-list-wrapping"))
Expand Down Expand Up @@ -101,7 +102,7 @@ tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf(
"-Xjsr305=strict",
"-opt-in=kotlin.time.ExperimentalTime"
"-opt-in=kotlin.time.ExperimentalTime",
)
jvmTarget = "11"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ private val LOGGER = KotlinLogging.logger {}
@ConditionalOnProperty(name = ["jelu.auth.proxy.enabled"], havingValue = "true", matchIfMissing = false)
class AuthHeaderFilter(
private val userService: UserService,
private val properties: JeluProperties
private val properties: JeluProperties,
) : OncePerRequestFilter() {

override fun doFilterInternal(
request: HttpServletRequest,
response: HttpServletResponse,
filterChain: FilterChain
filterChain: FilterChain,
) {
val headerName = properties.auth.proxy.header
val headerAuth: String? = request.getHeader(headerName)
Expand All @@ -44,7 +44,7 @@ class AuthHeaderFilter(
val authentication = UsernamePasswordAuthenticationToken(
user,
null,
user.authorities
user.authorities,
)
authentication.details = WebAuthenticationDetailsSource().buildDetails(request)
SecurityContextHolder.getContext().authentication = authentication
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/io/github/bayang/jelu/config/GlobalConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class GlobalConfig {
}.build()
return WebClient.builder().exchangeStrategies(exchange).clientConnector(
ReactorClientHttpConnector(
HttpClient.create().compress(true).followRedirect(true)
)
HttpClient.create().compress(true).followRedirect(true),
),
).build()
}

Expand All @@ -45,7 +45,7 @@ class GlobalConfig {
allowCredentials = true
addExposedHeader(HttpHeaders.CONTENT_DISPOSITION)
addExposedHeader(sessionHeaderName)
}
},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ private val logger = KotlinLogging.logger {}
@Component
@ConditionalOnProperty(name = ["jelu.auth.ldap.enabled"], havingValue = "true", matchIfMissing = false)
class JeluLdapUserDetailsContextMapper(
private val userRepository: UserRepository
private val userRepository: UserRepository,
) : UserDetailsContextMapper {

@Transactional
override fun mapUserFromContext(
ctx: DirContextOperations?,
username: String?,
authorities: MutableCollection<out GrantedAuthority>?
authorities: MutableCollection<out GrantedAuthority>?,
): UserDetails {
dumpAttributesForDebug(ctx?.attributes)
val isAdmin = findAdminMembership(ctx?.attributes)
Expand Down
28 changes: 14 additions & 14 deletions src/main/kotlin/io/github/bayang/jelu/config/JeluProperties.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,49 @@ data class JeluProperties(
val metadata: Metadata = Metadata(Calibre(null)),
val auth: Auth = Auth(
Ldap(),
Proxy()
Proxy(),
),
val metadataProviders: List<MetaDataProvider>?,
val lucene: Lucene = Lucene(indexAnalyzer = IndexAnalyzer())
val lucene: Lucene = Lucene(indexAnalyzer = IndexAnalyzer()),
) {

data class MetaDataProvider(
var name: String,
var isEnabled: Boolean = false,
var apiKey: String?,
var order: Int = -1000
var order: Int = -1000,
)

data class Database(
@get:NotBlank var path: String
@get:NotBlank var path: String,
)

data class Files(
@get:NotBlank var images: String,
@get:NotBlank var imports: String,
var resizeImages: Boolean = true
var resizeImages: Boolean = true,
)

data class Session(
@get:Positive var duration: Int
@get:Positive var duration: Int,
)

data class Cors(
var allowedOrigins: List<String> = emptyList()
var allowedOrigins: List<String> = emptyList(),
)

data class Calibre(
var path: String?,
var order: Int = 1000
var order: Int = 1000,
)

data class Metadata(
var calibre: Calibre
var calibre: Calibre,
)

data class Auth(
var ldap: Ldap,
var proxy: Proxy
var proxy: Proxy,
)

data class Ldap(
Expand All @@ -69,28 +69,28 @@ data class JeluProperties(
val userSearchFilter: String = "",
val userSearchBase: String = "",
val userDn: String = "",
val password: String = ""
val password: String = "",
)

data class Proxy(
var enabled: Boolean = false,
val adminName: String = "",
val header: String = "X-Authenticated-User"
val header: String = "X-Authenticated-User",
)

data class IndexAnalyzer(
@get:Positive
var minGram: Int = 3,
@get:Positive
var maxGram: Int = 10,
var preserveOriginal: Boolean = true
var preserveOriginal: Boolean = true,
)

data class Lucene(
@get:NotBlank
var dataDirectory: String = "",

var indexAnalyzer: IndexAnalyzer
var indexAnalyzer: IndexAnalyzer,

)
}
4 changes: 2 additions & 2 deletions src/main/kotlin/io/github/bayang/jelu/config/LdapConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.springframework.security.ldap.userdetails.UserDetailsContextMapper
@ConditionalOnProperty(name = ["jelu.auth.ldap.enabled"], havingValue = "true", matchIfMissing = false)
class LdapConfig(
private val userDetailsContextMapper: UserDetailsContextMapper,
private val properties: JeluProperties
private val properties: JeluProperties,
) {

@Bean
Expand All @@ -41,7 +41,7 @@ class LdapConfig(
if (!properties.auth.ldap.userSearchFilter.isNullOrBlank()) {
val userSearchBase = if (properties.auth.ldap.userSearchBase.isNullOrBlank()) "" else properties.auth.ldap.userSearchBase
authenticator.setUserSearch(
FilterBasedLdapUserSearch(userSearchBase, properties.auth.ldap.userSearchFilter, contextSource)
FilterBasedLdapUserSearch(userSearchBase, properties.auth.ldap.userSearchFilter, contextSource),
)
}
authenticator.afterPropertiesSet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import java.nio.file.Paths

@Configuration
class LuceneConfiguration(
private val jeluProperties: JeluProperties
private val jeluProperties: JeluProperties,
) {

@Bean
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/io/github/bayang/jelu/config/OpenApiConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ class OpenApiConfig {
Info()
.title("Jelu API")
.version("v1.0")
.license(License().name("MIT").url("https://github.com/bayang/jelu/blob/main/LICENSE"))
.license(License().name("MIT").url("https://github.com/bayang/jelu/blob/main/LICENSE")),
)
.externalDocs(
ExternalDocumentation()
.description("jelu documentation")
.url("https://github.com/bayang/jelu")
.url("https://github.com/bayang/jelu"),
)
.components(
Components()
.addSecuritySchemes(
"basicAuth",
SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic")
)
SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"),
),
)
.servers(mutableListOf(server))
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/kotlin/io/github/bayang/jelu/config/SecurityConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SecurityConfig(
private val properties: JeluProperties,
private val userDetailsService: UserDetailsService,
private val passwordEncoder: PasswordEncoder,
private val authHeaderFilter: AuthHeaderFilter?
private val authHeaderFilter: AuthHeaderFilter?,
) {

@Bean
Expand All @@ -37,7 +37,7 @@ class SecurityConfig(
"/api/v1/token",
"/api/v1/setup/status",
"/api/v1/server-settings",
"/api/v1/reviews/**"
"/api/v1/reviews/**",
).permitAll()
it.mvcMatchers(HttpMethod.GET, "/api/v1/reviews/**").permitAll()
it.mvcMatchers(HttpMethod.GET, "/api/v1/books/**").permitAll()
Expand All @@ -46,20 +46,20 @@ class SecurityConfig(
it.mvcMatchers(HttpMethod.PUT, "/api/v1/users/**").hasAnyRole("USER")
it.mvcMatchers(
HttpMethod.GET,
"/api/v1/users/me"
"/api/v1/users/me",
).hasRole("USER")
it.antMatchers(
"/api/v1/users/**"
"/api/v1/users/**",
).hasRole("USER")
it.antMatchers(
"/api/v1/users"
"/api/v1/users",
).hasRole("USER")
it.mvcMatchers(
HttpMethod.POST,
"/api/v1/user-messages"
"/api/v1/user-messages",
).hasRole("ADMIN")
it.antMatchers(
"/api/**"
"/api/**",
).hasRole("USER")
}
.httpBasic()
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/io/github/bayang/jelu/config/WebMvcConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class WebMvcConfig(private val properties: JeluProperties) : WebMvcConfigurer {
"/android-chrome-192x192.png",
"/android-chrome-512x512.png",
"/manifest.json",
"/site.webmanifest"
"/site.webmanifest",
)
.addResourceLocations(
"classpath:public/index.html",
Expand All @@ -54,7 +54,7 @@ class WebMvcConfig(private val properties: JeluProperties) : WebMvcConfigurer {
"classpath:public/android-chrome-192x192.png",
"classpath:public/android-chrome-512x512.png",
"classpath:public/manifest.json",
"classpath:public/site.webmanifest"
"classpath:public/site.webmanifest",
)
.setCacheControl(CacheControl.noStore())
}
Expand Down
Loading

0 comments on commit 5430a7e

Please sign in to comment.