Commit a7736860 authored by Mathias Chouet's avatar Mathias Chouet 🍝
Browse files

Get rid of eval() in getSeverity()

parent ac261833
......@@ -422,11 +422,13 @@ export class Message {
public getSeverity(): MessageSeverity {
const m: string = MessageCode[this._code];
const prefix: string = m.split("_")[0];
for (const s in MessageSeverity) { // pas nécessaire, mais permet d'avoir un contrôle de validité
if (MessageSeverity[s] === prefix) {
// tslint:disable-next-line:no-eval
return eval("MessageSeverity." + prefix);
}
switch (prefix) {
case "ERROR":
return MessageSeverity.ERROR;
case "WARNING":
return MessageSeverity.WARNING;
case "INFO":
return MessageSeverity.INFO;
}
throw new Error("Message.getSeverity() : valeur de code '" + this._code + "' invalide");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment