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

hazendaz / jmockit1 / 496

15 Nov 2025 05:33PM UTC coverage: 72.192% (-0.008%) from 72.2%
496

push

github

web-flow
Merge pull request #412 from hazendaz/renovate/major-spring-core

Update spring core to v7 (major)

5677 of 8360 branches covered (67.91%)

Branch coverage included in aggregate %.

11922 of 16018 relevant lines covered (74.43%)

0.74 hits per line

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

0.0
/main/src/main/java/mockit/coverage/CoveragePercentage.java
1
/*
2
 * MIT License
3
 * Copyright (c) 2006-2025 JMockit developers
4
 * See LICENSE file for full license text.
5
 */
6
package mockit.coverage;
7

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

10
import org.checkerframework.checker.index.qual.NonNegative;
11

12
public final class CoveragePercentage {
13
    private CoveragePercentage() {
14
    }
15

16
    public static int calculate(@NonNegative int coveredCount, @NonNegative int totalCount) {
17
        if (totalCount == 0) {
×
18
            return -1;
×
19
        }
20

21
        // noinspection NumericCastThatLosesPrecision
22
        return (int) (100.0 * coveredCount / totalCount + 0.5);
×
23
    }
24

25
    @NonNull
26
    public static String percentageColor(@NonNegative int coveredCount, @NonNegative int totalCount) {
27
        if (coveredCount == 0) {
×
28
            return "ff0000";
×
29
        }
30
        if (coveredCount == totalCount) {
×
31
            return "00ff00";
×
32
        }
33

34
        double percentage = 100.0 * coveredCount / totalCount;
×
35
        // noinspection NumericCastThatLosesPrecision
36
        int green = (int) (0xFF * percentage / 100.0 + 0.5);
×
37
        int red = 0xFF - green;
×
38

39
        StringBuilder color = new StringBuilder(6);
×
40
        appendColorInHexadecimal(color, red);
×
41
        appendColorInHexadecimal(color, green);
×
42
        color.append("00");
×
43

44
        return color.toString();
×
45
    }
46

47
    private static void appendColorInHexadecimal(@NonNull StringBuilder colorInHexa, @NonNegative int rgb) {
48
        String hex = Integer.toHexString(rgb);
×
49

50
        if (hex.length() == 1) {
×
51
            colorInHexa.append('0');
×
52
        }
53

54
        colorInHexa.append(hex);
×
55
    }
×
56
}
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