• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

spotbugs / spotbugs-maven-plugin / 2443

15 Jun 2025 11:09PM UTC coverage: 19.716%. Remained the same
2443

push

github

web-flow
Merge pull request #1079 from hazendaz/nio

Adjustments to handle auto generated groovy code on test path as well

35 of 616 branches covered (5.68%)

Branch coverage included in aggregate %.

0 of 1 new or added line in 1 file covered. (0.0%)

298 of 1073 relevant lines covered (27.77%)

0.28 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/stubfixer/java/com/github/spotbugs/StubOverrideFixer.java
1
/*
2
 * Copyright 2005-2025 the original author or authors.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     https://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package com.github.spotbugs;
17

18
import com.github.javaparser.ParseProblemException;
19
import com.github.javaparser.StaticJavaParser;
20
import com.github.javaparser.ast.CompilationUnit;
21
import com.github.javaparser.ast.body.MethodDeclaration;
22

23
import java.io.IOException;
24
import java.nio.charset.StandardCharsets;
25
import java.nio.file.Files;
26
import java.nio.file.Path;
27
import java.util.Set;
28
import java.util.stream.Stream;
29

30
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
32

33
public class StubOverrideFixer {
×
34

35
    private static Logger logger = LoggerFactory.getLogger(StubOverrideFixer.class);
×
36

37
    private static final Set<String> GROOVY_METHODS = Set.of("getMetaClass", "setMetaClass", "invokeMethod",
×
38
            "getProperty", "setProperty");
39

40
    public static void main(String[] args) throws IOException {
41
        Path stubsDir = Path.of(args[0]);
×
42
        try (Stream<Path> stream = Files.walk(stubsDir)) {
×
43
            stream.filter(p -> p.toString().endsWith(".java")).forEach(StubOverrideFixer::processStub);
×
44
        }
45
    }
×
46

47
    private static void processStub(Path filePath) {
48
        try {
49
            CompilationUnit cu = StaticJavaParser.parse(filePath);
×
50

51
            cu.findAll(MethodDeclaration.class).forEach(method -> {
×
52
                if (shouldHaveOverride(method)) {
×
NEW
53
                    method.addAnnotation("java.lang.Override");
×
54
                }
55
            });
×
56

57
            Files.write(filePath, cu.toString().getBytes(StandardCharsets.UTF_8));
×
58
        } catch (IOException | ParseProblemException e) {
×
59
            logger.error("Error processing: {} - {}", filePath, e.getMessage());
×
60
        }
×
61
    }
×
62

63
    private static boolean shouldHaveOverride(MethodDeclaration method) {
64
        return GROOVY_METHODS.contains(method.getNameAsString());
×
65
    }
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc