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

Dev #2363

Open
wants to merge 3 commits into
base: vijaytakbhate2002
Choose a base branch
from
Open

Conversation

vijaytakbhate2002
Copy link

Hey maintainer,
I added Error checking code in _check function and invoked that function to other functions (add, subtract, multiply, divide). Removed Error checking code from these functions.

Here is before and after image of code change

Before

image

After

image

@dantharejabot
Copy link
Collaborator

Yay, a pull request!

After you submit a pull request, one of the following will happen:

😭 You don’t get a response. 😭

Even on an active project, it’s possible that your pull request won’t get an immediate response. You should expect some delay as most open source maintainers do so in their free time and can be busy with other tasks.

If you haven’t gotten a response in over a week, it’s fair to politely respond in the same thread, asking someone for a review. If you know the handle of the right person to review your pull request, you can @-mention them to send them a notification. Avoid reaching out to that person privately; remember that public communication is vital to open source projects.

If you make a polite bump and still nobody responds, it’s possible that nobody will respond, ever. It’s not a great feeling, but don’t let that discourage you. It’s happened to everyone! There are many possible reasons why you didn’t get a response, including personal circumstances that may be out of your control. Try to find another project or way to contribute. If anything, this is a good reason not to invest too much time in making a pull request before other community members are engaged and responsive.

🚧 You're asked to make changes to your pull request. 🚧

It’s very common that someone will request changes on your pull request, whether that’s feedback on the scope of your idea, or changes to your code. Often a pull request is just the start of the conversation.

When someone requests changes, be responsive. They’ve taken the time to review your pull request. Opening a PR and walking away is bad form. If you don’t know how to make changes, research the problem, then ask for help if you need it.

If you don’t have time to work on the issue anymore (for example, if the conversation has been going on for months, and your circumstances have changed), let the maintainer know so they’re not expecting a response. Someone else may be happy to take over.

👎 Your pull request doesn’t get accepted. 👎

It's possible your pull request may or may not be accepted in the end. If you’re not sure why it wasn’t accepted, it’s perfectly reasonable to ask the maintainer for feedback and clarification. Ultimately, however, you’ll need to respect that this is their decision. Don’t argue or get hostile. You’re always welcome to fork and work on your own version if you disagree!

🎉 Your pull request gets accepted and merged. 🎉

Hooray! You’ve successfully made an open source contribution!


Thank you for the submission, @vijaytakbhate2002! I'll review your code shortly, hang tight.

Copy link
Collaborator

@dantharejabot dantharejabot left a comment

Choose a reason for hiding this comment

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

This is a great attempt, @vijaytakbhate2002!

I would like to request a few changes before merging your work. Please review my comments below and make the appropriate changes to your code.

After you update your code locally, follow the instructions to save your changes locally and push your changes to your fork.

When you push your changes to your fork, I'll come back for another review.


There are 8 style guide violations in your contribution. I've marked them with inline comments for your convenience.

Please revisit your code and follow the style guide best practices.

Hint: You might be able to fix some issues automatically by running npm run lint -- --fix


There are 5 tests still pending. In your test file, change describe.skip to describe and ensure they pass.

⚠️ _check should throw a TypeError if arguments are not numbers
⚠️ _check should be called once in "add"
⚠️ _check should be called once in "subtract"
⚠️ _check should be called once in "multiply"
⚠️ _check should be called once in "divide"

There are 16 tests failing. Please revisit your code and make the failing tests pass.

add should throw a TypeError if arguments are not numbers

-actual
+expected

-ReferenceError: x is not defined
+TypeError
AssertionError: expected [Function] to throw 'TypeError' but 'ReferenceError: x is not defined' was thrown
    at Context.<anonymous> (src/calculator.test.js:49:51)
    at processImmediate (node:internal/timers:464:21)

add should add two positive numbers

ReferenceError: x is not defined
    at Object.exports._check (src/calculator.js:4:28)
    at Object.exports.add (src/calculator.js:12:11)
    at Context.<anonymous> (src/calculator.test.js:58:23)
    at processImmediate (node:internal/timers:464:21)

add should add two negative numbers

ReferenceError: x is not defined
    at Object.exports._check (src/calculator.js:4:28)
    at Object.exports.add (src/calculator.js:12:11)
    at Context.<anonymous> (src/calculator.test.js:62:23)
    at processImmediate (node:internal/timers:464:21)

add should add one positive number and one negative number

ReferenceError: x is not defined
    at Object.exports._check (src/calculator.js:4:28)
    at Object.exports.add (src/calculator.js:12:11)
    at Context.<anonymous> (src/calculator.test.js:66:23)
    at processImmediate (node:internal/timers:464:21)

subtract should throw a TypeError if arguments are not numbers

-actual
+expected

-ReferenceError: x is not defined
+TypeError
AssertionError: expected [Function] to throw 'TypeError' but 'ReferenceError: x is not defined' was thrown
    at Context.<anonymous> (src/calculator.test.js:72:56)
    at processImmediate (node:internal/timers:464:21)

subtract should subtract two positive numbers

ReferenceError: x is not defined
    at Object.exports._check (src/calculator.js:4:28)
    at Object.exports.subtract (src/calculator.js:17:11)
    at Context.<anonymous> (src/calculator.test.js:81:23)
    at processImmediate (node:internal/timers:464:21)

subtract should subtract two negative numbers

ReferenceError: x is not defined
    at Object.exports._check (src/calculator.js:4:28)
    at Object.exports.subtract (src/calculator.js:17:11)
    at Context.<anonymous> (src/calculator.test.js:85:23)
    at processImmediate (node:internal/timers:464:21)

subtract should subtract one positive number and one negative number

ReferenceError: x is not defined
    at Object.exports._check (src/calculator.js:4:28)
    at Object.exports.subtract (src/calculator.js:17:11)
    at Context.<anonymous> (src/calculator.test.js:89:23)
    at processImmediate (node:internal/timers:464:21)

multiply should throw a TypeError if arguments are not numbers

-actual
+expected

-ReferenceError: x is not defined
+TypeError
AssertionError: expected [Function] to throw 'TypeError' but 'ReferenceError: x is not defined' was thrown
    at Context.<anonymous> (src/calculator.test.js:95:56)
    at processImmediate (node:internal/timers:464:21)

multiply should multiply two positive numbers

ReferenceError: x is not defined
    at Object.exports._check (src/calculator.js:4:28)
    at Object.exports.multiply (src/calculator.js:22:11)
    at Context.<anonymous> (src/calculator.test.js:104:23)
    at processImmediate (node:internal/timers:464:21)

multiply should multiply two negative numbers

ReferenceError: x is not defined
    at Object.exports._check (src/calculator.js:4:28)
    at Object.exports.multiply (src/calculator.js:22:11)
    at Context.<anonymous> (src/calculator.test.js:108:23)
    at processImmediate (node:internal/timers:464:21)

multiply should multiply one positive number and one negative number

ReferenceError: x is not defined
    at Object.exports._check (src/calculator.js:4:28)
    at Object.exports.multiply (src/calculator.js:22:11)
    at Context.<anonymous> (src/calculator.test.js:112:23)
    at processImmediate (node:internal/timers:464:21)

divide should throw a TypeError if arguments are not numbers

-actual
+expected

-ReferenceError: x is not defined
+TypeError
AssertionError: expected [Function] to throw 'TypeError' but 'ReferenceError: x is not defined' was thrown
    at Context.<anonymous> (src/calculator.test.js:118:54)
    at processImmediate (node:internal/timers:464:21)

divide should divide two positive numbers

ReferenceError: x is not defined
    at Object.exports._check (src/calculator.js:4:28)
    at Object.exports.divide (src/calculator.js:27:11)
    at Context.<anonymous> (src/calculator.test.js:127:23)
    at processImmediate (node:internal/timers:464:21)

divide should divide two negative numbers

ReferenceError: x is not defined
    at Object.exports._check (src/calculator.js:4:28)
    at Object.exports.divide (src/calculator.js:27:11)
    at Context.<anonymous> (src/calculator.test.js:131:23)
    at processImmediate (node:internal/timers:464:21)

divide should divide one positive number and one negative number

ReferenceError: x is not defined
    at Object.exports._check (src/calculator.js:4:28)
    at Object.exports.divide (src/calculator.js:27:11)
    at Context.<anonymous> (src/calculator.test.js:135:23)
    at processImmediate (node:internal/timers:464:21)

@@ -1,47 +1,30 @@
exports._check = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Block must not be padded by blank lines.
(learn more)

};

exports.add = (x, y) => {

Copy link
Collaborator

Choose a reason for hiding this comment

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

Trailing spaces not allowed.
(learn more)

};

exports.add = (x, y) => {

if (typeof x !== 'number') {
throw new TypeError(`${x} is not a number`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

'x' is not defined.
(learn more)

};

exports.add = (x, y) => {

if (typeof x !== 'number') {
throw new TypeError(`${x} is not a number`);
}
if (typeof y !== 'number') {
throw new TypeError(`${y} is not a number`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

'y' is not defined.
(learn more)

};

exports.add = (x, y) => {
exports._check(x, y)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing semicolon.
(learn more)

if (typeof y !== 'number') {
throw new TypeError(`${y} is not a number`);
}
exports._check(x, y)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing semicolon.
(learn more)

if (typeof y !== 'number') {
throw new TypeError(`${y} is not a number`);
}
exports._check(x, y)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing semicolon.
(learn more)

if (typeof y !== 'number') {
throw new TypeError(`${y} is not a number`);
}
exports._check(x, y)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing semicolon.
(learn more)

};

exports.add = (x, y) => {

if (typeof x !== 'number') {
throw new TypeError(`${x} is not a number`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line is responsible for 12 failing tests. Run npm test and see if you can figure out why.

❌ add should add two positive numbers
❌ add should add two negative numbers
❌ add should add one positive number and one negative number
❌ subtract should subtract two positive numbers
❌ subtract should subtract two negative numbers
❌ subtract should subtract one positive number and one negative number
❌ multiply should multiply two positive numbers
❌ multiply should multiply two negative numbers
❌ multiply should multiply one positive number and one negative number
❌ divide should divide two positive numbers
❌ divide should divide two negative numbers
❌ divide should divide one positive number and one negative number

@dantharejabot
Copy link
Collaborator

✨ Changes synced ✨

When a pull request is open, GitHub tracks changes to the branch it was opened from. As you push changes to your fork's dev branch, you'll automatically see them here.

Thanks for the changes, @vijaytakbhate2002. I'm reviewing them now.

Copy link
Collaborator

@dantharejabot dantharejabot left a comment

Choose a reason for hiding this comment

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

This is a great attempt, @vijaytakbhate2002!

I would like to request a few changes before merging your work. Please review my comments below and make the appropriate changes to your code.

After you update your code locally, follow the instructions to save your changes locally and push your changes to your fork.

When you push your changes to your fork, I'll come back for another review.


There are 10 style guide violations in your contribution. I've marked them with inline comments for your convenience.

Please revisit your code and follow the style guide best practices.

Hint: You might be able to fix some issues automatically by running npm run lint -- --fix


There are 5 tests still pending. In your test file, change describe.skip to describe and ensure they pass.

⚠️ _check should throw a TypeError if arguments are not numbers
⚠️ _check should be called once in "add"
⚠️ _check should be called once in "subtract"
⚠️ _check should be called once in "multiply"
⚠️ _check should be called once in "divide"

};

exports.add = (x, y) => {
exports._check(x, y);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Trailing spaces not allowed.
(learn more)


exports.add = (x, y) => {
exports._check(x, y);
return x + y;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Trailing spaces not allowed.
(learn more)

throw new TypeError(`${y} is not a number`);
}
return x - y;
exports._check(x, y);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Trailing spaces not allowed.
(learn more)

}
return x - y;
exports._check(x, y);
return x - y;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Trailing spaces not allowed.
(learn more)

throw new TypeError(`${y} is not a number`);
}
return x * y;
exports._check(x, y);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Trailing spaces not allowed.
(learn more)

}
return x * y;
exports._check(x, y);
return x * y;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Trailing spaces not allowed.
(learn more)

}
if (typeof y !== 'number') {
throw new TypeError(`${y} is not a number`);
exports._check(x, y);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Trailing spaces not allowed.
(learn more)

if (typeof y !== 'number') {
throw new TypeError(`${y} is not a number`);
exports._check(x, y);
if (y === 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Trailing spaces not allowed.
(learn more)

throw new TypeError(`${y} is not a number`);
exports._check(x, y);
if (y === 0) {
throw new Error("Cannot divide by zero");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Strings must use singlequote.
(learn more)

}
return x / y;
return x / y;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Trailing spaces not allowed.
(learn more)

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