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

pmd / pmd / 43

20 Jun 2025 06:39PM UTC coverage: 78.375% (-0.002%) from 78.377%
43

push

github

adangel
Fix #1639 #5832: Use filtered comment text for UnnecessaryImport (#5833)

Merged pull request #5833 from adangel:java/issue-5832-unnecessaryimport

17714 of 23438 branches covered (75.58%)

Branch coverage included in aggregate %.

3 of 3 new or added lines in 1 file covered. (100.0%)

109 existing lines in 17 files now uncovered.

38908 of 48807 relevant lines covered (79.72%)

0.81 hits per line

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

68.42
/pmd-core/src/main/java/net/sourceforge/pmd/PMDVersion.java
1
/**
2
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3
 */
4

5
package net.sourceforge.pmd;
6

7
import java.io.IOException;
8
import java.io.InputStream;
9
import java.util.Properties;
10

11
import org.slf4j.Logger;
12
import org.slf4j.LoggerFactory;
13

14
/**
15
 * Stores the current PMD version and provides utility methods around it.
16
 */
17
public final class PMDVersion {
18

19
    private static final Logger LOG = LoggerFactory.getLogger(PMDVersion.class);
1✔
20

21
    /**
22
     * Constant that contains always the current version of PMD.
23
     */
24
    public static final String VERSION;
25

26
    private static final String RELEASE_TIMESTAMP;
27
    private static final String GIT_COMMIT_ID;
28
    private static final String GIT_COMMIT_TIME;
29

30
    private static final String UNKNOWN = "unknown";
31

32
    /*
33
     * Determines the version from maven's generated pom.properties file.
34
     */
35
    static {
36
        String pmdVersion = UNKNOWN;
1✔
37
        String releaseTimestamp = UNKNOWN;
1✔
38
        String gitCommitId = UNKNOWN;
1✔
39
        String gitCommitTime = UNKNOWN;
1✔
40
        try (InputStream stream = PMDVersion.class.getResourceAsStream("pmd-core-version.properties")) {
1✔
41
            if (stream != null) {
1!
42
                final Properties properties = new Properties();
1✔
43
                properties.load(stream);
1✔
44
                pmdVersion = properties.getProperty("version");
1✔
45
                releaseTimestamp = properties.getProperty("releaseTimestamp");
1✔
46

47
                gitCommitId = properties.getProperty("gitCommitId");
1✔
48
                gitCommitTime = properties.getProperty("gitCommitTime");
1✔
49
            }
50
        } catch (final IOException e) {
×
51
            LOG.debug("Couldn't determine version of PMD", e);
×
52
        }
1✔
53

54
        VERSION = pmdVersion;
1✔
55
        RELEASE_TIMESTAMP = releaseTimestamp;
1✔
56
        GIT_COMMIT_ID = gitCommitId;
1✔
57
        GIT_COMMIT_TIME = gitCommitTime;
1✔
58
    }
1✔
59

60
    private PMDVersion() {
×
61
        throw new AssertionError("Can't instantiate utility classes");
×
62
    }
63

64
    /**
65
     * Retrieves the next major release to be expected.
66
     * Useful when logging deprecation messages to indicate when support will be removed.
67
     *
68
     * @return The next major release to be expected.
69
     */
70
    public static String getNextMajorRelease() {
71
        if (isUnknown()) {
1!
72
            return UNKNOWN;
×
73
        }
74

75
        final int major = Integer.parseInt(VERSION.split("\\.")[0]);
1✔
76
        return (major + 1) + ".0.0";
1✔
77
    }
78

79
    /**
80
     * Checks if the current version is unknown.
81
     * @return True if an unknown version, false otherwise
82
     */
83
    public static boolean isUnknown() {
84
        return UNKNOWN.equals(VERSION);
1✔
85
    }
86

87
    /**
88
     * Checks if the current version is a snapshot.
89
     * @return True if a snapshot release, false otherwise
90
     */
91
    public static boolean isSnapshot() {
92
        return VERSION.endsWith("-SNAPSHOT");
1✔
93
    }
94

95
    public static String getFullVersionName() {
UNCOV
96
        if (isSnapshot()) {
×
97
            return "PMD " + VERSION + " (" + GIT_COMMIT_ID + ", " + GIT_COMMIT_TIME + ")";
×
98
        }
UNCOV
99
        return "PMD " + VERSION + " (" + GIT_COMMIT_ID + ", " + RELEASE_TIMESTAMP + ")";
×
100
    }
101
}
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