From 0aebb03b1480fdd2b068fdf50e4050ba9f3d04e5 Mon Sep 17 00:00:00 2001 From: Derk-Jan Karrenbeld Date: Wed, 3 Jul 2019 12:10:20 +0200 Subject: [PATCH] Tweak statuses https://github.com/exercism/automated-mentoring-support/issues/53 Merge "approve_as_optimal" and "approve_with_comment" into a single status "approve", and rename the "disapprove_with_comment" status to "disapprove". --- CONTRIBUTING.md | 10 +- docs/comments.md | 5 +- docs/smoke-tests.md | 8 +- docs/snapshot-tests.md | 5 +- src/batch.ts | 5 +- src/interface.d.ts | 2 +- src/output/AnalyzerOutput.ts | 21 +- .../__snapshots__/snapshot.ts.snap | 540 ++++++++++++++-- test/analyzers/resistor-color/smoke.ts | 2 +- test/analyzers/resistor-color/snapshot.ts | 5 +- .../two-fer/__snapshots__/snapshot.ts.snap | 585 +++++++++++++++++- test/analyzers/two-fer/smoke.ts | 6 +- test/analyzers/two-fer/snapshot.ts | 5 +- test/output/AnalyzerOutput.ts | 8 +- test/output/toProcessable.ts | 10 +- test/smoke.ts | 6 +- 16 files changed, 1084 insertions(+), 139 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f653bf35..35e9283a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,11 +51,11 @@ from the track anatomy project deem to be the set of reasonable solutions. #### Abstract Syntax Approach -These solutions will be your baseline for `approve_as_optimal`, one of the -expected outputs. If your analyzer will be based on Abstract Syntax Tree -parsing, you can run these analyzers through the included ASTParser, or use -[AST explorer][ast-explorer] and make sure it's set to the correct parser (at - moment of writing this is `@typescript/eslint-parser`). +These solutions will be your baseline for `approve`, one of the expected +outputs. If your analyzer will be based on Abstract Syntax Tree parsing, you can +run these analyzers through the included ASTParser, or use [AST explorer][ast-explorer] +and make sure it's set to the correct parser (at moment of writing this is +`@typescript/eslint-parser`). **Note**: You may write a different style analyzer, that is _not_ using ASTs. diff --git a/docs/comments.md b/docs/comments.md index 7919e98a..49ee9f6c 100644 --- a/docs/comments.md +++ b/docs/comments.md @@ -4,9 +4,8 @@ Comments are the output analyzers directly give to the respective parties: - `refer_to_mentor`: at the moment of writing, the consensus is that comments will be passed to the mentor; -- `approve_with_comment`: the comments will be passed to the student; -- `disapprove_with_comment`: the comments will be passed to the student; -- `approve_as_optimal`: no comments are passed to _anyone_. +- `approve`: the comments, if any, will be passed to the student; +- `disapprove`: the comments will be passed to the student; ## Using the Comment Factory diff --git a/docs/smoke-tests.md b/docs/smoke-tests.md index ccdcd58f..6ba09683 100644 --- a/docs/smoke-tests.md +++ b/docs/smoke-tests.md @@ -25,15 +25,15 @@ describe('When running analysis on ', () => { const output = await analyze(solutionContent) - expect(output.status).toBe('approve_as_optimal'); + expect(output.status).toBe('approve'); expect(output.comments.length).toBe(0); }) }) ``` -Add additional test cases for `approve_with_comment` and -`disapprove_with_comment`, if your analyzer can actually output those. If you -have explicit code that should always return `refer_to_mentor` add it to. +Add additional test cases for `approve` and `disapprove`, if your analyzer can +actually output those. If you have explicit code that should always return +`refer_to_mentor`, add it too. **Note**: This is not the place to add an exhaustive test of inputs to outputs. It's merely trying to detect when one of the known cases changes! diff --git a/docs/snapshot-tests.md b/docs/snapshot-tests.md index 0b94c4ee..d181715e 100644 --- a/docs/snapshot-tests.md +++ b/docs/snapshot-tests.md @@ -32,11 +32,10 @@ const snapshotTestsGenerator = makeTestGenerator( ) describe('When running analysis on two-fer fixtures', () => { - snapshotTestsGenerator('approve_as_optimal', [ + snapshotTestsGenerator('approve', [ // ]) - snapshotTestsGenerator('approve_with_comment', []) - snapshotTestsGenerator('disapprove_with_comment', []) + snapshotTestsGenerator('disapprove', []) snapshotTestsGenerator('refer_to_mentor', []) }) diff --git a/src/batch.ts b/src/batch.ts index 69cff3ec..79b7831b 100644 --- a/src/batch.ts +++ b/src/batch.ts @@ -211,9 +211,8 @@ ${JSON.stringify( | Status | Count | Comments | Unique | Avg | Median | Total | | --------------------:| -----:| --------:| ------:| ------:|-------:|--------:| -${line('Approve (optimal)', aggregatedGroups['approve_as_optimal'])} -${line('Approve (comment)', aggregatedGroups['approve_with_comment'])} -${line('Disapprove (comment)', aggregatedGroups['disapprove_with_comment'])} +${line('Approve', aggregatedGroups['approve'])} +${line('Disapprove', aggregatedGroups['disapprove'])} ${line('Refer to mentor', aggregatedGroups['refer_to_mentor'])} ${line('Total', totalData)} `.trim()) diff --git a/src/interface.d.ts b/src/interface.d.ts index db9443d7..bc28b53b 100644 --- a/src/interface.d.ts +++ b/src/interface.d.ts @@ -50,7 +50,7 @@ interface Comment { } interface Output { - status: 'refer_to_mentor' | 'approve_as_optimal' | 'approve_with_comment' | 'disapprove_with_comment'; + status: 'refer_to_mentor' | 'approve' | 'disapprove'; comments: Comment[]; /** diff --git a/src/output/AnalyzerOutput.ts b/src/output/AnalyzerOutput.ts index 4cb8ef47..a07ad28b 100644 --- a/src/output/AnalyzerOutput.ts +++ b/src/output/AnalyzerOutput.ts @@ -1,12 +1,13 @@ enum SolutionStatus { - /** This is the default situation and should be used when there is any uncertainty. */ + /** This is the default situation and should be used when there is any + * uncertainty. */ Redirect = 'refer_to_mentor', - /** To be used when a solution matches pre-known optimal solutions */ - ApproveAsOptimal = 'approve_as_optimal', - /** To be used when a solution can be approved but with a known improvement. */ - ApproveWithComment = 'approve_with_comment', - /** To be used when a solution can be disapproved as suboptimal and a comment is provided. */ - DisapproveWithComment = 'disapprove_with_comment' + /** To be used when a solution matches pre-known optimal solutions or when a + * solution can be approved but with a known improvement. */ + Approve = 'approve', + /** To be used when a solution can be disapproved as suboptimal and a comment + * is provided. */ + Disapprove = 'disapprove' } /** @@ -30,9 +31,7 @@ export class AnalyzerOutput implements Output { * Mark the solution as approved */ public approve(): void { - this.status = this.comments.length === 0 - ? SolutionStatus.ApproveAsOptimal - : SolutionStatus.ApproveWithComment + this.status = SolutionStatus.Approve this.freeze() } @@ -41,7 +40,7 @@ export class AnalyzerOutput implements Output { * Mark the solution as dissapproved */ public disapprove(): void { - this.status = SolutionStatus.DisapproveWithComment + this.status = SolutionStatus.Disapprove this.freeze() } diff --git a/test/analyzers/resistor-color/__snapshots__/snapshot.ts.snap b/test/analyzers/resistor-color/__snapshots__/snapshot.ts.snap index 322ec1c7..f4ffd901 100644 --- a/test/analyzers/resistor-color/__snapshots__/snapshot.ts.snap +++ b/test/analyzers/resistor-color/__snapshots__/snapshot.ts.snap @@ -3,419 +3,839 @@ exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/0's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/1's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/2's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/12's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/13's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/14's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/16's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/17's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/18's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/20's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/100's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/101's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/102's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/105's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/106's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/107's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/110's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/113's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/115's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/117's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/122's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/123's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/127's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/131's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/132's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/134's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/135's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/137's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/138's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/142's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/149's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/150's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/151's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/158's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/161's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/163's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/164's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/165's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/168's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/171's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/172's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/173's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/174's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/175's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/179's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/180's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/182's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/184's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/186's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/187's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/189's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/191's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/192's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/196's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/197's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/199's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/206's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/209's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/211's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches resistor-color/212's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/0's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/1's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/2's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/12's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/13's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/14's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/16's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/17's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/18's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/20's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/100's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/101's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/102's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/105's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/106's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/107's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/110's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/113's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/115's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/117's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/122's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/123's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/127's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/131's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/132's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/134's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/135's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/137's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/138's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/142's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/149's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/150's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/151's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/158's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/161's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/163's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/164's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/165's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/168's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/171's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/172's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/173's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/174's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/175's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/179's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/180's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/182's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/184's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/186's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/187's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/189's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/191's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/192's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/196's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/197's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/199's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/206's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/209's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/211's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches resistor-color/212's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", } `; diff --git a/test/analyzers/resistor-color/smoke.ts b/test/analyzers/resistor-color/smoke.ts index 0310a03e..d34efd13 100644 --- a/test/analyzers/resistor-color/smoke.ts +++ b/test/analyzers/resistor-color/smoke.ts @@ -15,7 +15,7 @@ describe('When running analysis on resistor-color', () => { const output = await analyze(solutionContent) - expect(output.status).toBe('approve_as_optimal'); + expect(output.status).toBe('approve'); expect(output.comments.length).toBe(0); }) }) diff --git a/test/analyzers/resistor-color/snapshot.ts b/test/analyzers/resistor-color/snapshot.ts index 98a0b28e..140c6194 100644 --- a/test/analyzers/resistor-color/snapshot.ts +++ b/test/analyzers/resistor-color/snapshot.ts @@ -6,7 +6,7 @@ const snapshotTestsGenerator = makeTestGenerator( ) describe('When running analysis on two-fer fixtures', () => { - snapshotTestsGenerator('approve_as_optimal', [ + snapshotTestsGenerator('approve', [ 0, 1, 100, 101, 102, 105, 106, 107, 110, 113, 115, 117, 12, 122, 123, 127, 13, 131, 132, 134, 135, 137, 138, 14, 142, 149, 150, 151, 158, 16, @@ -14,7 +14,6 @@ describe('When running analysis on two-fer fixtures', () => { 175, 179, 18, 180, 182, 184, 186, 187, 189, 191, 192, 196, 197, 199, 2, 20, 206, 209, 211, 212 ]) - snapshotTestsGenerator('approve_with_comment', []) - snapshotTestsGenerator('disapprove_with_comment', []) + snapshotTestsGenerator('disapprove', []) snapshotTestsGenerator('refer_to_mentor', []) }) diff --git a/test/analyzers/two-fer/__snapshots__/snapshot.ts.snap b/test/analyzers/two-fer/__snapshots__/snapshot.ts.snap index 12cc0bc6..387325d7 100644 --- a/test/analyzers/two-fer/__snapshots__/snapshot.ts.snap +++ b/test/analyzers/two-fer/__snapshots__/snapshot.ts.snap @@ -3,49 +3,580 @@ exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches two-fer/70's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches two-fer/118's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches two-fer/129's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches two-fer/139's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches two-fer/313's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches two-fer/400's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", } `; exports[`When running analysis on two-fer fixtures and expecting it to approve as optimal matches two-fer/493's output: output 1`] = ` AnalyzerOutput { "comments": Array [], - "status": "approve_as_optimal", + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches two-fer/70's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches two-fer/118's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches two-fer/129's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches two-fer/139's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches two-fer/313's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches two-fer/400's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to approve matches two-fer/493's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [], + "status": "approve", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/1's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_default_value", + "message": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of name to 'you' to avoid this conditional.", + "template": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of %s to 'you' to avoid this conditional.", + "variables": Object { + "parameter": "name", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/10's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_default_value", + "message": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of name to 'you' to avoid this conditional.", + "template": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of %s to 'you' to avoid this conditional.", + "variables": Object { + "parameter": "name", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/11's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.generic.no_method", + "message": "No method called \`twoFer\`. The tests won't pass without it.", + "template": "No method called \`%s\`. The tests won't pass without it.", + "variables": Object { + "method.name": "twoFer", + }, + }, + CommentImpl { + "externalTemplate": "javascript.generic.no_named_export", + "message": "No [export](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export) called \`twoFer\`. +The tests won't pass without it. + +Did you forget adding: \`export twoFer\`?", + "template": "No [export](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export) called \`%s\`. +The tests won't pass without it. + +Did you forget adding: \`export %s\`?", + "variables": Object { + "export.name": "twoFer", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/12's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_default_value", + "message": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of name to 'you' to avoid this conditional.", + "template": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of %s to 'you' to avoid this conditional.", + "variables": Object { + "parameter": "name", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/100's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_default_value", + "message": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of name to 'you' to avoid this conditional.", + "template": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of %s to 'you' to avoid this conditional.", + "variables": Object { + "parameter": "name", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/101's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.generic.prefer_strict_equality", + "message": "In _JavaScript_, always prefer [strict (identity and non-identity) equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Identity) +such as \`===\` and \`!==\` over the forms that use implicit type coercion, +such as [\`==\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Equality) +and [\`!=\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Inequality), +unless you explicitly want to coerce the type of one of the two operands. + +There are definitely cases where you'll want to use non-strict equality, but +that's not the case in this exercise.", + "template": "In _JavaScript_, always prefer [strict (identity and non-identity) equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Identity) +such as \`===\` and \`!==\` over the forms that use implicit type coercion, +such as [\`==\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Equality) +and [\`!=\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Inequality), +unless you explicitly want to coerce the type of one of the two operands. + +There are definitely cases where you'll want to use non-strict equality, but +that's not the case in this exercise.", + "variables": Object {}, + }, + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_default_value", + "message": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of name to 'you' to avoid this conditional.", + "template": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of %s to 'you' to avoid this conditional.", + "variables": Object { + "parameter": "name", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/102's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.generic.prefer_strict_equality", + "message": "In _JavaScript_, always prefer [strict (identity and non-identity) equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Identity) +such as \`===\` and \`!==\` over the forms that use implicit type coercion, +such as [\`==\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Equality) +and [\`!=\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Inequality), +unless you explicitly want to coerce the type of one of the two operands. + +There are definitely cases where you'll want to use non-strict equality, but +that's not the case in this exercise.", + "template": "In _JavaScript_, always prefer [strict (identity and non-identity) equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Identity) +such as \`===\` and \`!==\` over the forms that use implicit type coercion, +such as [\`==\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Equality) +and [\`!=\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Inequality), +unless you explicitly want to coerce the type of one of the two operands. + +There are definitely cases where you'll want to use non-strict equality, but +that's not the case in this exercise.", + "variables": Object {}, + }, + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_default_value", + "message": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of name to 'you' to avoid this conditional.", + "template": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of %s to 'you' to avoid this conditional.", + "variables": Object { + "parameter": "name", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/104's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_default_value", + "message": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of X to 'you' to avoid this conditional.", + "template": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of %s to 'you' to avoid this conditional.", + "variables": Object { + "parameter": "X", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/105's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_explicity_default_value", + "message": "Instead of relying on %s being \\"undefined\\" when +no value is passed in, you could set the default value of 'name' to +'you'.", + "template": "Instead of relying on %s being \\"undefined\\" when +no value is passed in, you could set the default value of '%s' to +'you'.", + "variables": Object { + "maybe-undefined-expression": "name", + "parameter": "name", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/107's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_explicity_default_value", + "message": "Instead of relying on %s being \\"undefined\\" when +no value is passed in, you could set the default value of 'name' to +'you'.", + "template": "Instead of relying on %s being \\"undefined\\" when +no value is passed in, you could set the default value of '%s' to +'you'.", + "variables": Object { + "maybe-undefined-expression": "name", + "parameter": "name", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/109's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_default_value", + "message": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of name to 'you' to avoid this conditional.", + "template": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of %s to 'you' to avoid this conditional.", + "variables": Object { + "parameter": "name", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/110's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.generic.prefer_strict_equality", + "message": "In _JavaScript_, always prefer [strict (identity and non-identity) equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Identity) +such as \`===\` and \`!==\` over the forms that use implicit type coercion, +such as [\`==\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Equality) +and [\`!=\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Inequality), +unless you explicitly want to coerce the type of one of the two operands. + +There are definitely cases where you'll want to use non-strict equality, but +that's not the case in this exercise.", + "template": "In _JavaScript_, always prefer [strict (identity and non-identity) equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Identity) +such as \`===\` and \`!==\` over the forms that use implicit type coercion, +such as [\`==\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Equality) +and [\`!=\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Inequality), +unless you explicitly want to coerce the type of one of the two operands. + +There are definitely cases where you'll want to use non-strict equality, but +that's not the case in this exercise.", + "variables": Object {}, + }, + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_default_value", + "message": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of name to 'you' to avoid this conditional.", + "template": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of %s to 'you' to avoid this conditional.", + "variables": Object { + "parameter": "name", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/111's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_default_value", + "message": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of name to 'you' to avoid this conditional.", + "template": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of %s to 'you' to avoid this conditional.", + "variables": Object { + "parameter": "name", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/112's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.generic.no_method", + "message": "No method called \`twoFer\`. The tests won't pass without it.", + "template": "No method called \`%s\`. The tests won't pass without it.", + "variables": Object { + "method.name": "twoFer", + }, + }, + CommentImpl { + "externalTemplate": "javascript.generic.no_named_export", + "message": "No [export](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export) called \`twoFer\`. +The tests won't pass without it. + +Did you forget adding: \`export twoFer\`?", + "template": "No [export](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export) called \`%s\`. +The tests won't pass without it. + +Did you forget adding: \`export %s\`?", + "variables": Object { + "export.name": "twoFer", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/114's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_default_value", + "message": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of name to 'you' to avoid this conditional.", + "template": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of %s to 'you' to avoid this conditional.", + "variables": Object { + "parameter": "name", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/115's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_default_value", + "message": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of name to 'you' to avoid this conditional.", + "template": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of %s to 'you' to avoid this conditional.", + "variables": Object { + "parameter": "name", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/116's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_default_value", + "message": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of name to 'you' to avoid this conditional.", + "template": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of %s to 'you' to avoid this conditional.", + "variables": Object { + "parameter": "name", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/121's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_default_value", + "message": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of name to 'you' to avoid this conditional.", + "template": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of %s to 'you' to avoid this conditional.", + "variables": Object { + "parameter": "name", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/123's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_default_value", + "message": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of name to 'you' to avoid this conditional.", + "template": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of %s to 'you' to avoid this conditional.", + "variables": Object { + "parameter": "name", + }, + }, + ], + "status": "disapprove", +} +`; + +exports[`When running analysis on two-fer fixtures and expecting it to disapprove matches two-fer/124's output: output 1`] = ` +AnalyzerOutput { + "comments": Array [ + CommentImpl { + "externalTemplate": "javascript.two-fer.optimise_default_value", + "message": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of name to 'you' to avoid this conditional.", + "template": "You currently use a conditional to branch in case there is no value passed into +\`twoFer\`. Instead you could set the [default value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) +of %s to 'you' to avoid this conditional.", + "variables": Object { + "parameter": "name", + }, + }, + ], + "status": "disapprove", } `; @@ -65,7 +596,7 @@ of %s to 'you' to avoid this conditional.", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -85,7 +616,7 @@ of %s to 'you' to avoid this conditional.", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -115,7 +646,7 @@ Did you forget adding: \`export %s\`?", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -135,7 +666,7 @@ of %s to 'you' to avoid this conditional.", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -155,7 +686,7 @@ of %s to 'you' to avoid this conditional.", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -195,7 +726,7 @@ of %s to 'you' to avoid this conditional.", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -235,7 +766,7 @@ of %s to 'you' to avoid this conditional.", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -255,7 +786,7 @@ of %s to 'you' to avoid this conditional.", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -276,7 +807,7 @@ no value is passed in, you could set the default value of '%s' to }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -297,7 +828,7 @@ no value is passed in, you could set the default value of '%s' to }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -317,7 +848,7 @@ of %s to 'you' to avoid this conditional.", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -357,7 +888,7 @@ of %s to 'you' to avoid this conditional.", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -377,7 +908,7 @@ of %s to 'you' to avoid this conditional.", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -407,7 +938,7 @@ Did you forget adding: \`export %s\`?", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -427,7 +958,7 @@ of %s to 'you' to avoid this conditional.", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -447,7 +978,7 @@ of %s to 'you' to avoid this conditional.", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -467,7 +998,7 @@ of %s to 'you' to avoid this conditional.", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -487,7 +1018,7 @@ of %s to 'you' to avoid this conditional.", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -507,7 +1038,7 @@ of %s to 'you' to avoid this conditional.", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; @@ -527,7 +1058,7 @@ of %s to 'you' to avoid this conditional.", }, }, ], - "status": "disapprove_with_comment", + "status": "disapprove", } `; diff --git a/test/analyzers/two-fer/smoke.ts b/test/analyzers/two-fer/smoke.ts index 5a5195da..b8907fb2 100644 --- a/test/analyzers/two-fer/smoke.ts +++ b/test/analyzers/two-fer/smoke.ts @@ -14,7 +14,7 @@ describe('When running analysis on two-fer', () => { const output = await analyze(solutionContent) - expect(output.status).toBe('approve_as_optimal'); + expect(output.status).toBe('approve'); expect(output.comments.length).toBe(0); }) @@ -30,7 +30,7 @@ describe('When running analysis on two-fer', () => { const output = await analyze(solutionContent) - expect(output.status).toBe('approve_with_comment'); + expect(output.status).toBe('approve'); expect(output.comments.length).toBeGreaterThanOrEqual(1); }) @@ -44,7 +44,7 @@ describe('When running analysis on two-fer', () => { const output = await analyze(solutionContent) - expect(output.status).toBe('disapprove_with_comment'); + expect(output.status).toBe('disapprove'); expect(output.comments.length).toBeGreaterThanOrEqual(1); }) diff --git a/test/analyzers/two-fer/snapshot.ts b/test/analyzers/two-fer/snapshot.ts index 157681f6..4412866a 100644 --- a/test/analyzers/two-fer/snapshot.ts +++ b/test/analyzers/two-fer/snapshot.ts @@ -7,11 +7,10 @@ const snapshotTestsGenerator = makeTestGenerator( ) describe('When running analysis on two-fer fixtures', () => { - snapshotTestsGenerator('approve_as_optimal', [ + snapshotTestsGenerator('approve', [ 118, 129, 139, 313, 400, 493, 70 ]) - snapshotTestsGenerator('approve_with_comment', []) - snapshotTestsGenerator('disapprove_with_comment', [ + snapshotTestsGenerator('disapprove', [ 1, 10, 100, 101, 102, 104, 105, 107, 109, 11, 110, 111, 112, 114, 115, 116, 12, 121, 123, 124 ]) diff --git a/test/output/AnalyzerOutput.ts b/test/output/AnalyzerOutput.ts index 09e2fe94..18db649e 100644 --- a/test/output/AnalyzerOutput.ts +++ b/test/output/AnalyzerOutput.ts @@ -35,7 +35,7 @@ describe('AnalyzerOutput', () => { output.approve() it('approves as optimal', () => { - expect(output.status).toBe('approve_as_optimal') + expect(output.status).toBe('approve') }) it('has no comments', () => { @@ -49,7 +49,7 @@ describe('AnalyzerOutput', () => { output.approve() it('approves with comment', () => { - expect(output.status).toBe('approve_with_comment') + expect(output.status).toBe('approve') }) it('has that comment', () => { @@ -93,7 +93,7 @@ describe('AnalyzerOutput', () => { output.disapprove() it('disapproves with comment', () => { - expect(output.status).toBe('disapprove_with_comment') + expect(output.status).toBe('disapprove') }) it('has no comments', () => { @@ -107,7 +107,7 @@ describe('AnalyzerOutput', () => { output.disapprove() it('disapproves with comment', () => { - expect(output.status).toBe('disapprove_with_comment') + expect(output.status).toBe('disapprove') }) it('has that comment', () => { diff --git a/test/output/toProcessable.ts b/test/output/toProcessable.ts index 449ff2e7..8451ed93 100644 --- a/test/output/toProcessable.ts +++ b/test/output/toProcessable.ts @@ -24,7 +24,7 @@ describe('AnalyzerOutput#toProcessable', () => { const result = await output.toProcessable({ templates: false }) expect(JSON.parse(result)).toEqual({ - status: 'approve_with_comment', + status: 'approve', comments: [ 'simple comment without parameters', { @@ -45,7 +45,7 @@ describe('AnalyzerOutput#toProcessable', () => { const result = await output.toProcessable({ templates: true }) expect(JSON.parse(result)).toEqual({ - status: 'approve_with_comment', + status: 'approve', comments: [ COMMENT_WITHOUT_PARAMS_IDENTIFIER, { @@ -63,7 +63,7 @@ describe('AnalyzerOutput#toProcessable', () => { output.approve() const result = await output.toProcessable({ templates: true }) - expect(JSON.parse(result)).toMatchObject({ status: 'approve_as_optimal' }) + expect(JSON.parse(result)).toMatchObject({ status: 'approve' }) }) }) @@ -75,7 +75,7 @@ describe('AnalyzerOutput#toProcessable', () => { output.approve() const result = await output.toProcessable({ templates: true }) - expect(JSON.parse(result)).toMatchObject({ status: 'approve_with_comment' }) + expect(JSON.parse(result)).toMatchObject({ status: 'approve' }) }) }) @@ -86,7 +86,7 @@ describe('AnalyzerOutput#toProcessable', () => { output.disapprove() const result = await output.toProcessable({ templates: true }) - expect(JSON.parse(result)).toMatchObject({ status: 'disapprove_with_comment' }) + expect(JSON.parse(result)).toMatchObject({ status: 'disapprove' }) }) }) diff --git a/test/smoke.ts b/test/smoke.ts index 286e91d4..76d3666f 100644 --- a/test/smoke.ts +++ b/test/smoke.ts @@ -21,7 +21,7 @@ describe('When running analysis', () => { const input = new InlineInput([solutionContent]) const output = await run(analyzer, input, options) - expect(output.status).toBe('approve_as_optimal'); + expect(output.status).toBe('approve'); expect(output.comments.length).toBe(0); }) @@ -39,7 +39,7 @@ describe('When running analysis', () => { const input = new InlineInput([solutionContent]) const output = await run(analyzer, input, options) - expect(output.status).toBe('approve_with_comment'); + expect(output.status).toBe('approve'); expect(output.comments.length).toBeGreaterThanOrEqual(1); }) @@ -55,7 +55,7 @@ describe('When running analysis', () => { const input = new InlineInput([solutionContent]) const output = await run(analyzer, input, options) - expect(output.status).toBe('disapprove_with_comment'); + expect(output.status).toBe('disapprove'); expect(output.comments.length).toBeGreaterThanOrEqual(1); })