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

SAP / ui5-linter / 11818212773

13 Nov 2024 01:24PM CUT coverage: 82.058% (+1.8%) from 80.287%
11818212773

Pull #327

github

web-flow
Merge eb2eebb35 into a024d44ca
Pull Request #327: feat: Add ui5lint-disable directives

1893 of 2438 branches covered (77.65%)

Branch coverage included in aggregate %.

117 of 121 new or added lines in 9 files covered. (96.69%)

5 existing lines in 1 file now uncovered.

2717 of 3180 relevant lines covered (85.44%)

2620.54 hits per line

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

67.65
/src/linter/html/HtmlReporter.ts
1
import {Tag as SaxTag, Text as SaxText, Position as SaxPosition} from "sax-wasm";
2
import LinterContext, {CoverageInfo, ResourcePath} from "../LinterContext.js";
3
import {MESSAGE} from "../messages.js";
4
import {MessageArgs} from "../MessageArgs.js";
5

6
interface ReporterCoverageInfo extends CoverageInfo {
7
        node: SaxTag;
8
}
9

10
export default class HtmlReporter {
11
        #resourcePath: string;
12
        #context: LinterContext;
13

14
        constructor(resourcePath: ResourcePath, context: LinterContext) {
15
                this.#resourcePath = resourcePath;
77✔
16
                this.#context = context;
77✔
17
        }
18

19
        addMessage<M extends MESSAGE>(id: M, args: MessageArgs[M], node: SaxTag | SaxText): void;
20
        addMessage<M extends MESSAGE>(id: M, node: SaxTag | SaxText): void;
21
        addMessage<M extends MESSAGE>(
22
                id: M, argsOrNode?: MessageArgs[M] | SaxTag | SaxText, node?: SaxTag | SaxText
23
        ) {
24
                if (!argsOrNode) {
243!
25
                        throw new Error("Invalid arguments: Missing second argument");
×
26
                }
27
                let args: MessageArgs[M];
28
                if (argsOrNode instanceof SaxTag) {
243✔
29
                        node = argsOrNode;
18✔
30
                        args = null as unknown as MessageArgs[M];
18✔
31
                } else if (argsOrNode instanceof SaxText) {
225✔
32
                        node = argsOrNode;
3✔
33
                        args = null as unknown as MessageArgs[M];
3✔
34
                } else if (!node) {
222!
35
                        throw new Error("Invalid arguments: Missing 'node'");
×
36
                } else {
37
                        args = argsOrNode;
222✔
38
                }
39

40
                let startPos: SaxPosition;
41
                if (node instanceof SaxTag) {
243✔
42
                        startPos = node.openStart;
38✔
43
                } else {
44
                        startPos = node.start;
205✔
45
                }
46
                this.#context.addLintingMessage(this.#resourcePath, id, args, {
243✔
47
                        line: startPos.line + 1,
48
                        column: startPos.character + 1,
49
                });
50
        }
51

52
        addCoverageInfo({node, message, category}: ReporterCoverageInfo) {
53
                let line = 0, column = 0, endLine = 0, endColumn = 0;
×
54
                if (node instanceof SaxTag) {
×
55
                        ({line, character: column} = node.openStart);
×
56
                        ({line: endLine, character: endColumn} = node.closeEnd);
×
57
                }
58

59
                this.#context.addCoverageInfo(this.#resourcePath, {
×
60
                        category,
61
                        // One-based to be aligned with most IDEs
62
                        line: line + 1,
63
                        column: column + 1,
64
                        endLine: endLine + 1,
65
                        endColumn: endColumn + 1,
66
                        message,
67
                });
68
        }
69
}
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