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

hazendaz / jmockit1 / 85

26 Apr 2025 06:37PM UTC coverage: 73.285% (-0.02%) from 73.308%
85

push

github

web-flow
Merge pull request #327 from hazendaz/paths

Use nio more per modernizer and update more tests to junit 5

5625 of 8178 branches covered (68.78%)

Branch coverage included in aggregate %.

5 of 43 new or added lines in 14 files covered. (11.63%)

3 existing lines in 3 files now uncovered.

11885 of 15715 relevant lines covered (75.63%)

0.76 hits per line

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

0.0
/main/src/main/java/mockit/coverage/reporting/SourceFiles.java
1
/*
2
 * Copyright (c) 2006 JMockit developers
3
 * This file is subject to the terms of the MIT license (see LICENSE.txt).
4
 */
5
package mockit.coverage.reporting;
6

7
import edu.umd.cs.findbugs.annotations.NonNull;
8

9
import java.io.File;
10
import java.nio.file.Path;
11
import java.util.ArrayList;
12
import java.util.List;
13

14
final class SourceFiles {
×
15
    @NonNull
×
16
    private final List<File> srcDirs = new ArrayList<>();
17

18
    @NonNull
19
    List<File> buildListOfSourceDirectories(@NonNull String[] sourceDirs) {
20
        if (sourceDirs.length > 0) {
×
21
            buildListWithSpecifiedDirectories(sourceDirs);
×
22
        } else {
23
            buildListWithAllSrcSubDirectories();
×
24
        }
25

26
        return srcDirs;
×
27
    }
28

29
    private void buildListWithSpecifiedDirectories(@NonNull String[] dirs) {
30
        for (String dir : dirs) {
×
NEW
31
            File srcDir = Path.of(dir).toFile();
×
32

33
            if (srcDir.isDirectory()) {
×
34
                srcDirs.add(srcDir);
×
35
            }
36
        }
37

38
        if (srcDirs.isEmpty()) {
×
39
            throw new IllegalStateException("None of the specified source directories exist");
×
40
        }
41
    }
×
42

43
    private void buildListWithAllSrcSubDirectories() {
NEW
44
        String curDirName = Path.of(System.getProperty("user.dir")).toFile().getName();
×
NEW
45
        addSrcSubDirs(Path.of("../" + curDirName).toFile());
×
UNCOV
46
    }
×
47

48
    private void addSrcSubDirs(@NonNull File dir) {
49
        File[] files = dir.listFiles();
×
50
        if (files == null) {
×
51
            return;
×
52
        }
53

54
        for (File subDir : files) {
×
55
            if (subDir.isDirectory()) {
×
56
                String subDirName = subDir.getName();
×
57

58
                if ("src".equals(subDirName)) {
×
59
                    srcDirs.add(subDir);
×
60
                } else if (!isDirectoryToIgnore(subDirName)) {
×
61
                    addSrcSubDirs(subDir);
×
62
                }
63
            }
64
        }
65
    }
×
66

67
    private static final String IGNORED_DIRS = "bin build classes generated-sources out test tst web ";
68

69
    private static boolean isDirectoryToIgnore(@NonNull String subDirName) {
70
        int p = IGNORED_DIRS.indexOf(subDirName);
×
71
        return p >= 0 && IGNORED_DIRS.charAt(p + subDirName.length()) == ' ';
×
72
    }
73
}
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