From 52894503115c395b22676ab37c76b7251af3548b Mon Sep 17 00:00:00 2001 From: Derk-Jan Karrenbeld Date: Tue, 24 Sep 2019 03:14:04 +0200 Subject: [PATCH] :rocket: version 0.4.1 --- CHANGELOG.md | 5 ++ package.json | 2 +- src/analyzers/resistor-color-duo/index.ts | 13 ++++- .../__snapshots__/snapshot.ts.snap | 48 +++++++++++++++++-- 4 files changed, 61 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bcae0b4..78479f5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.4.1 + +- Add message (fix) to `reduce` solutions without `slice` +- Add `limit_number_of_colors` extra message when `slice` is an `must_add_missing_call`. + ## 0.4.0 - Add analyzer for `resistor-color-duo` diff --git a/package.json b/package.json index 5f9e8f92..49850839 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@exercism/javascript-analyzer", - "version": "0.4.0", + "version": "0.4.1", "description": "Exercism analyzer for javascript", "repository": "https://github.com/exercism/javascript-analyzer", "author": "Derk-Jan Karrenbeld ", diff --git a/src/analyzers/resistor-color-duo/index.ts b/src/analyzers/resistor-color-duo/index.ts index 713745b5..3217e80b 100644 --- a/src/analyzers/resistor-color-duo/index.ts +++ b/src/analyzers/resistor-color-duo/index.ts @@ -205,7 +205,16 @@ export class ResistorColorDuoAnalyzer extends IsolatedAnalyzerImpl { output.disapprove(ISSUE_METHOD_NOT_FOUND({ 'method.name': lastIssue.methodName })) } else if (lastIssue instanceof MissingExpectedCall) { // output.add(BETA_COMMENTARY_PREFIX()) - output.disapprove(ISSUE_EXPECTED_CALL({ 'method.name': lastIssue.methodName, 'expected.reason': lastIssue.reason })) + output.add(ISSUE_EXPECTED_CALL({ 'method.name': lastIssue.methodName, 'expected.reason': lastIssue.reason })) + + // Add extra information for limit number + if (solution.entry.hasOneMap || solution.entry.hasOneReduce) { + if (!solution.entry.hasOneSlice) { + output.add(LIMIT_NUMBER_OF_COLORS()) + } + } + + output.disapprove() } else { this.logger.error('The analyzer did not handle the issue: ' + JSON.stringify(lastIssue)) output.redirect() @@ -238,7 +247,7 @@ export class ResistorColorDuoAnalyzer extends IsolatedAnalyzerImpl { output.add(PREFER_NUMBER_OVER_PARSE()) } - if (solution.entry.hasOneMap || solution.entry.hasOneSlice) { + if (solution.entry.hasOneMap || solution.entry.hasOneReduce) { if (!solution.entry.hasOneSlice) { output.add(LIMIT_NUMBER_OF_COLORS()) } diff --git a/test/analyzers/resistor-color-duo/__snapshots__/snapshot.ts.snap b/test/analyzers/resistor-color-duo/__snapshots__/snapshot.ts.snap index 8fe21c5d..5c89b961 100644 --- a/test/analyzers/resistor-color-duo/__snapshots__/snapshot.ts.snap +++ b/test/analyzers/resistor-color-duo/__snapshots__/snapshot.ts.snap @@ -244,15 +244,35 @@ IsolatedAnalyzerOutput { "comments": Array [ CommentImpl { "externalTemplate": "javascript.resistor-color-duo.must_add_missing_call", - "message": "📕 In order to limit the number of colors processed to 2, expected a \`.slice(0, 2)\` call. If + "message": "📕 In order to limit the number of colors processed to two, expected a \`.slice(0, 2)\` call. If that reasoning applies, mentor the student to add this call.", "template": "📕 In order to %{expected.reason}, expected a \`%{method.name}\` call. If that reasoning applies, mentor the student to add this call.", "variables": Object { - "expected.reason": "limit the number of colors processed to 2", + "expected.reason": "limit the number of colors processed to two", "method.name": ".slice(0, 2)", }, }, + CommentImpl { + "externalTemplate": "javascript.resistor-color-duo.limit_number_of_colors", + "message": "💬 Limit the number of input colors that are processed. If more than two colors +are passed in, only the first two colors should be used to calculate the total +\`colorCode\` value. + +📕 (At least) one test case inputs three colors instead of two. If the student +has not accounted for this, they might need to update their solution. Help them +find the button to update. The tests won't pass without limiting the number of +colors.", + "template": "💬 Limit the number of input colors that are processed. If more than two colors +are passed in, only the first two colors should be used to calculate the total +\`colorCode\` value. + +📕 (At least) one test case inputs three colors instead of two. If the student +has not accounted for this, they might need to update their solution. Help them +find the button to update. The tests won't pass without limiting the number of +colors.", + "variables": Object {}, + }, ], "status": "disapprove", } @@ -487,15 +507,35 @@ IsolatedAnalyzerOutput { "comments": Array [ CommentImpl { "externalTemplate": "javascript.resistor-color-duo.must_add_missing_call", - "message": "📕 In order to limit the number of colors processed to 2, expected a \`.slice(0, 2)\` call. If + "message": "📕 In order to limit the number of colors processed to two, expected a \`.slice(0, 2)\` call. If that reasoning applies, mentor the student to add this call.", "template": "📕 In order to %{expected.reason}, expected a \`%{method.name}\` call. If that reasoning applies, mentor the student to add this call.", "variables": Object { - "expected.reason": "limit the number of colors processed to 2", + "expected.reason": "limit the number of colors processed to two", "method.name": ".slice(0, 2)", }, }, + CommentImpl { + "externalTemplate": "javascript.resistor-color-duo.limit_number_of_colors", + "message": "💬 Limit the number of input colors that are processed. If more than two colors +are passed in, only the first two colors should be used to calculate the total +\`colorCode\` value. + +📕 (At least) one test case inputs three colors instead of two. If the student +has not accounted for this, they might need to update their solution. Help them +find the button to update. The tests won't pass without limiting the number of +colors.", + "template": "💬 Limit the number of input colors that are processed. If more than two colors +are passed in, only the first two colors should be used to calculate the total +\`colorCode\` value. + +📕 (At least) one test case inputs three colors instead of two. If the student +has not accounted for this, they might need to update their solution. Help them +find the button to update. The tests won't pass without limiting the number of +colors.", + "variables": Object {}, + }, ], "status": "disapprove", }