Skip to content
This repository was archived by the owner on Aug 1, 2021. It is now read-only.

Fix simple cipher - #536

Merged
matthewmorgan merged 1 commit into
exercism:masterfrom
allison-zhao:fix/simple-cipher
Apr 6, 2018
Merged

matthewmorgan merged 1 commit into
exercism:masterfrom
allison-zhao:fix/simple-cipher

Conversation

@allison-zhao

@allison-zhao allison-zhao commented Mar 29, 2018 •

Copy link
Copy Markdown
Contributor

Closes #399

@allison-zhao

Copy link
Copy Markdown
Contributor Author

@matthewmorgan hi! not sure why travis is failing - looks like some of the specs failed. i changed some code on the spec file to correct lint errors - maybe i missed something there?

@matthewmorgan matthewmorgan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leahzxxz See my comment about the linting error etc in the specfile. This is a case where we need to purposely disable one rule for a limited set of tests.

Comment thread exercises/simple-cipher/example.js Outdated
'use strict';

var ALPHABET = 'abcdefghijklmnopqrstuvwxyz';
const ALPHABET = 'abcdefghijklmnopqrstuvwxyz';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in the previous PR, we want to always use var on this track.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep will change - thanks!

expect( function () {
new Cipher('ABCDEF');
}).toThrow(new Error('Bad key'));
expect(new Cipher('ABCDEF')).toThrow(new Error('Bad key'));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should revert this change. The toThrow matcher requires a function as an argument, but your change provides it with a Cipher object instead.

I imagine you were seeing an error for the eslint no-new rule. You can disable for this test block with:

  /* eslint-disable no-new */
describe('Incorrect key cipher', function () {
...
});
  /* eslint-enable no-new */

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good to know - thank you!

@matthewmorgan matthewmorgan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leahzxxz A couple of small things, including some jshint cleanup that would be appreciated even though it wasn't your addition. :)

Comment thread exercises/simple-cipher/example.js Outdated

function addEncodedCharacter(character, index, array) {
function addEncodedCharacter(character, index) {
/* jshint validthis:true */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm...I missed this the first time around. We should remove these jshint directives. I'm not sure if they were merged inadvertently or are artifacts of an older linting setup, but they don't make sense anymore.

expect(function () {
new Cipher('');
}).toThrow(new Error('Bad key'));
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be sure to add the complementary enable line for the eslint rule.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthewmorgan could you specify what that means? what is the complementary enable line? (sorry I'm still new to this 😃 )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem.

You need to define the end of the disable block, otherwise the entire rest of the file will be ignored for that ESlint rule. EG:

  /* eslint-disable no-new */
describe('Incorrect key cipher', function () {
...
});
  /* eslint-enable no-new */

Notice that this block begins with disable and ends with enable, which turns that linting rule back on.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining! Just pushed the change. Final issue woohoo!

Comment thread exercises/simple-cipher/example.js Outdated

function addDecodedCharacter(character, index, array) {
function addDecodedCharacter(character, index) {
/* jshint validthis:true */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove please.

@matthewmorgan

Copy link
Copy Markdown
Contributor

PS very excited to see that this is the final issue to resolve #399!!

@matthewmorgan

Copy link
Copy Markdown
Contributor

Nice work!

One more question: do you feel comfortable squashing your work to a single commit? If not, I am happy to help with that.

@allison-zhao

Copy link
Copy Markdown
Contributor Author

Hmm I haven't done it before - could you just squash and merge? Thanks! (would also appreciate if you let me know how to do it on my end)

@matthewmorgan

Copy link
Copy Markdown
Contributor

I can just squash and merge ;)
I was suggesting that you do it (if you haven't before) to learn how. It's not hard.

You could do it like this:

git checkout master
git pull upstream/master  # or however you have named the exercism/javascript remote
git checkout fix/simple-cipher
git rebase master  # this will replay your changes in a single commit onto master

Assuming you don't have any merge conflicts, just force-push your branch back up to your fork:

git push -f origin fix/simple-cipher

Care to give it a try?

@allison-zhao

Copy link
Copy Markdown
Contributor Author

@matthewmorgan thanks for the instructions! just rebased and fixed merge conflicts. Doesn't look like my commits are squashed though... Did I do it right 😝

@matthewmorgan

Copy link
Copy Markdown
Contributor

One more step-- needed to make sure you were sync'd up with master (that was the hardest part.)

Let's see if we can get this done before anyone merges anything else in ahead of us.

git reset --soft fd567086481e7b85a5bbbb406b905acab72db6bb # last commit on master before your new ones
git commit -am 'Fix linting errors for simple-cipher'
git push -f origin fix/simple-cipher

@allison-zhao

Copy link
Copy Markdown
Contributor Author

@matthewmorgan Done! let me know if you need anything else. Really appreciate all the guidance!

@matthewmorgan

Copy link
Copy Markdown
Contributor

No problem! Nice work, thanks for your contributions.

@matthewmorgan
matthewmorgan merged commit 1524838 into exercism:master Apr 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants