diff --git a/ivette/src/frama-c/client.ts b/ivette/src/frama-c/client.ts index 15b8e1cbe379313ee2c076e3b0fa76905f26a32f..6c85d2b3a102cb1d5b8cbb266a02c36f6113d146 100644 --- a/ivette/src/frama-c/client.ts +++ b/ivette/src/frama-c/client.ts @@ -39,7 +39,7 @@ export abstract class Client { abstract disconnect(): void; /** Send Request */ - abstract send(kind: string, id: string, request: string, data: any): void; + abstract send(kind: string, id: string, request: string, data: json): void; /** Signal ON */ abstract sigOn(id: string): void; diff --git a/ivette/src/frama-c/client_socket.ts b/ivette/src/frama-c/client_socket.ts index 0dc921a02072366e7b1c848ae11599a6e658344d..b057f96598ff2ef59134e6b231dee5a7c52bf17e 100644 --- a/ivette/src/frama-c/client_socket.ts +++ b/ivette/src/frama-c/client_socket.ts @@ -95,7 +95,7 @@ class SocketClient extends Client { } /** Send Request */ - send(kind: string, id: string, request: string, data: any): void { + send(kind: string, id: string, request: string, data: json): void { this.queue.push({ cmd: kind, id, request, data }); this._flush(); } @@ -181,6 +181,7 @@ class SocketClient extends Client { const n1 = this.buffer.length; if (data === undefined || n0 <= n1) break; try { + // eslint-disable-next-line @typescript-eslint/no-explicit-any const cmd: any = JSON.parse(data); if (cmd !== null && typeof (cmd) === 'object') { switch (cmd.res) { diff --git a/ivette/src/frama-c/client_zmq.ts b/ivette/src/frama-c/client_zmq.ts index 89cc9ecd3a32b067e6bc83bafdab0658aa671fb6..5834e0c4bdfda3f78b8b18063172db44f24a084a 100644 --- a/ivette/src/frama-c/client_zmq.ts +++ b/ivette/src/frama-c/client_zmq.ts @@ -62,7 +62,7 @@ class ZmqClient extends Client { } /** Send Request */ - send(kind: string, id: string, request: string, data: any): void { + send(kind: string, id: string, request: string, data: string): void { if (this.zmqSocket) { this.queue.push(kind, id, request, data); this._flush(); diff --git a/ivette/src/frama-c/kernel/Messages.tsx b/ivette/src/frama-c/kernel/Messages.tsx index a02c18dbddb70cf6f226fe835dac952050e360cd..53e32f5232ab526fec99d73535a71c8f61114520 100644 --- a/ivette/src/frama-c/kernel/Messages.tsx +++ b/ivette/src/frama-c/kernel/Messages.tsx @@ -280,7 +280,7 @@ function MessageFilter(props: { filter: State<Filter> }) { ); } -function FilterRatio({ model }: { model: Arrays.ArrayModel<any, any> }) { +function FilterRatio<K, R>({ model }: { model: Arrays.ArrayModel<K, R> }) { const [filtered, total] = [model.getRowCount(), model.getTotalRowCount()]; const title = `${filtered} displayed messages / ${total} total messages`; return ( diff --git a/ivette/src/frama-c/plugins/dive/index.tsx b/ivette/src/frama-c/plugins/dive/index.tsx index fb5775b1add9ec75bce871644fb260a03d21778f..9adfa9f4f0122a5b8659ea9781863c48b0ddcc91 100644 --- a/ivette/src/frama-c/plugins/dive/index.tsx +++ b/ivette/src/frama-c/plugins/dive/index.tsx @@ -56,8 +56,8 @@ interface Cxtcommand { } interface CytoscapeExtended extends Cytoscape.Core { - cxtmenu(options: any): void; - panzoom(options: any): void; + cxtmenu(options: unknown): void; + panzoom(options: unknown): void; } function callstackToString(callstack: API.callstack): string { @@ -217,9 +217,12 @@ class Dive { trigger: 'manual', appendTo: document.body, lazy: false, + // Cytoscape extensions are not typed yet + // eslint-disable-next-line @typescript-eslint/no-explicit-any onCreate: (instance: any) => { const { popperInstance } = instance; if (popperInstance) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any popperInstance.reference = (node as any).popperRef(); } }, @@ -272,14 +275,15 @@ class Dive { } /* eslint-disable no-restricted-syntax */ - receiveGraph(data: any): Cytoscape.CollectionReturnValue { + receiveGraph(data: API.graphData): Cytoscape.CollectionReturnValue { let newNodes = this.cy.collection(); for (const node of data.nodes) { + let stops = undefined if (typeof node.range === 'number') - node.stops = `0% ${node.range}% ${node.range}% 100%`; + stops = `0% ${node.range}% ${node.range}% 100%`; - let ele = this.cy.$id(node.id); + let ele = this.cy.$id(node.id.toString()); if (ele.nonempty()) { ele.removeData(); ele.data(node); @@ -294,7 +298,7 @@ class Dive { ele = this.cy.add({ group: 'nodes', - data: { ...node, parent }, + data: { ...(node as { [k: string]: unknown }), stops, parent }, classes: 'new', }); this.addTips(ele); @@ -320,10 +324,14 @@ class Dive { } for (const dep of data.deps) { - const src = this.cy.$id(dep.src); - const dst = this.cy.$id(dep.dst); + const src = this.cy.$id(dep.src.toString()); + const dst = this.cy.$id(dep.dst.toString()); this.cy.add({ - data: { ...dep, source: dep.src, target: dep.dst }, + data: { + ...(dep as { [k: string]: unknown }), + source: dep.src, + target: dep.dst + }, group: 'edges', classes: src?.hasClass('new') || dst?.hasClass('new') ? 'new' : '', }); @@ -332,11 +340,11 @@ class Dive { return newNodes; } - receiveData(data: any): Cytoscape.NodeSingular { + receiveData(data: API.diffData): Cytoscape.NodeSingular | undefined { this.cy.startBatch(); for (const id of data.sub) - this.remove(this.cy.$id(id)); + this.remove(this.cy.$id(id.toString())); const newNodes = this.receiveGraph(data.add); @@ -344,7 +352,8 @@ class Dive { this.recomputeLayout(newNodes); - return this.cy.$id(data.root); + const root = data.root + return root ? this.cy.$id(root.toString()) : undefined; } get layout(): string { @@ -383,8 +392,8 @@ class Dive { } } - async exec<In, Out>( - request: Server.ExecRequest<In, Out>, + async exec<In>( + request: Server.ExecRequest<In, API.diffData | null>, param: In, ) { try { @@ -417,7 +426,7 @@ class Dive { } } - static async setWindow(window: any): Promise<void> { + static async setWindow(window: API.explorationWindow): Promise<void> { if (Server.isRunning()) await Server.send(API.window, window); } @@ -433,7 +442,7 @@ class Dive { case 'overview': await Dive.setWindow({ perception: { backward: 4, forward: 1 }, - horizon: { backward: null, forward: null }, + horizon: { backward: undefined, forward: undefined }, }); break; default: /* This is useless and impossible if the program is correctly diff --git a/ivette/src/frama-c/server.ts b/ivette/src/frama-c/server.ts index 1ce8efe4b13ddcbbeac40263a76f12b23f10bfa9..5c1518902cb8c78c8b832155ed7873d8ee0c540c 100644 --- a/ivette/src/frama-c/server.ts +++ b/ivette/src/frama-c/server.ts @@ -336,7 +336,7 @@ export function clear() { /** Server configuration. */ export interface Configuration { /** Process environment variables (default: `undefined`). */ - env?: any; + env?: { [VAR: string]: string }; /** Working directory (default: current). */ cwd?: string; /** Server command (default: `frama-c`). */ @@ -694,12 +694,15 @@ export function send<In, Out>( const response: Response<Out> = new Promise<Out>((resolve, reject) => { const unwrap = (js: Json.json) => { const data = request.output(js); - resolve(data as unknown as Out); + if (data) + resolve(data); + else + reject('Wrong response type') }; pending.set(rid, { resolve: unwrap, reject }); }); response.kill = () => pending.get(rid)?.reject(); - client.send(request.kind, rid, request.name, param); + client.send(request.kind, rid, request.name, param as unknown as Json.json); if (!pollingTimer) { const polling = (config && config.polling) || pollingTimeout; pollingTimer = setInterval(() => { diff --git a/ivette/src/frama-c/states.ts b/ivette/src/frama-c/states.ts index cedb61d60b8b3e82c102e2c4914ebb8ef897fe68..1ee7b2726b64d5821d6221b42f2d9f32890aa397 100644 --- a/ivette/src/frama-c/states.ts +++ b/ivette/src/frama-c/states.ts @@ -327,11 +327,11 @@ class SyncState<A> { // --- Synchronized States Registry // -------------------------------------------------------------------------- -const syncStates = new Map<string, SyncState<any>>(); +const syncStates = new Map<string, SyncState<unknown>>(); function getSyncState<A>(h: Handler<A>): SyncState<A> { const id = `${currentProject}@${h.name}`; - let s = syncStates.get(id); + let s = syncStates.get(id) as SyncState<A> | undefined; if (!s) { s = new SyncState(h); syncStates.set(id, s); @@ -440,16 +440,16 @@ class SyncArray<K, A> { // --- Synchronized Arrays Registry // -------------------------------------------------------------------------- -const syncArrays = new Map<string, SyncArray<any, any>>(); +const syncArrays = new Map<string, SyncArray<unknown, unknown>>(); function lookupSyncArray<K, A>( array: Array<K, A>, ): SyncArray<K, A> { const id = `${currentProject}@${array.name}`; - let st = syncArrays.get(id); + let st = syncArrays.get(id) as SyncArray<K,A> | undefined; if (!st) { st = new SyncArray(array); - syncArrays.set(id, st); + syncArrays.set(id, st as SyncArray<unknown, unknown>); } return st; }