Verified Commit 3b12d324 authored by Nadim Kobeissi's avatar Nadim Kobeissi 💾
Browse files

Lint

parent 459fc2d8
Pipeline #852 passed with stage
in 50 seconds
......@@ -22,9 +22,9 @@ export default class AnalysisProvider {
static analysisOutput = vscode.window.createOutputChannel("Verifpal Analysis");
static decorate(editor: vscode.TextEditor, parsedResults) {
let fileContents = editor.document.getText();
let passedQueries: vscode.DecorationOptions[] = [];
let failedQueries: vscode.DecorationOptions[] = [];
const fileContents = editor.document.getText();
const passedQueries: vscode.DecorationOptions[] = [];
const failedQueries: vscode.DecorationOptions[] = [];
const fileContentsArray = fileContents.split("\n");
for (let i = 0; i < parsedResults.length; i++) {
if (parsedResults[i].Resolved) {
......@@ -34,11 +34,11 @@ export default class AnalysisProvider {
}
for (let i = 0; i < parsedResults.length; i++) {
for (let line = 0; line < fileContentsArray.length; line++) {
let tl = fileContentsArray[line].toLowerCase();
let tq = parsedResults[i].Query.toLowerCase();
let queryIndex = tl.indexOf(tq);
const tl = fileContentsArray[line].toLowerCase();
const tq = parsedResults[i].Query.toLowerCase();
const queryIndex = tl.indexOf(tq);
if (queryIndex >= 0) {
let range = new vscode.Range(
const range = new vscode.Range(
new vscode.Position(line, queryIndex),
new vscode.Position(line, queryIndex + tq.length)
);
......@@ -55,11 +55,11 @@ export default class AnalysisProvider {
if (!parsedResults[i].Resolved) {
continue;
}
let constantNames = parsedResults[i].Constants;
const constantNames = parsedResults[i].Constants;
for (let ii = 0; ii < constantNames.length; ii++) {
let constMatch = tl.match(`(\\W)${constantNames[ii]}(\\,|\\]|\\)|\\s|\\^|$)`);
const constMatch = tl.match(`(\\W)${constantNames[ii]}(\\,|\\]|\\)|\\s|\\^|$)`);
if (constMatch !== null && constMatch.index !== undefined) {
let range = new vscode.Range(
const range = new vscode.Range(
new vscode.Position(line, constMatch.index + 1),
new vscode.Position(line, constMatch.index + 1 + constantNames[ii].length)
);
......@@ -79,7 +79,7 @@ export default class AnalysisProvider {
vscode.window.showErrorMessage("Verifpal: Analysis is already running.");
return;
}
let fileContents = editor.document.getText();
const fileContents = editor.document.getText();
vscode.window.showInformationMessage("Verifpal: Running analysis...");
analysisActive = true;
return VerifpalLib.getVerify(fileContents).then((result: string) => {
......@@ -88,9 +88,9 @@ export default class AnalysisProvider {
const verifyResults = JSON.parse(result);
const parsedResults: Object[] = [];
for (let i = 0; i < verifyResults.length; i++) {
let q = JSON.stringify(verifyResults[i].Query);
const q = JSON.stringify(verifyResults[i].Query);
VerifpalLib.getPrettyQuery(q).then((result: string) => {
let constantNames: string[] = [];
const constantNames: string[] = [];
switch (verifyResults[i].Query.Kind) {
case "confidentiality":
for (let ii = 0; ii < verifyResults[i].Query.Constants.length; ii++) {
......@@ -118,8 +118,8 @@ export default class AnalysisProvider {
}
break;
}
let formattedSummary = verifyResults[i].Summary.replace(/\[(\d|;)+m/gm, "");
let p = {
const formattedSummary = verifyResults[i].Summary.replace(/\[(\d|;)+m/gm, "");
const p = {
Query: result,
Resolved: verifyResults[i].Resolved,
Summary: formattedSummary,
......
......@@ -15,21 +15,21 @@ export default class DiagramProvider {
static renderDiagram(fileName: string, fileContents: string, extensionPath: string) {
this.diagramActive = true;
let modelName = path.basename(fileName);
const modelName = path.basename(fileName);
let diagramHtml = fs.readFileSync(
path.join(extensionPath, "res", "diagram.html")
).toString();
VerifpalLib.getPrettyDiagram(fileContents).then((result: string) => {
let ep1 = this.webviewPanel.webview.asWebviewUri(vscode.Uri.file(
const ep1 = this.webviewPanel.webview.asWebviewUri(vscode.Uri.file(
path.join(extensionPath, "res", "webfont.js")
));
let ep2 = this.webviewPanel.webview.asWebviewUri(vscode.Uri.file(
const ep2 = this.webviewPanel.webview.asWebviewUri(vscode.Uri.file(
path.join(extensionPath, "res", "snap.svg-min.js")
));
let ep3 = this.webviewPanel.webview.asWebviewUri(vscode.Uri.file(
const ep3 = this.webviewPanel.webview.asWebviewUri(vscode.Uri.file(
path.join(extensionPath, "res", "underscore-min.js")
));
let ep4 = this.webviewPanel.webview.asWebviewUri(vscode.Uri.file(
const ep4 = this.webviewPanel.webview.asWebviewUri(vscode.Uri.file(
path.join(extensionPath, "res", "sequence-diagram-min.js")
));
diagramHtml = diagramHtml.replace("$$EXTPATH1$$", ep1);
......
......@@ -11,8 +11,8 @@ export default class HoverProvider {
const fileContents = document.getText();
return VerifpalLib.getKnowledgeMap(fileContents).then((result: string) => {
const knowledgeMap = JSON.parse(result.toString());
let primitiveInfo = VerifpalLib.primitiveInfo(word);
let queryInfo = VerifpalLib.queryInfo(word);
const primitiveInfo = VerifpalLib.primitiveInfo(word);
const queryInfo = VerifpalLib.queryInfo(word);
if (primitiveInfo.length > 0) {
return new Promise((resolve) => {
resolve(new vscode.Hover([
......@@ -32,12 +32,12 @@ export default class HoverProvider {
]));
});
} else {
let info = VerifpalLib.constantInfo(word, knowledgeMap);
const info = VerifpalLib.constantInfo(word, knowledgeMap);
if (!info.Valid) {
return;
}
return VerifpalLib.getPrettyValue(info.Assigned).then((result: string) => {
let hoverText = `// Created by ${info.Creator}\n${result}`;
const hoverText = `// Created by ${info.Creator}\n${result}`;
return new Promise((resolve) => {
resolve(new vscode.Hover([
"Verifpal: Constant Information", {
......
......@@ -57,7 +57,7 @@ export default class VerifpalLib {
if (verifpalOutputError) {
reject(verifpalOutputError);
} else {
let result = verifpalOutput;
const result = verifpalOutput;
resolve(result);
}
});
......@@ -102,13 +102,13 @@ export default class VerifpalLib {
}
static constantInfo = (constantName: string, knowledgeMap) => {
let info = {
const info = {
Creator: "",
Assigned: "",
KnownBy: "",
Valid: false,
};
let i = VerifpalLib.getKnowledgeMapIndexFromConstant(constantName, knowledgeMap);
const i = VerifpalLib.getKnowledgeMapIndexFromConstant(constantName, knowledgeMap);
if (i >= 0) {
info.Creator = knowledgeMap.Creator[i];
info.Assigned = JSON.stringify(knowledgeMap.Assigned[i]) + "\n";
......@@ -119,7 +119,7 @@ export default class VerifpalLib {
}
static primitiveInfo = (primitiveName: string) => {
let primitives = {
const primitives = {
"ASSERT": {
output: 1,
eg: "ASSERT(MAC(key, message), MAC(key, message)): unused",
......@@ -227,14 +227,14 @@ export default class VerifpalLib {
}
};
if (({}).hasOwnProperty.call(primitives, primitiveName.toUpperCase())) {
let p = primitives[primitiveName.toUpperCase()];
const p = primitives[primitiveName.toUpperCase()];
return `${p.eg}\n// ${p.help}`;
}
return "";
};
static queryInfo = (queryName: string) => {
let queries = {
const queries = {
"confidentiality": {
eg: "confidentiality? a",
help: "Checks whether a given value can be obtained by the attacker.",
......@@ -257,7 +257,7 @@ export default class VerifpalLib {
}
};
if (({}).hasOwnProperty.call(queries, queryName.toLowerCase())) {
let q = queries[queryName.toLowerCase()];
const q = queries[queryName.toLowerCase()];
return `${q.eg}\n// ${q.help}`;
}
return "";
......
......@@ -27,8 +27,8 @@ export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.languages.registerDocumentFormattingEditProvider("verifpal", {
provideDocumentFormattingEdits(document: vscode.TextDocument) {
let fileContents = document.getText();
let fullRange = new vscode.Range(0, 0, document.lineCount, 0);
const fileContents = document.getText();
const fullRange = new vscode.Range(0, 0, document.lineCount, 0);
return VerifpalLib.getPrettyPrint(fileContents).then((result: string) => {
const edit = new vscode.WorkspaceEdit();
edit.replace(document.uri, fullRange, result);
......@@ -40,8 +40,8 @@ export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.commands.registerTextEditorCommand("verifpal.showDiagram", (editor: vscode.TextEditor) => {
let fileName = editor.document.fileName;
let fileContents = editor.document.getText();
const fileName = editor.document.fileName;
const fileContents = editor.document.getText();
DiagramProvider.webviewPanel = vscode.window.createWebviewPanel(
"verifpal",
"Verifpal Protocol Diagram",
......@@ -58,8 +58,8 @@ export function activate(context: vscode.ExtensionContext) {
vscode.workspace.onDidSaveTextDocument((document: vscode.TextDocument) => {
if (DiagramProvider.diagramActive) {
let fileName = document.fileName;
let fileContents = document.getText();
const fileName = document.fileName;
const fileContents = document.getText();
DiagramProvider.renderDiagram(fileName, fileContents, context.extensionPath);
}
});
......
Supports Markdown
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