Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Review Tweaks #1

Merged
merged 3 commits into from
Oct 20, 2018
Merged

Code Review Tweaks #1

merged 3 commits into from
Oct 20, 2018

Conversation

billneff79
Copy link
Contributor

@billneff79 billneff79 commented Oct 19, 2018

  • add eslint-config-synacor for static analysis
  • fix lint failures
  • other small stylistic changes

When you do the diff, enable the "Hide whitespace changes" setting to make it significantly easier to review

/**
* @private
*/
static processMethod(type, data) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

New helper method I created to abstract commonality of all of the static methods below

return {type:"Button", data:obj};
}

static isPromise(obj) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pulled this outside of the class since it wasn't class specific. It's added again below

let finalText = convo._write.reduce((acc, text) => acc.sentence(text), new Say()).toString().trim();
let finalSpeech = convo._speak.reduce((acc, text) => acc.sentence(text), new Say()).toString().trim();
let promises = [];
let textWasPopulated = !!(finalText || finalSpeech);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In javascript, an empty string is falsey, so we don't need the additional variables to hold textIsNotEmpty and speechIsNotEmpty as long as you trim the strings above. If you don't want to trim them for some reason, you can undo the change, but given how you are using them, that doesn't seem necessary

Copy link
Owner

Choose a reason for hiding this comment

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

That's the Java dev in me not used to "falsey" things =). Thanks for the tip there.

/* eslint-enable new-cap */
static prepComplete(obj, action = 'close', options) {
if (isPromise(obj)) {
return obj.then(result => this.prepComplete(result, action, options));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed obj to result in the arrow function to avoid any ambiguities on which scoped obj was being used

return r;
}
setAccessToken(token) {
if (!conv.user) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

conv is not defined in this scope. I assumed you meant this.conv

Copy link
Owner

Choose a reason for hiding this comment

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

my bad. Nice catch.

@tmtek tmtek merged commit 0ad5d3e into tmtek:master Oct 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants