Skip to content

Commit

Permalink
refactor: added optional chaining and
Browse files Browse the repository at this point in the history
solved merge conflits for merging master branch
  • Loading branch information
ManikantaMandala committed Oct 9, 2024
1 parent 3dba131 commit e9ed098
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions apps/nunjucks-filters/src/customFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function getPayloadExamples(msg) {
}

const payload = msg.payload();
if (payload && payload.examples()) {
if (payload?.examples()) {
return payload.examples().map(example => ({ example }));
}
}
Expand Down Expand Up @@ -90,7 +90,7 @@ function getHeadersExamples(msg) {
}

const headers = msg.headers();
if (headers && headers.examples()) {
if (headers?.examples()) {
return headers.examples().map(example => ({ example }));
}
}
Expand Down Expand Up @@ -142,7 +142,7 @@ filter.oneLine = oneLine;
* @scopePropName {string} - Name of param for JSDocs
* @returns {string} JSDoc compatible entry
*/
function docline(field, fieldName, scopePropName) {
function docline(field, fieldName, scopePropName) {
/* eslint-disable sonarjs/cognitive-complexity */
const getType = (f) => f.type() || 'string';
const getDescription = (f) => f.description() ? ` - ${f.description().replace(/\r?\n|\r/g, '')}` : '';
Expand Down Expand Up @@ -198,11 +198,7 @@ function replaceServerVariablesWithValues(url, serverVariables) {
const getVariableValue = (object, variable) => {
const keyValue = object[variable]._json;

<<<<<<< HEAD
if (keyValue) return keyValue.default ?? keyValue.enum?.[0];
=======
if (keyValue) return keyValue.default || (keyValue.enum && keyValue.enum[0]);
>>>>>>> 9907055 (refactor: improve custom filters readability with optional chaining)
};

const urlVariables = getVariablesNamesFromUrl(url);
Expand Down

0 comments on commit e9ed098

Please sign in to comment.