-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add npm run quality
script, Update Readme
#97
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #97 +/- ##
========================================
- Coverage 100% 98.58% -1.42%
========================================
Files 21 22 +1
Lines 591 635 +44
========================================
+ Hits 591 626 +35
- Misses 0 9 +9
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mukkachaitanya please see the suggested changes.
package.json
Outdated
@@ -9,7 +9,8 @@ | |||
"integration": "nyc --reporter=lcov --reporter=text-lcov -s --all mocha 'test/integration/**/*.js'", | |||
"post-integration": "nyc report --reporter=lcov > coverage.lcov && codecov -F integration && rm -rf ~/.autolabjs", | |||
"feature": "nyc --reporter=lcov --reporter=text-lcov -s --all cucumber-js 'test/feature/features' -r 'test/feature/steps'", | |||
"post-feature": "nyc report --reporter=lcov > coverage.lcov && codecov -F feature" | |||
"post-feature": "nyc report --reporter=lcov > coverage.lcov && codecov -F feature", | |||
"quality" : "eslint . & jsinspect . & buddy ." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now the style is to put a comma even on the last line so that the diff shows modification only on one line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"quality" : "eslint . && jsinspect . && buddy ."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sir, if eslint
fails the none of the further checks are taken, i.e., none of jsinspect/buddy commands are executed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also sir, json
doesn't accept a trailing comma. Throws the following error :
npm ERR! JSON.parse Unexpected token } in JSON at position 831 while parsing near '...ect . & buddy .",
npm ERR! JSON.parse },
npm ERR! JSON.parse "bin": {
npm ERR! JSON.parse "a...'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
@@ -1,5 +1,9 @@ | |||
{ | |||
"extends": "airbnb-base", | |||
"env" : { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are these needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eslint
give errors of the form :
12:3 error 'it' is not defined no-undef
18:3 error 'describe' is not defined no-undef
when mocha
env is not set to be true.
.jsinspectrc
Outdated
@@ -0,0 +1,8 @@ | |||
{ | |||
"threshold": 60, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not similar to codeclimate duplication weight. This number is the number of lines. A prudent value seems to be between 4 to 6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make that change.
@mukkachaitanya also it is better to run |
Also Sir, there are a lot of |
6384353
to
254c706
Compare
254c706
to
e99c3b6
Compare
This is rude awakening for me as well. Please fix these issues before we do further development. One hypersensitive check is the threshold parameter in |
Some changes in commit 6db57af to be considered :
"no-plusplus" : ["error", { "allowForLoopAfterthoughts": true }],
"no-unused-vars": [
"error",
{
"varsIgnorePattern": "should|expect|Before|After|Given"
}
]
"max-lines-per-function" : ["off"]
|
.buddyrc
Outdated
{ | ||
"detectObjects": false, | ||
"enforceConst": false, | ||
"ignore": [0, 1, 2, 3], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this ignore statement.
.buddyrc
Outdated
@@ -0,0 +1,6 @@ | |||
{ | |||
"detectObjects": false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please clarify the use of next two lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the documentation :
detectObjects - detect object expressions and properties
enforceConst - require literals to be defined using const
I think we can switch both to true
.
.eslintrc
Outdated
"node": true, | ||
"mocha": true | ||
}, | ||
"rules": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please clarify the reason for using the rule.
.eslintrc
Outdated
"no-unused-vars": [ | ||
"error", | ||
{ | ||
"varsIgnorePattern": "should|expect|Before|After|Given" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid this rule using a plug-in?
@@ -37,9 +41,9 @@ const printTableAndGetScore = (data) => { | |||
}; | |||
|
|||
const printStatusAndLog = (data, totalScore) => { | |||
logger.moduleLog('debug', 'Eval Output', `Evaluation logs: ${new Buffer(data.log, 'base64').toString()}.`); | |||
logger.moduleLog('debug', 'Eval Output', `Evaluation logs: ${Buffer.from(data.log, 'base64').toString()}.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Buffer constructor is different depending on the type of its argument, and not validating such arguments might lead to memory disclosure and denial of service. So eslint enforces the use of Buffer.from()
or Buffer.alloc()
instead.
if (!type) { | ||
const typePrompt = prefPrompts.getServerTypePrompt(); | ||
type = (await inquirer.prompt(typePrompt)).type; | ||
({ type } = (await inquirer.prompt(typePrompt))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why brackets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have discussed this, sir, but for having everything in a single thread; the MDN documentation says:
The parentheses ( ... ) around the assignment statement are required when using object literal destructuring assignment without a declaration.
{a, b} = {a: 1, b: 2} is not valid stand-alone syntax, as the {a, b} on the left-hand side is considered a block and not an object literal.
However, ({a, b} = {a: 1, b: 2}) is valid, as is var {a, b} = {a: 1, b: 2}
NOTE: Your ( ... ) expression needs to be preceded by a semicolon or it may be used to execute a function on the previous line.
@@ -77,7 +80,7 @@ const storePrefs = (changePrefEvent) => { | |||
} else if (changePrefEvent.name === 'server_changed') { | |||
storeServer(changePrefEvent.details); | |||
} else if (changePrefEvent.name === 'show_prefs') { | |||
changePrefEvent = eventForShowPref(changePrefEvent); | |||
return eventForShowPref(changePrefEvent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function storePrefs
was modifying the input argument changePrefEvent
storing and then returning it. Instead, the above modification returns the new value directly.
package.json
Outdated
@@ -9,7 +9,8 @@ | |||
"integration": "nyc --reporter=lcov --reporter=text-lcov -s --all mocha 'test/integration/**/*.js'", | |||
"post-integration": "nyc report --reporter=lcov > coverage.lcov && codecov -F integration && rm -rf ~/.autolabjs", | |||
"feature": "nyc --reporter=lcov --reporter=text-lcov -s --all cucumber-js 'test/feature/features' -r 'test/feature/steps'", | |||
"post-feature": "nyc report --reporter=lcov > coverage.lcov && codecov -F feature" | |||
"post-feature": "nyc report --reporter=lcov > coverage.lcov && codecov -F feature", | |||
"quality": "eslint . & jsinspect . & buddy ." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add &&
lib/utils/preference-manager.js
Outdated
@@ -1,3 +1,4 @@ | |||
/* eslint no-use-before-define: "warn" */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to refactor the cyclic functions.
b311e6a
to
417c17c
Compare
Requirements
Description of the Change
Adds
npm run quality
script that uses eslint, jsinspect and buddy.js to keep a check on the quality of the project.Benefits
Improved and easy code quality checking.
Applicable Issues
Addresses #96