Skip to content

Commit

Permalink
Merge pull request #1495 from telefonicaid/task/remove_extract_variables
Browse files Browse the repository at this point in the history
remove extractVariables
  • Loading branch information
fgalan authored Oct 5, 2023
2 parents 1cfbb33 + 7661de9 commit 1edff87
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 32 deletions.
3 changes: 2 additions & 1 deletion CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
- Remove: extractVariables from jexl plugin (no needed anymore since the removal of bidireational plugin)
- Fix: ensure service and subservice in context of error handlers using req headers
- Fix: remove attribute of measures with name `id` or `type` to avoid collisions (#1485)
- Fix: ensure entity id and type are string (#1476)
- Fix: update ctxt allow nested expressions (#1493)
- Fix: change log level contextAvailable expression exception (from WARN to INFO)
- Fix: null values arithmetics in JEXL expressions (#1440)
- Fix: remove mongo `DeprecationWarning: current Server Discovery and Monitoring engine is deprecated` by setting `useUnifiedTopology = true`
- Upgrade mongodb dev dep from 4.17.0 to 4.17.1
- Upgrade mongodb dev dep from 4.17.0 to 4.17.1
5 changes: 0 additions & 5 deletions lib/plugins/expressionPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,8 @@ function contextAvailable(expression, context, typeInformation) {
return jexlParser.contextAvailable(expression, context);
}

function extractVariables(expression) {
return jexlParser.extractVariables(expression);
}

exports.parse = parse;
exports.setJEXLTransforms = setJEXLTransforms;
exports.applyExpression = applyExpression;
exports.extractContext = extractContext;
exports.contextAvailable = contextAvailable;
exports.extractVariables = extractVariables;
26 changes: 0 additions & 26 deletions lib/plugins/jexlParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,6 @@ function parse(expression, context, callback) {
}
}

function extractVariables(expression) {
const inst = new Lexer(grammar);
let variables = [];

try {
const tokens = inst.tokenize(expression);

// Keep only root attributes, removing the dot and sub-attributes. For example, if we have
// a.0.b, a.1.b and a.2.b, we will only keep a
// Additionaly, it will remove the function calls, since they are also detected as identifiers
variables = tokens.filter(function (token, index, array) {
return (
(token.type === ' ' && array[index - 1].type !== 'dot') ||
(token.type === 'identifier' && array[index + 1] && array[index + 1].type !== 'openParen')
);
});

// Return only array of values
return variables.map((a) => a.value);
} catch (e) {
logger.warn(logContext, 'Wrong expression found "[%j]" error: "[%s]", it will be ignored', expression, e);
return false;
}
}

function extractContext(attributeList) {
const context = {};
let value;
Expand Down Expand Up @@ -201,7 +176,6 @@ function setTransforms(configMap) {
logger.info(logContext, message);
}

exports.extractVariables = extractVariables;
exports.extractContext = extractContext;
exports.contextAvailable = contextAvailable;
exports.applyExpression = applyExpression;
Expand Down

0 comments on commit 1edff87

Please sign in to comment.