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

jiangxincode / ApkToolBoxGUI / #1171

06 Sep 2025 02:10PM UTC coverage: 2.891%. Remained the same
#1171

push

jiangxincode
[PMD issues]Fix PMD issues: BigIntegerInstantiation

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

248 of 8579 relevant lines covered (2.89%)

0.03 hits per line

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

0.0
/src/main/java/edu/jiangxin/apktoolbox/convert/protobuf/unsupervised/VarintUtils.java
1
package edu.jiangxin.apktoolbox.convert.protobuf.unsupervised;
2

3
import java.math.BigInteger;
4
import java.util.HashMap;
5
import java.util.Map;
6

7
public class VarintUtils {
×
8

9
    /**
10
     * 解码为有符号类型
11
     *
12
     * @param bigInteger
13
     * @return
14
     */
15
    protected static BigInteger interpretAsSignedType(BigInteger bigInteger){
NEW
16
        BigInteger i = bigInteger.and(BigInteger.ONE);
×
NEW
17
        if (i.equals(BigInteger.ZERO)) {
×
NEW
18
            return bigInteger.divide(BigInteger.TWO);
×
19
        }
NEW
20
        return new BigInteger("-1").multiply(bigInteger.add(BigInteger.ONE).divide(BigInteger.TWO));
×
21
    }
22

23

24
    /**
25
     * 解码可变整数
26
     *
27
     * @param buffer
28
     * @param offset
29
     * @return
30
     */
31
    protected static Map<String, Object> decodeVarint(byte[] buffer, int offset) {
NEW
32
        BigInteger res = BigInteger.ZERO;
×
33
        int shift = 0;
×
34
        byte bytes;
35

36
        int count = 0;
×
37
        do {
38
            if (offset >= buffer.length) {
×
39
                throw new RuntimeException("Index out of bound decoding varint");
×
40
            }
41
            count++;
×
42
            bytes = buffer[offset++];
×
43

NEW
44
            BigInteger multiplier =  BigInteger.TWO.pow(shift);
×
45
            BigInteger thisByteValue = new BigInteger(Long.toString(bytes & 0x7f)).multiply(multiplier);
×
46
            shift += 7;
×
47
            res = res.add(thisByteValue);
×
48
        } while ((bytes & 0xff) >= 128 && count < 8);
×
49

50
        Map<String, Object> result = new HashMap<>(2);
×
51
        result.put("value", res);
×
52
        result.put("length", shift / 7);
×
53
        return result;
×
54
    }
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