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

oracle / opengrok / #3691

09 Nov 2023 04:15PM UTC coverage: 74.721% (+8.6%) from 66.08%
#3691

push

web-flow
avoid annotations for binary files (#4476)

fixes #4473

6 of 13 new or added lines in 4 files covered. (46.15%)

258 existing lines in 28 files now uncovered.

43797 of 58614 relevant lines covered (74.72%)

0.75 hits per line

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

0.0
/opengrok-indexer/src/main/java/org/opengrok/indexer/history/RCSAnnotationParser.java
1
/*
2
 * CDDL HEADER START
3
 *
4
 * The contents of this file are subject to the terms of the
5
 * Common Development and Distribution License (the "License").
6
 * You may not use this file except in compliance with the License.
7
 *
8
 * See LICENSE.txt included in this distribution for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing Covered Code, include this CDDL HEADER in each
12
 * file and include the License file at LICENSE.txt.
13
 * If applicable, add the following below this CDDL HEADER, with the
14
 * fields enclosed by brackets "[]" replaced with your own identifying
15
 * information: Portions Copyright [yyyy] [name of copyright owner]
16
 *
17
 * CDDL HEADER END
18
 */
19

20
/*
21
 * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
22
 */
23
package org.opengrok.indexer.history;
24

25
import org.opengrok.indexer.logger.LoggerFactory;
26
import org.opengrok.indexer.util.Executor;
27

28
import java.io.IOException;
29
import java.io.BufferedReader;
30
import java.io.File;
31
import java.io.InputStream;
32
import java.io.InputStreamReader;
33
import java.util.logging.Level;
34
import java.util.logging.Logger;
35
import java.util.regex.Matcher;
36
import java.util.regex.Pattern;
37

38
public class RCSAnnotationParser implements Executor.StreamHandler {
UNCOV
39
    private static final Logger LOGGER = LoggerFactory.getLogger(RCSAnnotationParser.class);
×
40

UNCOV
41
    private Annotation annotation = null;
×
42
    private final File file;
43

44
    /**
45
     * Pattern used to extract author/revision from {@code blame}.
46
     */
UNCOV
47
    private static final Pattern ANNOTATION_PATTERN
×
UNCOV
48
            = Pattern.compile("^([\\d\\.]+)\\s*\\((\\S+)\\s*\\S+\\): ");
×
49

UNCOV
50
    RCSAnnotationParser(File file) {
×
UNCOV
51
        this.file = file;
×
UNCOV
52
    }
×
53

54
    @Override
55
    public void processStream(InputStream input) throws IOException {
56
        annotation = new Annotation(file.getName());
×
57
        String line;
58
        int lineno = 0;
×
59
        Matcher matcher = ANNOTATION_PATTERN.matcher("");
×
60

61
        try (BufferedReader in = new BufferedReader(new InputStreamReader(input))) {
×
62
            while ((line = in.readLine()) != null) {
×
63
                ++lineno;
×
64
                matcher.reset(line);
×
65
                if (matcher.find()) {
×
66
                    String rev = matcher.group(1);
×
67
                    String author = matcher.group(2);
×
68
                    annotation.addLine(rev, author, true);
×
69
                } else {
×
70
                    LOGGER.log(Level.WARNING,
×
71
                            "Error: did not find annotation in line {0} for ''{1}'': [{2}]",
72
                            new Object[]{lineno, this.file, line});
×
73
                }
74
            }
75
        }
76
    }
×
77

78
    Annotation getAnnotation() {
UNCOV
79
        return this.annotation;
×
80
    }
81
}
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

© 2025 Coveralls, Inc