Skip to content

Commit b03d267

Browse files
committed
NEW @W-16891765@ Added end-of-file comment to config output.
1 parent 0e71236 commit b03d267

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

messages/config-model.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ Empty object used because rule selection returned no rules
1212

1313
# template.yaml.no-rules-selected
1414
Remove this empty object {} when you are ready to specify your first rule override
15+
16+
# template.common.end-of-config
17+
END OF CODE ANALYZER CONFIGURATION

src/lib/models/ConfigModel.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ abstract class YamlFormatter {
114114
this.toYamlRuleOverrides() + '\n' +
115115
'\n' +
116116
this.toYamlComment(topLevelDescription.fieldDescriptions!.engines) + '\n' +
117-
this.toYamlEngineOverrides() + '\n';
117+
this.toYamlEngineOverrides() + '\n' +
118+
'\n' +
119+
this.toYamlSectionHeadingComment(getMessage(BundleName.ConfigModel, 'template.common.end-of-config')) + '\n';
118120
}
119121

120122
private toYamlRuleOverrides(): string {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ======================================================================
2+
# END OF CODE ANALYZER CONFIGURATION
3+
# ======================================================================

test/fixtures/comparison-files/lib/actions/ConfigAction.test.ts/header-comments/top-level.yml.goldfile renamed to test/fixtures/comparison-files/lib/actions/ConfigAction.test.ts/header-comments/top-level-start.yml.goldfile

File renamed without changes.

test/lib/actions/ConfigAction.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,16 @@ describe('ConfigAction tests', () => {
4242
};
4343
});
4444

45-
it('Top-level overview-comment is correct', async () => {
45+
it.each([
46+
{position: 'start'},
47+
{position: 'end'}
48+
])('Top-level $position comment is correct', async ({position}) => {
4649
// ==== TESTED BEHAVIOR ====
4750
// Just select all rules for this test, since we don't care about the rules here.
4851
const output = await runActionAndGetDisplayedConfig(dependencies, ['all']);
4952

5053
// ==== ASSERTIONS ====
51-
const goldFileContents = await readGoldFile(path.join(PATH_TO_COMPARISON_DIR, 'header-comments', 'top-level.yml.goldfile'));
54+
const goldFileContents = await readGoldFile(path.join(PATH_TO_COMPARISON_DIR, 'header-comments', `top-level-${position}.yml.goldfile`));
5255
expect(output).toContain(goldFileContents);
5356
});
5457

@@ -167,7 +170,10 @@ describe('ConfigAction tests', () => {
167170
});
168171

169172

170-
it('Top-level overview-comment is correct', async () => {
173+
it.each([
174+
{position: 'start'},
175+
{position: 'end'}
176+
])('Top-level $position comment is correct', async ({position}) => {
171177
// ==== SETUP ====
172178
// Set the dummy config properties to null; it's fine for this test.
173179
stubConfigFactory.setDummyConfigRoot('null');
@@ -178,7 +184,7 @@ describe('ConfigAction tests', () => {
178184
const output = await runActionAndGetDisplayedConfig(dependencies, ['all']);
179185

180186
// ==== ASSERTIONS ====
181-
const goldFileContents = await readGoldFile(path.join(PATH_TO_COMPARISON_DIR, 'header-comments', 'top-level.yml.goldfile'));
187+
const goldFileContents = await readGoldFile(path.join(PATH_TO_COMPARISON_DIR, 'header-comments', `top-level-${position}.yml.goldfile`));
182188
expect(output).toContain(goldFileContents);
183189
});
184190

0 commit comments

Comments
 (0)