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

Cognifide / AEM-Rules-for-SonarQube / #800

25 Oct 2024 02:25PM UTC coverage: 93.905% (-0.9%) from 94.773%
#800

push

tomasz-strzelecki-wttech
Fix SonarLint Java support

635 of 768 branches covered (82.68%)

28 of 58 new or added lines in 11 files covered. (48.28%)

3 existing lines in 2 files now uncovered.

1664 of 1772 relevant lines covered (93.91%)

0.94 hits per line

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

88.89
/src/main/java/com/vml/aemrules/htl/lex/DoctypeTokenizer.java
1
/*-
2
 * #%L
3
 * AEM Rules for SonarQube
4
 * %%
5
 * Copyright (C) 2015-2024 VML
6
 * %%
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *      http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 * #L%
19
 */
20
package com.vml.aemrules.htl.lex;
21

22
import org.sonar.plugins.html.node.Attribute;
23
import org.sonar.plugins.html.node.DirectiveNode;
24
import org.sonar.plugins.html.node.Node;
25

26
import java.io.IOException;
27
import java.io.Reader;
28
import java.io.StreamTokenizer;
29
import java.io.StringReader;
30
import java.util.List;
31

32
class DoctypeTokenizer extends AbstractTokenizer<List<Node>> {
33

34
    public DoctypeTokenizer(String startToken, String endToken) {
35
        super(startToken, endToken);
1✔
36
    }
1✔
37

38
    private static void parseToken(DirectiveNode node) {
39
        String code = node.getCode();
1✔
40
        try (Reader reader = new StringReader(code)) {
1✔
41
            StreamTokenizer tokenizer = new StreamTokenizer(reader);
1✔
42
            tokenizer.quoteChar('"');
1✔
43
            while (tokenizer.nextToken() != StreamTokenizer.TT_EOF) {
1✔
44
                if (tokenizer.sval != null) {
1✔
45
                    if (node.getNodeName() == null) {
1!
UNCOV
46
                        node.setNodeName(tokenizer.sval);
×
47
                    } else {
48
                        node.getAttributes().add(new Attribute(tokenizer.sval));
1✔
49
                    }
50
                }
51
            }
52
        } catch (IOException e) {
×
53
            // ignore
54
        }
1✔
55
    }
1✔
56

57
    @Override
58
    protected void addNode(List<Node> nodeList, Node node) {
59
        super.addNode(nodeList, node);
1✔
60
        parseToken((DirectiveNode) node);
1✔
61
    }
1✔
62

63
    @Override
64
    Node createNode() {
65
        return new DirectiveNode();
1✔
66
    }
67
}
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