Skip to content

Commit

Permalink
Use the SPDX license header. Fix a few warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
baron1405 committed Jun 14, 2024
1 parent 3703b5e commit f32355a
Show file tree
Hide file tree
Showing 27 changed files with 41 additions and 318 deletions.
1 change: 0 additions & 1 deletion dev/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down
13 changes: 1 addition & 12 deletions dev/checkstyle/header.txt
Original file line number Diff line number Diff line change
@@ -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$
14 changes: 2 additions & 12 deletions src/main/java/org/cthing/filevisitor/CollectingMatchHandler.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/org/cthing/filevisitor/GitIgnore.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/org/cthing/filevisitor/GitUtils.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
18 changes: 4 additions & 14 deletions src/main/java/org/cthing/filevisitor/Glob.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/org/cthing/filevisitor/MatchHandler.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/org/cthing/filevisitor/MatchingException.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
15 changes: 2 additions & 13 deletions src/main/java/org/cthing/filevisitor/MatchingFileVisitor.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/org/cthing/filevisitor/MatchingTreeWalker.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/org/cthing/filevisitor/PathUtils.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/org/cthing/filevisitor/RegexUtils.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/org/cthing/filevisitor/StringIterator.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/org/cthing/filevisitor/StringUtils.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/org/cthing/filevisitor/package-info.java
Original file line number Diff line number Diff line change
@@ -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
*/

/**
Expand Down
18 changes: 5 additions & 13 deletions src/test/java/org/cthing/filevisitor/FileTreeExtension.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
}
13 changes: 1 addition & 12 deletions src/test/java/org/cthing/filevisitor/GitConfigTest.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
13 changes: 1 addition & 12 deletions src/test/java/org/cthing/filevisitor/GitIgnoreTest.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Loading

0 comments on commit f32355a

Please sign in to comment.