diff --git a/dev/checkstyle/checkstyle.xml b/dev/checkstyle/checkstyle.xml index 9f19037..2317e0d 100644 --- a/dev/checkstyle/checkstyle.xml +++ b/dev/checkstyle/checkstyle.xml @@ -33,7 +33,6 @@ <!-- File must start with the C Thing copyright header --> <module name="RegexpHeader"> <property name="headerFile" value="${config_loc}/header.txt"/> - <property name="multiLines" value="3"/> </module> <!-- Flag IDE generated comments --> diff --git a/dev/checkstyle/header.txt b/dev/checkstyle/header.txt index c448c3c..11bd74f 100644 --- a/dev/checkstyle/header.txt +++ b/dev/checkstyle/header.txt @@ -1,14 +1,3 @@ ^/\*$ ^ \* Copyright [\d]{4}((,[\s]*[\d]{4})*|(-[\d]{4})?) C Thing Software$ -^ \*$ -^ \* Licensed under the Apache License, Version 2\.0 \(the "License"\);$ -^ \* you may not use this file except in compliance with the License\.$ -^ \* You may obtain a copy of the License at$ -^ \*$ -^ \* http://www\.apache\.org/licenses/LICENSE-2\.0$ -^ \*$ -^ \* Unless required by applicable law or agreed to in writing, software$ -^ \* distributed under the License is distributed on an "AS IS" BASIS,$ -^ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.$ -^ \* See the License for the specific language governing permissions and$ -^ \* limitations under the License\.$ +^ \* SPDX-License-Identifier: Apache-2.0$ diff --git a/src/main/java/org/cthing/filevisitor/CollectingMatchHandler.java b/src/main/java/org/cthing/filevisitor/CollectingMatchHandler.java index 013b03d..4c7ca5a 100644 --- a/src/main/java/org/cthing/filevisitor/CollectingMatchHandler.java +++ b/src/main/java/org/cthing/filevisitor/CollectingMatchHandler.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; @@ -68,6 +57,7 @@ public boolean file(final Path file, final BasicFileAttributes attrs) throws IOE } @Override + @SuppressWarnings("MethodDoesntCallSuperMethod") public boolean directory(final Path dir, final BasicFileAttributes attrs) { if (this.includeDirectories) { this.paths.add(dir); diff --git a/src/main/java/org/cthing/filevisitor/GitIgnore.java b/src/main/java/org/cthing/filevisitor/GitIgnore.java index 27d14a1..4a83ad5 100644 --- a/src/main/java/org/cthing/filevisitor/GitIgnore.java +++ b/src/main/java/org/cthing/filevisitor/GitIgnore.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/main/java/org/cthing/filevisitor/GitUtils.java b/src/main/java/org/cthing/filevisitor/GitUtils.java index 871d8ce..ed44a23 100644 --- a/src/main/java/org/cthing/filevisitor/GitUtils.java +++ b/src/main/java/org/cthing/filevisitor/GitUtils.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/main/java/org/cthing/filevisitor/Glob.java b/src/main/java/org/cthing/filevisitor/Glob.java index ee388be..f799480 100644 --- a/src/main/java/org/cthing/filevisitor/Glob.java +++ b/src/main/java/org/cthing/filevisitor/Glob.java @@ -1,23 +1,13 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -200,11 +190,11 @@ static class Token { * @param negated {@code true} if the token excludes rather than includes the characters in the class * @param ranges Characters in the character class */ - Token(final boolean negated, final List<CharRange> ranges) { + Token(final boolean negated, final Collection<CharRange> ranges) { this.type = TokenType.CharClass; this.ch = 0; this.negated = negated; - this.ranges = ranges; + this.ranges = List.copyOf(ranges); } @Override diff --git a/src/main/java/org/cthing/filevisitor/MatchHandler.java b/src/main/java/org/cthing/filevisitor/MatchHandler.java index 3c2e365..747f77b 100644 --- a/src/main/java/org/cthing/filevisitor/MatchHandler.java +++ b/src/main/java/org/cthing/filevisitor/MatchHandler.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/main/java/org/cthing/filevisitor/MatchingException.java b/src/main/java/org/cthing/filevisitor/MatchingException.java index d93df17..b5bc0dc 100644 --- a/src/main/java/org/cthing/filevisitor/MatchingException.java +++ b/src/main/java/org/cthing/filevisitor/MatchingException.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/main/java/org/cthing/filevisitor/MatchingFileVisitor.java b/src/main/java/org/cthing/filevisitor/MatchingFileVisitor.java index 74d5cfc..d5b7e04 100644 --- a/src/main/java/org/cthing/filevisitor/MatchingFileVisitor.java +++ b/src/main/java/org/cthing/filevisitor/MatchingFileVisitor.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; @@ -87,7 +76,7 @@ public MatchingFileVisitor(final MatchHandler matchHandler, final String... matc */ public MatchingFileVisitor(final MatchHandler matchHandler, final List<String> matchPatterns) { this.handler = matchHandler; - this.matchPatterns = matchPatterns; + this.matchPatterns = List.copyOf(matchPatterns); this.contextStack = new ArrayDeque<>(); this.baseIgnores = new ArrayList<>(); this.excludeHidden = true; diff --git a/src/main/java/org/cthing/filevisitor/MatchingTreeWalker.java b/src/main/java/org/cthing/filevisitor/MatchingTreeWalker.java index 949d631..bcc2fbf 100644 --- a/src/main/java/org/cthing/filevisitor/MatchingTreeWalker.java +++ b/src/main/java/org/cthing/filevisitor/MatchingTreeWalker.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/main/java/org/cthing/filevisitor/PathUtils.java b/src/main/java/org/cthing/filevisitor/PathUtils.java index ea9d3ac..dde9b47 100644 --- a/src/main/java/org/cthing/filevisitor/PathUtils.java +++ b/src/main/java/org/cthing/filevisitor/PathUtils.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/main/java/org/cthing/filevisitor/RegexUtils.java b/src/main/java/org/cthing/filevisitor/RegexUtils.java index ee166b4..070d678 100644 --- a/src/main/java/org/cthing/filevisitor/RegexUtils.java +++ b/src/main/java/org/cthing/filevisitor/RegexUtils.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/main/java/org/cthing/filevisitor/StringIterator.java b/src/main/java/org/cthing/filevisitor/StringIterator.java index 8bb8989..3857eac 100644 --- a/src/main/java/org/cthing/filevisitor/StringIterator.java +++ b/src/main/java/org/cthing/filevisitor/StringIterator.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/main/java/org/cthing/filevisitor/StringUtils.java b/src/main/java/org/cthing/filevisitor/StringUtils.java index ffb6f17..a4dc978 100644 --- a/src/main/java/org/cthing/filevisitor/StringUtils.java +++ b/src/main/java/org/cthing/filevisitor/StringUtils.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/main/java/org/cthing/filevisitor/package-info.java b/src/main/java/org/cthing/filevisitor/package-info.java index e461f0a..bbad18a 100644 --- a/src/main/java/org/cthing/filevisitor/package-info.java +++ b/src/main/java/org/cthing/filevisitor/package-info.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ /** diff --git a/src/test/java/org/cthing/filevisitor/FileTreeExtension.java b/src/test/java/org/cthing/filevisitor/FileTreeExtension.java index 60d5ed3..20ced18 100644 --- a/src/test/java/org/cthing/filevisitor/FileTreeExtension.java +++ b/src/test/java/org/cthing/filevisitor/FileTreeExtension.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; @@ -21,6 +10,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.Comparator; +import java.util.stream.Stream; import org.junit.jupiter.api.extension.AfterEachCallback; import org.junit.jupiter.api.extension.BeforeEachCallback; @@ -135,7 +125,9 @@ public Object resolveParameter(final ParameterContext parameterContext, private static void deleteAll(final Path root) throws IOException { if (Files.exists(root)) { - Files.walk(root).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); + try (Stream<Path> fileStream = Files.walk(root)) { + fileStream.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); + } } } } diff --git a/src/test/java/org/cthing/filevisitor/GitConfigTest.java b/src/test/java/org/cthing/filevisitor/GitConfigTest.java index 517b156..6d0d33a 100644 --- a/src/test/java/org/cthing/filevisitor/GitConfigTest.java +++ b/src/test/java/org/cthing/filevisitor/GitConfigTest.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/test/java/org/cthing/filevisitor/GitIgnoreTest.java b/src/test/java/org/cthing/filevisitor/GitIgnoreTest.java index 42a9385..ca43d98 100644 --- a/src/test/java/org/cthing/filevisitor/GitIgnoreTest.java +++ b/src/test/java/org/cthing/filevisitor/GitIgnoreTest.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/test/java/org/cthing/filevisitor/GitUtilsTest.java b/src/test/java/org/cthing/filevisitor/GitUtilsTest.java index 8eaea5a..e48ed96 100644 --- a/src/test/java/org/cthing/filevisitor/GitUtilsTest.java +++ b/src/test/java/org/cthing/filevisitor/GitUtilsTest.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/test/java/org/cthing/filevisitor/GlobTest.java b/src/test/java/org/cthing/filevisitor/GlobTest.java index 07b166f..2631bb4 100644 --- a/src/test/java/org/cthing/filevisitor/GlobTest.java +++ b/src/test/java/org/cthing/filevisitor/GlobTest.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/test/java/org/cthing/filevisitor/MatchingFileVisitorTest.java b/src/test/java/org/cthing/filevisitor/MatchingFileVisitorTest.java index 8bea84b..4c3de5b 100644 --- a/src/test/java/org/cthing/filevisitor/MatchingFileVisitorTest.java +++ b/src/test/java/org/cthing/filevisitor/MatchingFileVisitorTest.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; @@ -727,6 +716,7 @@ public boolean file(final Path file, final BasicFileAttributes attrs) throws IOE } @Override + @SuppressWarnings("MethodDoesntCallSuperMethod") public boolean directory(final Path dir, final BasicFileAttributes attrs) throws IOException { if (dir.equals(this.terminatingDir)) { throw new IOException("Expected exception"); diff --git a/src/test/java/org/cthing/filevisitor/MatchingTreeWalkerTest.java b/src/test/java/org/cthing/filevisitor/MatchingTreeWalkerTest.java index 19ca19f..f58323a 100644 --- a/src/test/java/org/cthing/filevisitor/MatchingTreeWalkerTest.java +++ b/src/test/java/org/cthing/filevisitor/MatchingTreeWalkerTest.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; @@ -773,6 +762,7 @@ public boolean file(final Path file, final BasicFileAttributes attrs) throws IOE } @Override + @SuppressWarnings("MethodDoesntCallSuperMethod") public boolean directory(final Path dir, final BasicFileAttributes attrs) throws IOException { if (dir.equals(this.terminatingDir)) { throw new IOException("Expected exception"); diff --git a/src/test/java/org/cthing/filevisitor/PathUtilsTest.java b/src/test/java/org/cthing/filevisitor/PathUtilsTest.java index e1c8c78..30995ff 100644 --- a/src/test/java/org/cthing/filevisitor/PathUtilsTest.java +++ b/src/test/java/org/cthing/filevisitor/PathUtilsTest.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/test/java/org/cthing/filevisitor/RegexUtilsTest.java b/src/test/java/org/cthing/filevisitor/RegexUtilsTest.java index 06be96d..986ba20 100644 --- a/src/test/java/org/cthing/filevisitor/RegexUtilsTest.java +++ b/src/test/java/org/cthing/filevisitor/RegexUtilsTest.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/test/java/org/cthing/filevisitor/StringIteratorTest.java b/src/test/java/org/cthing/filevisitor/StringIteratorTest.java index 8fb6a79..e311fce 100644 --- a/src/test/java/org/cthing/filevisitor/StringIteratorTest.java +++ b/src/test/java/org/cthing/filevisitor/StringIteratorTest.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/test/java/org/cthing/filevisitor/StringUtilsTest.java b/src/test/java/org/cthing/filevisitor/StringUtilsTest.java index 6969c43..71d019c 100644 --- a/src/test/java/org/cthing/filevisitor/StringUtilsTest.java +++ b/src/test/java/org/cthing/filevisitor/StringUtilsTest.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; diff --git a/src/test/java/org/cthing/filevisitor/TestHomeExtension.java b/src/test/java/org/cthing/filevisitor/TestHomeExtension.java index 109bbff..2492958 100644 --- a/src/test/java/org/cthing/filevisitor/TestHomeExtension.java +++ b/src/test/java/org/cthing/filevisitor/TestHomeExtension.java @@ -1,17 +1,6 @@ /* * Copyright 2024 C Thing Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: Apache-2.0 */ package org.cthing.filevisitor; @@ -20,6 +9,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.Comparator; +import java.util.stream.Stream; import org.junit.jupiter.api.extension.BeforeEachCallback; import org.junit.jupiter.api.extension.ExtensionContext; @@ -38,7 +28,9 @@ class TestHomeExtension implements BeforeEachCallback { @SuppressWarnings("ResultOfMethodCallIgnored") public void beforeEach(final ExtensionContext context) throws Exception { if (Files.exists(TEST_HOME)) { - Files.walk(TEST_HOME).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); + try (Stream<Path> fileStream = Files.walk(TEST_HOME)) { + fileStream.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); + } } Files.createDirectories(TEST_HOME); }