-
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"detectObjects": false, | ||
"enforceConst": false, | ||
"ignore": [0, 1, 2, 3], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please remove this ignore statement. |
||
"reporter": "detailed" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/node_modules | ||
/coverage | ||
node_modules/* | ||
coverage/* | ||
test/feature/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"extends": "airbnb-base", | ||
"env" : { | ||
"node": true, | ||
"mocha": true | ||
}, | ||
"rules": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please clarify the reason for using the rule. |
||
"max-lines-per-function" : ["error", 30], | ||
"no-plusplus" : ["error", { "allowForLoopAfterthoughts": true }], | ||
"no-unused-vars": [ | ||
"error", | ||
{ | ||
"varsIgnorePattern": "should|expect|Before|After|Given" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. avoid this rule using a plug-in? |
||
} | ||
] | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"threshold": 30, | ||
"identifiers": true, | ||
"literals": true, | ||
"color": true, | ||
"ignore": "coverage", | ||
"minInstances": 2, | ||
"truncate": 100 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ script: | |
- npm run post-unit | ||
- npm run integration | ||
- npm run post-integration | ||
- npm run quality |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,16 +87,20 @@ const changeGitlab = (host) => { | |
}; | ||
|
||
const changeServer = async (options) => { | ||
let { host, port, type } = options; | ||
const { host, port } = options; | ||
let { type } = options; | ||
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 commentThe 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 commentThe 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:
|
||
} | ||
if (type === 'ms') { | ||
return changeMainServer(host, port); | ||
} if (type === 'gitlab') { | ||
return changeGitlab(host); | ||
} | ||
return { | ||
name: 'invalid_server', | ||
}; | ||
}; | ||
|
||
const changeLogger = async (options) => { | ||
|
@@ -124,15 +128,19 @@ const changeLogger = async (options) => { | |
const getInput = async (args, options) => { | ||
switch (args.preference) { | ||
case 'changelang': | ||
return await changeLang(options); | ||
return changeLang(options); | ||
case 'changeserver': | ||
return await changeServer(options); | ||
return changeServer(options); | ||
case 'show': | ||
return { | ||
name: 'show_prefs', | ||
}; | ||
case 'logger': | ||
return await changeLogger(options); | ||
return changeLogger(options); | ||
default: | ||
return { | ||
name: 'invalid_command', | ||
}; | ||
} | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,12 +23,16 @@ const onSubmissionPending = () => { | |
}; | ||
|
||
const printTableAndGetScore = (data) => { | ||
const testCaseColWidth = 15; | ||
const statusColWidth = 25; | ||
const scoreColWidth = 15; | ||
|
||
const table = new Table({ | ||
head: [chalk.cyan('Test Case #'), chalk.cyan('Status'), chalk.cyan('Score')], | ||
colWidths: [15, 25, 15], | ||
colWidths: [testCaseColWidth, statusColWidth, scoreColWidth], | ||
}); | ||
let totalScore = 0; | ||
for (i = 0; i < data.marks.length; i++) { | ||
for (let i = 0; i < data.marks.length; ++i) { | ||
totalScore += +data.marks[i]; | ||
table.push([(i + 1), data.comment[i], data.marks[i]]); | ||
} | ||
|
@@ -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 commentThe 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 commentThe 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 |
||
|
||
console.log(`\n${chalk.yellow('Log :\n')}${new Buffer(data.log, 'base64').toString()}`); | ||
console.log(`\n${chalk.yellow('Log :\n')}${Buffer.from(data.log, 'base64').toString()}`); | ||
if (data.status !== 0) { | ||
console.log(chalk.red('Penalty : ') + data.penalty); | ||
} else if (data.status === 0) { | ||
|
@@ -71,6 +75,8 @@ const sendOutput = (event) => { | |
stopSpinner(); | ||
onScores(event.details); | ||
break; | ||
default: | ||
console.log(chalk.red('\nInvalid Event')); | ||
} | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ const preferenceManager = require('../utils/preference-manager'); | |
|
||
const eventForShowPref = (changePrefEvent) => { | ||
const cliPrefs = preferenceManager.getPreference({ name: 'cliPrefs' }); | ||
changePrefEvent.details = { | ||
const details = { | ||
gitlab_host: cliPrefs.gitlab.host, | ||
mainserver_host: cliPrefs.main_server.host, | ||
mainserver_port: cliPrefs.main_server.port, | ||
|
@@ -11,7 +11,10 @@ const eventForShowPref = (changePrefEvent) => { | |
logger_location: cliPrefs.logger.logLocation, | ||
logger_blacklist: cliPrefs.logger.blacklist, | ||
}; | ||
return changePrefEvent; | ||
return { | ||
...changePrefEvent, | ||
details, | ||
}; | ||
}; | ||
|
||
const getPrefsObjectToStore = (prefsName, values) => ({ | ||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. The function |
||
} else if (changePrefEvent.name === 'logger_pref_changed') { | ||
storeLoggerPref(changePrefEvent.details); | ||
} | ||
|
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 :
I think we can switch both to
true
.