From d0cdbae599e0b7a9caa52c53fc2e609282bae002 Mon Sep 17 00:00:00 2001 From: pradyuman-verma Date: Thu, 3 Mar 2022 20:18:43 +0530 Subject: [PATCH] fixed checks --- package.json | 6 +++--- status-checks/check.ts | 16 ++++++++-------- tsconfig.json | 3 ++- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 2e73b9a1..84f57114 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,9 @@ "scripts": { "test": "hardhat run scripts/tests/global-test.ts", "coverage": "./node_modules/.bin/solidity-coverage", - "check": "node status-checks/huskyCheck.js", - "check-husky": "node status-checks/huskyCheck.js", - "deploy": "node scripts/deployConnectorsFromCmd.js", + "check": "ts-node status-checks/huskyCheck.ts", + "check-husky": "ts-node status-checks/huskyCheck.ts", + "deploy": "ts-node scripts/deployConnectorsFromCmd.ts", "test:runner": "hardhat run scripts/tests/run-tests.ts", "typechain": "hardhat typechain", "compile": "hardhat compile", diff --git a/status-checks/check.ts b/status-checks/check.ts index 371c3825..d902906b 100644 --- a/status-checks/check.ts +++ b/status-checks/check.ts @@ -92,7 +92,7 @@ const checkEvents = async (connector: { const eventsPath = `${connector.path}/events.sol`; const mainPath = `${connector.path}/main.sol`; if (connector.events.length) { - const eventNames = []; + const eventNames: any[] = []; for (let i1 = 0; i1 < connector.mainEvents.length; i1++) { const mainEvent = connector.mainEvents[i1]; const name = mainEvent.split("(")[0]; @@ -131,7 +131,7 @@ const checkEvents = async (connector: { } } if (connector.mainEvents.length < connector.events.length) { - const deprecatedEvents = connector.events.filter((e) => { + const deprecatedEvents = connector.events.filter((e: string) => { let used = false; for (let index = 0; index < eventNames.length; index++) { if (e.split("(")[0].split(" ")[1] === eventNames[index]) @@ -157,7 +157,7 @@ const checkEvents = async (connector: { const getCommments = async (strs: string | any[]) => { try { const comments = []; - let type: string; + let type: string = ''; for (let index = strs.length - 1; index >= 0; index--) { const str = strs[index]; if (!type) { @@ -194,9 +194,9 @@ const parseCode = async (connector: { path: any; code?: any }) => { const eventsFirstLines = []; let func = []; let funcs = []; - let event = []; - let mainEvents = []; - let firstLine: number; + let event: string[] = []; + let mainEvents: string[] = []; + let firstLine: number = 0; let mainEventsLines = []; for (let index = 0; index < strs.length; index++) { const str = strs[index]; @@ -297,7 +297,7 @@ const parseCode = async (connector: { path: any; code?: any }) => { } }; -const checkComments = async (connector) => { +const checkComments = async (connector: { funcs: string | any[]; path: any; }) => { try { const errors = []; for (let i1 = 0; i1 < connector.funcs.length; i1++) { @@ -317,7 +317,7 @@ const checkComments = async (connector) => { } const reqs = ["@dev", "@notice"]; for (let i3 = 0; i3 < reqs.length; i3++) { - if (!func.comments.some((comment) => comment.startsWith(reqs[i3]))) { + if (!func.comments.some((comment: string) => comment.startsWith(reqs[i3]))) { errors.push( `no ${reqs[i3]} for function ${func.name} at ${connector.path}/main.sol:${func.firstLine}` ); diff --git a/tsconfig.json b/tsconfig.json index af311260..8da7ae1e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,6 +21,7 @@ "tasks/**/*", "test/**/*", "typechain/**/*", - "types/**/*" + "types/**/*", + "status-checks/*" ] }