Address all eslint warnings

Address all eslint warnings that were still present by:

* Extracting code to a new function in order to reduce complexity
* Renamed error variables and use shorthand notation for objects
* Disabling eslint warnings where addressing the issue would require too much refactoring
This commit is contained in:
Jose Bolos
2022-04-11 16:16:54 +01:00
parent 0e7849dd07
commit b9b049ec2b
7 changed files with 61 additions and 46 deletions

View File

@@ -43,13 +43,15 @@ function route(app) {
task.actions = (task.actions ? task.actions.join('\n') : '');
response.render('task/edit', {
edited: (typeof request.query.edited !== 'undefined'),
standards: standards,
standards,
task: presentTask(task),
isTaskSubPage: true
});
});
});
/* eslint-disable complexity */
/* eslint-disable max-statements */
app.express.post('/:id/edit', (request, response, next) => {
app.webservice.task(request.params.id).get({}, (error, task) => {
if (error) {
@@ -57,9 +59,11 @@ function route(app) {
}
const originalActions = request.body.actions;
const originalHeaders = request.body.headers;
request.body.ignore = request.body.ignore || [];
request.body.timeout = request.body.timeout || undefined;
request.body.wait = request.body.wait || undefined;
if (request.body.actions) {
request.body.actions = request.body.actions.split(/[\r\n]+/)
.map(action => {
@@ -69,15 +73,18 @@ function route(app) {
return Boolean(action);
});
}
if (!request.body.actions) {
request.body.actions = [];
}
request.body.username = request.body.username || undefined;
request.body.password = request.body.password || undefined;
request.body.hideElements = request.body.hideElements || undefined;
request.body.headers = httpHeaders(request.body.headers || '', true);
app.webservice.task(request.params.id).edit(request.body, error => {
if (error) {
app.webservice.task(request.params.id).edit(request.body, webserviceError => {
if (webserviceError) {
task.name = request.body.name;
task.ignore = request.body.ignore;
task.timeout = request.body.timeout;
@@ -100,9 +107,9 @@ function route(app) {
return standard;
});
return response.render('task/edit', {
error: error,
standards: standards,
task: task,
webserviceError,
standards,
task,
isTaskSubPage: true
});
}

View File

@@ -28,9 +28,9 @@ function route(app) {
if (error) {
return next();
}
app.webservice.task(request.params.id).results({}, (error, results) => {
if (error) {
return next(error);
app.webservice.task(request.params.id).results({}, (webserviceError, results) => {
if (webserviceError) {
return next(webserviceError);
}
const presentedResults = presentResultList(results.map(presentResult));
response.render('task', {