From 9802a593e1232ea6cb719d447aad91aa8540b6b5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 15:49:54 +0000 Subject: [PATCH] Update dependency org.jlleitschuh.gradle.ktlint to v13 --- .editorconfig | 6 ++- .../AttributeCachingFileSystem.kt | 10 ++-- .../AttributeCachingFileSystemProvider.kt | 42 +++++++--------- .../attributecaching/AttributeCachingPath.kt | 6 +-- .../ForwardingFileSystemProvider.kt | 7 +-- .../AttributeCachingFileSystemTests.kt | 50 +++++++------------ gradle/libs.versions.toml | 2 +- 7 files changed, 49 insertions(+), 74 deletions(-) diff --git a/.editorconfig b/.editorconfig index 7b23397..d2a180f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,4 +15,8 @@ ij_kotlin_allow_trailing_comma_on_call_site = true [*.{yml,yaml}] indent_size = 2 -tab_width = 2 \ No newline at end of file +tab_width = 2 + +[*.kt*] +ktlint_code_style = intellij_idea +max_line_length = 120 \ No newline at end of file diff --git a/file-attribute-caching/src/main/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingFileSystem.kt b/file-attribute-caching/src/main/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingFileSystem.kt index 46ad21b..ab43ad7 100644 --- a/file-attribute-caching/src/main/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingFileSystem.kt +++ b/file-attribute-caching/src/main/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingFileSystem.kt @@ -19,10 +19,8 @@ import java.util.UUID * @param delegate The [FileSystem] to wrap and forward calls to. * @param provider The [FileSystemProvider] associated with this [FileSystem]. */ -public class AttributeCachingFileSystem( - delegate: FileSystem, - private val provider: FileSystemProvider, -) : ForwardingFileSystem(delegate) { +public class AttributeCachingFileSystem(delegate: FileSystem, private val provider: FileSystemProvider) : + ForwardingFileSystem(delegate) { override fun provider(): FileSystemProvider = provider @@ -61,9 +59,7 @@ public class AttributeCachingFileSystem( * @throws IOException If an IO error occurs. */ @Throws(FileAlreadyExistsException::class, ProviderNotFoundException::class, IOException::class) - public fun wrapping( - fileSystem: FileSystem, - ): AttributeCachingFileSystem = FileSystems.newFileSystem( + public fun wrapping(fileSystem: FileSystem): AttributeCachingFileSystem = FileSystems.newFileSystem( // Need to ensure a unique fileSystem name everytime this is called, hence UUID.randomUUID() URI.create("cache:///${UUID.randomUUID()}"), mapOf(Pair("filesystem", fileSystem)), diff --git a/file-attribute-caching/src/main/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingFileSystemProvider.kt b/file-attribute-caching/src/main/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingFileSystemProvider.kt index d2cbb02..d704f8e 100644 --- a/file-attribute-caching/src/main/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingFileSystemProvider.kt +++ b/file-attribute-caching/src/main/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingFileSystemProvider.kt @@ -292,18 +292,15 @@ internal class AttributeCachingFileSystemProvider : FileSystemProvider() { * given [type] are not supported. */ @Throws(IOException::class, UnsupportedOperationException::class) - override fun readAttributes( - path: Path, - type: Class, - vararg options: LinkOption, - ): A = if (path is AttributeCachingPath) { - val attributes = path.getAllAttributesMatchingClass(type) ?: throw UnsupportedOperationException( - "Could not read attributes of type $type from the path $path and its delegate filesystem.", - ) - attributes - } else { - path.fileSystem.provider().readAttributes(path, type, *options) - } + override fun readAttributes(path: Path, type: Class, vararg options: LinkOption): A = + if (path is AttributeCachingPath) { + val attributes = path.getAllAttributesMatchingClass(type) ?: throw UnsupportedOperationException( + "Could not read attributes of type $type from the path $path and its delegate filesystem.", + ) + attributes + } else { + path.fileSystem.provider().readAttributes(path, type, *options) + } /** * Read filesystem [attributes] from the incoming [path]. If the returned attributes are `null` we then attempt to get @@ -324,18 +321,15 @@ internal class AttributeCachingFileSystemProvider : FileSystemProvider() { * [FileSystemProvider]. */ @Throws(IOException::class, UnsupportedOperationException::class, IllegalArgumentException::class) - override fun readAttributes( - path: Path, - attributes: String, - vararg options: LinkOption, - ): MutableMap = if (path is AttributeCachingPath) { - val attributesMap = path.getAllAttributesMatchingNames(attributes) ?: throw IllegalArgumentException( - "Could not read attributes $attributes of the path $path from the delegate filesystem.", - ) - attributesMap - } else { - path.fileSystem.provider().readAttributes(path, attributes, *options) - } + override fun readAttributes(path: Path, attributes: String, vararg options: LinkOption): MutableMap = + if (path is AttributeCachingPath) { + val attributesMap = path.getAllAttributesMatchingNames(attributes) ?: throw IllegalArgumentException( + "Could not read attributes $attributes of the path $path from the delegate filesystem.", + ) + attributesMap + } else { + path.fileSystem.provider().readAttributes(path, attributes, *options) + } /** * Set a single attribute or attribute class (ie: "dos:*","basic:*","posix:permissions", etc.) for the given [path] diff --git a/file-attribute-caching/src/main/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingPath.kt b/file-attribute-caching/src/main/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingPath.kt index 00376a7..df8fe70 100644 --- a/file-attribute-caching/src/main/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingPath.kt +++ b/file-attribute-caching/src/main/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingPath.kt @@ -46,10 +46,8 @@ public const val CACHE_KEY_ACL: String = "acl:*" * @param fileSystem the [FileSystem] associated with this [AttributeCachingPath] instance. * @param delegate the [Path] to forward calls to if needed. */ -internal class AttributeCachingPath( - private val fileSystem: FileSystem, - internal val delegate: Path, -) : ForwardingPath(delegate) { +internal class AttributeCachingPath(private val fileSystem: FileSystem, internal val delegate: Path) : + ForwardingPath(delegate) { private val delegateSupportedFileAttributeViews = delegate.fileSystem.supportedFileAttributeViews() diff --git a/file-attribute-caching/src/main/kotlin/com/pkware/filesystem/forwarding/ForwardingFileSystemProvider.kt b/file-attribute-caching/src/main/kotlin/com/pkware/filesystem/forwarding/ForwardingFileSystemProvider.kt index 45da160..daa6d90 100644 --- a/file-attribute-caching/src/main/kotlin/com/pkware/filesystem/forwarding/ForwardingFileSystemProvider.kt +++ b/file-attribute-caching/src/main/kotlin/com/pkware/filesystem/forwarding/ForwardingFileSystemProvider.kt @@ -56,11 +56,8 @@ public abstract class ForwardingFileSystemProvider(private val delegate: FileSys delegate.delete(path) } - override fun readAttributes( - path: Path, - type: Class, - vararg options: LinkOption, - ): A = delegate.readAttributes(path, type, *options) + override fun readAttributes(path: Path, type: Class, vararg options: LinkOption): A = + delegate.readAttributes(path, type, *options) override fun readAttributes(path: Path, attributes: String, vararg options: LinkOption): MutableMap = delegate.readAttributes(path, attributes, *options) diff --git a/file-attribute-caching/src/test/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingFileSystemTests.kt b/file-attribute-caching/src/test/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingFileSystemTests.kt index 446fcaa..ddc47a5 100644 --- a/file-attribute-caching/src/test/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingFileSystemTests.kt +++ b/file-attribute-caching/src/test/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingFileSystemTests.kt @@ -196,13 +196,12 @@ class AttributeCachingFileSystemTests { @ParameterizedTest @MethodSource("allFileSystems") - fun `getName returns a cachingPath`(fileSystem: FileSystem) = - AttributeCachingFileSystem.wrapping(fileSystem).use { - val cachingPath = it.getPath("test.txt") - val closestToRootPathName = cachingPath.getName(0) - assertThat(cachingPath).isInstanceOf(AttributeCachingPath::class.java) - assertThat(closestToRootPathName).isInstanceOf(AttributeCachingPath::class.java) - } + fun `getName returns a cachingPath`(fileSystem: FileSystem) = AttributeCachingFileSystem.wrapping(fileSystem).use { + val cachingPath = it.getPath("test.txt") + val closestToRootPathName = cachingPath.getName(0) + assertThat(cachingPath).isInstanceOf(AttributeCachingPath::class.java) + assertThat(closestToRootPathName).isInstanceOf(AttributeCachingPath::class.java) + } @ParameterizedTest @MethodSource("allFileSystems") @@ -794,9 +793,7 @@ class AttributeCachingFileSystemTests { @ParameterizedTest @MethodSource("allFileSystems") - fun `cached attributes do not get modified by concurrent operation`( - fileSystem: FileSystem, - ) { + fun `cached attributes do not get modified by concurrent operation`(fileSystem: FileSystem) { val tempDirPath = fileSystem.getPath("temp") AttributeCachingFileSystem.wrapping(fileSystem).use { @@ -843,10 +840,7 @@ class AttributeCachingFileSystemTests { @ParameterizedTest @MethodSource("allFileSystemsWithCopyOption") - fun `copy file from source to target`( - option: CopyOption, - fileSystem: () -> FileSystem, - ) { + fun `copy file from source to target`(option: CopyOption, fileSystem: () -> FileSystem) { val testFileSystem = fileSystem() AttributeCachingFileSystem.wrapping(testFileSystem).use { // get filesystem attribute caching path @@ -916,10 +910,7 @@ class AttributeCachingFileSystemTests { @ParameterizedTest @MethodSource("allFileSystemsWithMoveOption") - fun `move file from source to target`( - option: CopyOption, - fileSystem: () -> FileSystem, - ) { + fun `move file from source to target`(option: CopyOption, fileSystem: () -> FileSystem) { val testFileSystem = fileSystem() AttributeCachingFileSystem.wrapping(testFileSystem).use { // get filesystem attribute caching path @@ -1006,16 +997,13 @@ class AttributeCachingFileSystemTests { @DisabledOnOs(OS.WINDOWS) @ParameterizedTest @MethodSource("hiddenTestPathsPosix") - fun `file isHidden on unix and macOS`( - fileName: String, - expectedHidden: Boolean, - fileSystem: () -> FileSystem, - ) = AttributeCachingFileSystem.wrapping(fileSystem()).use { - val directoryName = "temp" - Files.createDirectory(it.getPath(directoryName)) - val cachingPath = it.getPath(directoryName, fileName) - assertThat(Files.isHidden(cachingPath)).isEqualTo(expectedHidden) - } + fun `file isHidden on unix and macOS`(fileName: String, expectedHidden: Boolean, fileSystem: () -> FileSystem) = + AttributeCachingFileSystem.wrapping(fileSystem()).use { + val directoryName = "temp" + Files.createDirectory(it.getPath(directoryName)) + val cachingPath = it.getPath(directoryName, fileName) + assertThat(Files.isHidden(cachingPath)).isEqualTo(expectedHidden) + } @Test fun `only commonly supported attribute views are transferred when copying across filesystems`() { @@ -1162,10 +1150,8 @@ class AttributeCachingFileSystemTests { .build(), ) - private fun ComparableSubject.followedFlagRulesComparedTo( - options: CopyOption, - expected: FileTime, - ) = if (options == StandardCopyOption.COPY_ATTRIBUTES) isEqualTo(expected) else isNotEqualTo(expected) + private fun ComparableSubject.followedFlagRulesComparedTo(options: CopyOption, expected: FileTime) = + if (options == StandardCopyOption.COPY_ATTRIBUTES) isEqualTo(expected) else isNotEqualTo(expected) private fun getOsString(fileSystem: FileSystem): String { val supportedViews = fileSystem.supportedFileAttributeViews() diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8b9aade..292961e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] detektVersion = "1.23.1" junitVersion = "5.10.3" -ktlintVersion = "11.6.1" +ktlintVersion = "13.0.0" log4jVersion = "2.25.1" [libraries]