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

PR for Issue6: projectOwner & projectName is not set in .all-contributorsrc file. #80

Merged
merged 13 commits into from
May 29, 2018

Conversation

M-ZubairAhmed
Copy link
Contributor

@M-ZubairAhmed M-ZubairAhmed commented Dec 27, 2017

What:

Why:

  • As no error message is in place to check if project name and owner are present

How:

  • Added check in config-file before config is written into a json file
  • Added check in check before url is being constructed
  • wrapped json parse method in try catch from check to handle error

Checklist:

  • Documentation
  • Tests
  • Ready to be merged
  • Added myself to contributors table

@codecov-io
Copy link

codecov-io commented Dec 27, 2017

Codecov Report

Merging #80 into master will increase coverage by 0.44%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #80      +/-   ##
==========================================
+ Coverage   53.54%   53.99%   +0.44%     
==========================================
  Files          19       19              
  Lines         409      413       +4     
  Branches       66       68       +2     
==========================================
+ Hits          219      223       +4     
  Misses        161      161              
  Partials       29       29
Impacted Files Coverage Δ
src/util/config-file.js 68.18% <100%> (+7.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1562a37...fdcb6dd. Read the comment docs.

Copy link
Collaborator

@machour machour left a comment

Choose a reason for hiding this comment

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

Thank you @M-ZubairAhmed! Left you some comments.

Do you think you could add some tests for this?

body = JSON.parse(res.body)
contributorsIds = body.map(contributor => contributor.login)
} catch (error) {
throw new Error(error)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we catch if we're going to throw anyways? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh ok should i use chalk to display the error

return getContributorsPage(url)
if (owner === '') {
throw new Error('Error! Project owner is not set in .all-contributorsrc')
} else if (name === '') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

no need for else

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, i will replace it with if

throw new Error('Error! Project owner is not set in .all-contributorsrc')
} else if (name === '') {
throw new Error('Error! Project name is not set in .all-contributorsrc ')
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

no need for else here too

throw new Error(`Error! Project Name is not set in ${configPath}`)
} else if (content.projectName === '') {
throw new Error(`Error! Project Name is not set in ${configPath}`)
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same remarks for elses

@M-ZubairAhmed
Copy link
Contributor Author

i did the changes, i will add the tests soon

Copy link
Collaborator

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Looking good! Just one thing

@@ -14,6 +14,12 @@ function readConfig(configPath) {
}

function writeConfig(configPath, content) {
if (content.projectOwner === '') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of '', why don't we do a simple falsy check? if (!content.projectOwner)

This has the added benefit of working if the value is set to null or undefined somehow.

We should do that for all the checks I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kentcdodds thank you for your comment, i however feel that it could be a big pr, would you like me to add that in the current pr?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not an addition, it's simply a change to your addition. This change wont make the PR any bigger...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure will get on it

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 didnt knew this https://stackoverflow.com/a/8693015.
Thank you @kentcdodds

@M-ZubairAhmed
Copy link
Contributor Author

added changes as per @kentcdodds comment. Please @machour @kentcdodds review when you guys get time

module.exports = function getContributorsFromGithub(owner, name) {
if (!owner) {
throw new Error(
`${owner} aaaaError! Project owner is not set in .all-contributorsrc`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm guessing this aaaa here is a typo?

Other than that, this looks good!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

damn how did i miss that. Fixed it

@@ -0,0 +1,54 @@
const pify = require('pify')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, it's been a little while, but why does this file exist? It doesn't appear to be in use anywhere in the project (other than tests)...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry but this is a node package isn't it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I should have been more clear. I'm commenting on the file src/utils/check.js not pify.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry for being late.
It seems that this file was removed in this 152a1fe commit. I retested everything

@@ -1,15 +1,43 @@
import configFile from '../config-file'

const absentFile = './abc'
const expected = `Configuration file not found: ${absentFile}`
const absentConfileFileExpected = `Configuration file not found: ${absentFile}`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed this as, we have more test with expected in this file now.

Copy link
Collaborator

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

This looks good. Thanks so much!

@kentcdodds kentcdodds merged commit c4a0484 into all-contributors:master May 29, 2018
@M-ZubairAhmed M-ZubairAhmed deleted the message-noOwner branch May 30, 2018 10:27
@M-ZubairAhmed M-ZubairAhmed mentioned this pull request Feb 23, 2019
11 tasks
Berkmann18 pushed a commit that referenced this pull request May 24, 2020
* docs: update README.md

* docs: update .all-contributorsrc
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.

4 participants