Skip to content

Commit 0286c9a

Browse files
Update dependency org.jlleitschuh.gradle.ktlint to v13 (#29)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent 4668702 commit 0286c9a

7 files changed

Lines changed: 49 additions & 74 deletions

File tree

.editorconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ ij_kotlin_allow_trailing_comma_on_call_site = true
1515

1616
[*.{yml,yaml}]
1717
indent_size = 2
18-
tab_width = 2
18+
tab_width = 2
19+
20+
[*.kt*]
21+
ktlint_code_style = intellij_idea
22+
max_line_length = 120

file-attribute-caching/src/main/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingFileSystem.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ import java.util.UUID
1919
* @param delegate The [FileSystem] to wrap and forward calls to.
2020
* @param provider The [FileSystemProvider] associated with this [FileSystem].
2121
*/
22-
public class AttributeCachingFileSystem(
23-
delegate: FileSystem,
24-
private val provider: FileSystemProvider,
25-
) : ForwardingFileSystem(delegate) {
22+
public class AttributeCachingFileSystem(delegate: FileSystem, private val provider: FileSystemProvider) :
23+
ForwardingFileSystem(delegate) {
2624

2725
override fun provider(): FileSystemProvider = provider
2826

@@ -61,9 +59,7 @@ public class AttributeCachingFileSystem(
6159
* @throws IOException If an IO error occurs.
6260
*/
6361
@Throws(FileAlreadyExistsException::class, ProviderNotFoundException::class, IOException::class)
64-
public fun wrapping(
65-
fileSystem: FileSystem,
66-
): AttributeCachingFileSystem = FileSystems.newFileSystem(
62+
public fun wrapping(fileSystem: FileSystem): AttributeCachingFileSystem = FileSystems.newFileSystem(
6763
// Need to ensure a unique fileSystem name everytime this is called, hence UUID.randomUUID()
6864
URI.create("cache:///${UUID.randomUUID()}"),
6965
mapOf(Pair("filesystem", fileSystem)),

file-attribute-caching/src/main/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingFileSystemProvider.kt

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -292,18 +292,15 @@ internal class AttributeCachingFileSystemProvider : FileSystemProvider() {
292292
* given [type] are not supported.
293293
*/
294294
@Throws(IOException::class, UnsupportedOperationException::class)
295-
override fun <A : BasicFileAttributes?> readAttributes(
296-
path: Path,
297-
type: Class<A>,
298-
vararg options: LinkOption,
299-
): A = if (path is AttributeCachingPath) {
300-
val attributes = path.getAllAttributesMatchingClass(type) ?: throw UnsupportedOperationException(
301-
"Could not read attributes of type $type from the path $path and its delegate filesystem.",
302-
)
303-
attributes
304-
} else {
305-
path.fileSystem.provider().readAttributes(path, type, *options)
306-
}
295+
override fun <A : BasicFileAttributes?> readAttributes(path: Path, type: Class<A>, vararg options: LinkOption): A =
296+
if (path is AttributeCachingPath) {
297+
val attributes = path.getAllAttributesMatchingClass(type) ?: throw UnsupportedOperationException(
298+
"Could not read attributes of type $type from the path $path and its delegate filesystem.",
299+
)
300+
attributes
301+
} else {
302+
path.fileSystem.provider().readAttributes(path, type, *options)
303+
}
307304

308305
/**
309306
* 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() {
324321
* [FileSystemProvider].
325322
*/
326323
@Throws(IOException::class, UnsupportedOperationException::class, IllegalArgumentException::class)
327-
override fun readAttributes(
328-
path: Path,
329-
attributes: String,
330-
vararg options: LinkOption,
331-
): MutableMap<String, Any> = if (path is AttributeCachingPath) {
332-
val attributesMap = path.getAllAttributesMatchingNames(attributes) ?: throw IllegalArgumentException(
333-
"Could not read attributes $attributes of the path $path from the delegate filesystem.",
334-
)
335-
attributesMap
336-
} else {
337-
path.fileSystem.provider().readAttributes(path, attributes, *options)
338-
}
324+
override fun readAttributes(path: Path, attributes: String, vararg options: LinkOption): MutableMap<String, Any> =
325+
if (path is AttributeCachingPath) {
326+
val attributesMap = path.getAllAttributesMatchingNames(attributes) ?: throw IllegalArgumentException(
327+
"Could not read attributes $attributes of the path $path from the delegate filesystem.",
328+
)
329+
attributesMap
330+
} else {
331+
path.fileSystem.provider().readAttributes(path, attributes, *options)
332+
}
339333

340334
/**
341335
* Set a single attribute or attribute class (ie: "dos:*","basic:*","posix:permissions", etc.) for the given [path]

file-attribute-caching/src/main/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingPath.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ public const val CACHE_KEY_ACL: String = "acl:*"
4646
* @param fileSystem the [FileSystem] associated with this [AttributeCachingPath] instance.
4747
* @param delegate the [Path] to forward calls to if needed.
4848
*/
49-
internal class AttributeCachingPath(
50-
private val fileSystem: FileSystem,
51-
internal val delegate: Path,
52-
) : ForwardingPath(delegate) {
49+
internal class AttributeCachingPath(private val fileSystem: FileSystem, internal val delegate: Path) :
50+
ForwardingPath(delegate) {
5351

5452
private val delegateSupportedFileAttributeViews = delegate.fileSystem.supportedFileAttributeViews()
5553

file-attribute-caching/src/main/kotlin/com/pkware/filesystem/forwarding/ForwardingFileSystemProvider.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,8 @@ public abstract class ForwardingFileSystemProvider(private val delegate: FileSys
5656
delegate.delete(path)
5757
}
5858

59-
override fun <A : BasicFileAttributes?> readAttributes(
60-
path: Path,
61-
type: Class<A>,
62-
vararg options: LinkOption,
63-
): A = delegate.readAttributes(path, type, *options)
59+
override fun <A : BasicFileAttributes?> readAttributes(path: Path, type: Class<A>, vararg options: LinkOption): A =
60+
delegate.readAttributes(path, type, *options)
6461

6562
override fun readAttributes(path: Path, attributes: String, vararg options: LinkOption): MutableMap<String, Any> =
6663
delegate.readAttributes(path, attributes, *options)

file-attribute-caching/src/test/kotlin/com/pkware/filesystem/attributecaching/AttributeCachingFileSystemTests.kt

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,12 @@ class AttributeCachingFileSystemTests {
196196

197197
@ParameterizedTest
198198
@MethodSource("allFileSystems")
199-
fun `getName returns a cachingPath`(fileSystem: FileSystem) =
200-
AttributeCachingFileSystem.wrapping(fileSystem).use {
201-
val cachingPath = it.getPath("test.txt")
202-
val closestToRootPathName = cachingPath.getName(0)
203-
assertThat(cachingPath).isInstanceOf(AttributeCachingPath::class.java)
204-
assertThat(closestToRootPathName).isInstanceOf(AttributeCachingPath::class.java)
205-
}
199+
fun `getName returns a cachingPath`(fileSystem: FileSystem) = AttributeCachingFileSystem.wrapping(fileSystem).use {
200+
val cachingPath = it.getPath("test.txt")
201+
val closestToRootPathName = cachingPath.getName(0)
202+
assertThat(cachingPath).isInstanceOf(AttributeCachingPath::class.java)
203+
assertThat(closestToRootPathName).isInstanceOf(AttributeCachingPath::class.java)
204+
}
206205

207206
@ParameterizedTest
208207
@MethodSource("allFileSystems")
@@ -794,9 +793,7 @@ class AttributeCachingFileSystemTests {
794793

795794
@ParameterizedTest
796795
@MethodSource("allFileSystems")
797-
fun `cached attributes do not get modified by concurrent operation`(
798-
fileSystem: FileSystem,
799-
) {
796+
fun `cached attributes do not get modified by concurrent operation`(fileSystem: FileSystem) {
800797
val tempDirPath = fileSystem.getPath("temp")
801798

802799
AttributeCachingFileSystem.wrapping(fileSystem).use {
@@ -843,10 +840,7 @@ class AttributeCachingFileSystemTests {
843840

844841
@ParameterizedTest
845842
@MethodSource("allFileSystemsWithCopyOption")
846-
fun `copy file from source to target`(
847-
option: CopyOption,
848-
fileSystem: () -> FileSystem,
849-
) {
843+
fun `copy file from source to target`(option: CopyOption, fileSystem: () -> FileSystem) {
850844
val testFileSystem = fileSystem()
851845
AttributeCachingFileSystem.wrapping(testFileSystem).use {
852846
// get filesystem attribute caching path
@@ -916,10 +910,7 @@ class AttributeCachingFileSystemTests {
916910

917911
@ParameterizedTest
918912
@MethodSource("allFileSystemsWithMoveOption")
919-
fun `move file from source to target`(
920-
option: CopyOption,
921-
fileSystem: () -> FileSystem,
922-
) {
913+
fun `move file from source to target`(option: CopyOption, fileSystem: () -> FileSystem) {
923914
val testFileSystem = fileSystem()
924915
AttributeCachingFileSystem.wrapping(testFileSystem).use {
925916
// get filesystem attribute caching path
@@ -1006,16 +997,13 @@ class AttributeCachingFileSystemTests {
1006997
@DisabledOnOs(OS.WINDOWS)
1007998
@ParameterizedTest
1008999
@MethodSource("hiddenTestPathsPosix")
1009-
fun `file isHidden on unix and macOS`(
1010-
fileName: String,
1011-
expectedHidden: Boolean,
1012-
fileSystem: () -> FileSystem,
1013-
) = AttributeCachingFileSystem.wrapping(fileSystem()).use {
1014-
val directoryName = "temp"
1015-
Files.createDirectory(it.getPath(directoryName))
1016-
val cachingPath = it.getPath(directoryName, fileName)
1017-
assertThat(Files.isHidden(cachingPath)).isEqualTo(expectedHidden)
1018-
}
1000+
fun `file isHidden on unix and macOS`(fileName: String, expectedHidden: Boolean, fileSystem: () -> FileSystem) =
1001+
AttributeCachingFileSystem.wrapping(fileSystem()).use {
1002+
val directoryName = "temp"
1003+
Files.createDirectory(it.getPath(directoryName))
1004+
val cachingPath = it.getPath(directoryName, fileName)
1005+
assertThat(Files.isHidden(cachingPath)).isEqualTo(expectedHidden)
1006+
}
10191007

10201008
@Test
10211009
fun `only commonly supported attribute views are transferred when copying across filesystems`() {
@@ -1162,10 +1150,8 @@ class AttributeCachingFileSystemTests {
11621150
.build(),
11631151
)
11641152

1165-
private fun ComparableSubject<FileTime>.followedFlagRulesComparedTo(
1166-
options: CopyOption,
1167-
expected: FileTime,
1168-
) = if (options == StandardCopyOption.COPY_ATTRIBUTES) isEqualTo(expected) else isNotEqualTo(expected)
1153+
private fun ComparableSubject<FileTime>.followedFlagRulesComparedTo(options: CopyOption, expected: FileTime) =
1154+
if (options == StandardCopyOption.COPY_ATTRIBUTES) isEqualTo(expected) else isNotEqualTo(expected)
11691155

11701156
private fun getOsString(fileSystem: FileSystem): String {
11711157
val supportedViews = fileSystem.supportedFileAttributeViews()

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[versions]
22
detektVersion = "1.23.1"
33
junitVersion = "5.10.3"
4-
ktlintVersion = "11.6.1"
4+
ktlintVersion = "13.0.0"
55
log4jVersion = "2.25.1"
66

77
[libraries]

0 commit comments

Comments
 (0)