Skip to content

Commit 865619b

Browse files
authored
Merge pull request #1668 from forcedotcom/d/W-17052953-b
CHANGE @W-17052953@ Removed redundant information from rules output
2 parents cebd1e9 + 8a26778 commit 865619b

File tree

5 files changed

+26
-25
lines changed

5 files changed

+26
-25
lines changed

messages/rule-viewer.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
# summary.found-no-rules
2-
3-
Found 0 rules.
4-
5-
# summary.found-rules
6-
7-
Found %d rule(s):
8-
91
# summary.detail.header
102

113
%d. %s

src/lib/viewers/RuleViewer.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ abstract class AbstractRuleDisplayer implements RuleViewer {
1717
}
1818

1919
public view(rules: Rule[]): void {
20-
if (rules.length === 0) {
21-
this.display.displayLog(getMessage(BundleName.RuleViewer, 'summary.found-no-rules'));
22-
} else {
23-
this.display.displayLog(getMessage(BundleName.RuleViewer, 'summary.found-rules', [rules.length]));
20+
this.displayLineSeparator();
21+
if (rules.length > 0) {
2422
this._view(rules);
23+
this.displayLineSeparator();
2524
}
2625
}
2726

27+
protected displayLineSeparator(): void {
28+
this.display.displayLog("");
29+
}
30+
2831
protected abstract _view(rules: Rule[]): void;
2932
}
3033

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Found 1 rule(s):
1+
22
=== 1. StubRule1
33
severity: 2 (High)
44
engine: FakeEngine1
55
type: Standard
66
tags: Recommended, Security
77
resources: www.google.com
8-
description: This is the description for a stub rule. Blah blah blah.
8+
description: This is the description for a stub rule. Blah blah blah.

test/fixtures/comparison-files/lib/viewers/RuleViewer.test.ts/two-rules-details.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Found 2 rule(s):
1+
22
=== 1. StubRule1
33
severity: 2 (High)
44
engine: FakeEngine1
@@ -13,4 +13,4 @@ Found 2 rule(s):
1313
type: Flow
1414
tags: CodeStyle, Performance
1515
resources: www.bing.com, www.salesforce.com
16-
description: This is the description for a second stub rule. Blah blah blah.
16+
description: This is the description for a second stub rule. Blah blah blah.

test/lib/viewers/RuleViewer.test.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const PATH_TO_COMPARISON_FILES = path.resolve(__dirname, '..', '..', '..', 'test
1010

1111
describe('RuleViewer implementations', () => {
1212
describe('RuleDetailDisplayer', () => {
13-
it('When given no rules, outputs summary and nothing else', () => {
13+
it('When given no rules, outputs a line separator and nothing else', () => {
1414
const display = new SpyDisplay();
1515
const viewer = new RuleDetailDisplayer(display);
1616

@@ -20,7 +20,7 @@ describe('RuleViewer implementations', () => {
2020
expect(displayEvents).toHaveLength(1);
2121
expect(displayEvents).toEqual([{
2222
type: DisplayEventType.LOG,
23-
data: 'Found 0 rules.'
23+
data: ''
2424
}]);
2525
});
2626

@@ -34,7 +34,7 @@ describe('RuleViewer implementations', () => {
3434
]);
3535

3636
const actualDisplayEvents = display.getDisplayEvents();
37-
expect(actualDisplayEvents).toHaveLength(2);
37+
expect(actualDisplayEvents).toHaveLength(3);
3838
for (const displayEvent of actualDisplayEvents) {
3939
expect(displayEvent.type).toEqual(DisplayEventType.LOG);
4040
}
@@ -57,7 +57,7 @@ describe('RuleViewer implementations', () => {
5757
]);
5858

5959
const actualDisplayEvents = display.getDisplayEvents();
60-
expect(actualDisplayEvents).toHaveLength(2);
60+
expect(actualDisplayEvents).toHaveLength(3);
6161
for (const displayEvent of actualDisplayEvents) {
6262
expect(displayEvent.type).toEqual(DisplayEventType.LOG);
6363
}
@@ -80,7 +80,7 @@ describe('RuleViewer implementations', () => {
8080
expect(displayEvents).toHaveLength(1);
8181
expect(displayEvents).toEqual([{
8282
type: DisplayEventType.LOG,
83-
data: 'Found 0 rules.'
83+
data: ''
8484
}]);
8585
});
8686

@@ -94,10 +94,10 @@ describe('RuleViewer implementations', () => {
9494
]);
9595

9696
const displayEvents = display.getDisplayEvents();
97-
expect(displayEvents).toHaveLength(2);
97+
expect(displayEvents).toHaveLength(3);
9898
expect(displayEvents).toEqual([{
9999
type: DisplayEventType.LOG,
100-
data: 'Found 1 rule(s):'
100+
data: ''
101101
}, {
102102
type: DisplayEventType.TABLE,
103103
data: JSON.stringify({
@@ -110,6 +110,9 @@ describe('RuleViewer implementations', () => {
110110
tag: rule.getFormattedTags()
111111
}]
112112
})
113+
}, {
114+
type: DisplayEventType.LOG,
115+
data: ''
113116
}])
114117
});
115118

@@ -125,10 +128,10 @@ describe('RuleViewer implementations', () => {
125128
]);
126129

127130
const displayEvents = display.getDisplayEvents();
128-
expect(displayEvents).toHaveLength(2);
131+
expect(displayEvents).toHaveLength(3);
129132
expect(displayEvents).toEqual([{
130133
type: DisplayEventType.LOG,
131-
data: 'Found 2 rule(s):'
134+
data: ''
132135
}, {
133136
type: DisplayEventType.TABLE,
134137
data: JSON.stringify({
@@ -147,6 +150,9 @@ describe('RuleViewer implementations', () => {
147150
tag: rule2.getFormattedTags()
148151
}]
149152
})
153+
}, {
154+
type: DisplayEventType.LOG,
155+
data: ''
150156
}]);
151157
});
152158
});

0 commit comments

Comments
 (0)