Skip to content

Commit

Permalink
style: fix prefer-const linter rule violations
Browse files Browse the repository at this point in the history
  • Loading branch information
ssimek committed Jan 17, 2025
1 parent 0c97ebe commit d855332
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 30 deletions.
1 change: 0 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export default tseslint.config(
'no-cond-assign': 'off', // 21 instances
'no-empty': 'off', // 19 instances
'@typescript-eslint/restrict-template-expressions': 'off', // 17 instances
'prefer-const': 'off', // 13 instances
'@typescript-eslint/require-await': 'off', // 11 instances
}
},
Expand Down
3 changes: 1 addition & 2 deletions src/backend/disasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,7 @@ export class GdbDisassembler {
const entireRangeGood = range.isKnownStart || this.isRangeInValidMem(startAddress, endAddress);
const end = endAddress;
// const end = range.isData ? endAddress : this.clipHigh(endAddress, endAddress + this.maxInstrSize); // Get a bit more for functions
let cmd: string;
cmd = `data-disassemble -s ${hexFormat(startAddress)} -e ${hexFormat(end)} -- 5`;
const cmd = `data-disassemble -s ${hexFormat(startAddress)} -e ${hexFormat(end)} -- 5`;
if (this.doTiming) {
const symName = range.symNode ? ` (${range.symNode.symbol.name})` : '';
const count = `${end - startAddress} bytes`.padStart(15);
Expand Down
21 changes: 8 additions & 13 deletions src/backend/gdb_expansion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,9 @@ export function expandValue(variableCreate: (value: string | object, opts?: { ar
};

const stack = [root];
let parseValue;
let parseCommaResult;
let parseCommaValue;
let parseResult;
let createValue;
let variable = '';

const getNamespace = (variable): string => {
function getNamespace(variable): string {
let namespace = '';
let prefix = '';
stack.push(variable);
Expand All @@ -91,7 +86,7 @@ export function expandValue(variableCreate: (value: string | object, opts?: { ar
return prefix + namespace;
};

const parseTupleOrList = () => {
function parseTupleOrList() {
value = value.trim();
if (value[0] !== '{') {
return undefined;
Expand Down Expand Up @@ -151,7 +146,7 @@ export function expandValue(variableCreate: (value: string | object, opts?: { ar
return undefined;
};

const parsePrimitive = () => {
function parsePrimitive() {
let primitive: any;
let match;
value = value.trim();
Expand Down Expand Up @@ -191,7 +186,7 @@ export function expandValue(variableCreate: (value: string | object, opts?: { ar
return primitive;
};

parseValue = () => {
function parseValue() {
value = value.trim();
if (value[0] === '"') {
return parseCString();
Expand All @@ -202,7 +197,7 @@ export function expandValue(variableCreate: (value: string | object, opts?: { ar
}
};

parseResult = (pushToStack: boolean = false) => {
function parseResult(pushToStack: boolean = false) {
value = value.trim();
const variableMatch = resultRegex.exec(value);
if (!variableMatch) {
Expand All @@ -220,7 +215,7 @@ export function expandValue(variableCreate: (value: string | object, opts?: { ar
return createValue(name, val);
};

createValue = (name, val) => {
function createValue(name, val) {
let ref = 0;
if (typeof val === 'object') {
ref = variableCreate(val);
Expand All @@ -246,7 +241,7 @@ export function expandValue(variableCreate: (value: string | object, opts?: { ar
};
};

parseCommaValue = () => {
function parseCommaValue() {
value = value.trim();
if (value[0] !== ',') {
return undefined;
Expand All @@ -255,7 +250,7 @@ export function expandValue(variableCreate: (value: string | object, opts?: { ar
return parseValue();
};

parseCommaResult = (pushToStack: boolean = false) => {
function parseCommaResult(pushToStack: boolean = false) {
value = value.trim();
if (value[0] !== ',') {
return undefined;
Expand Down
15 changes: 5 additions & 10 deletions src/backend/mi_parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,7 @@ export function parseMI(output: string): MINode {
return str;
};

let parseValue;
let parseCommaResult;
let parseCommaValue;
let parseResult;

const parseTupleOrList = () => {
function parseTupleOrList() {
if (output[0] !== '{' && output[0] !== '[') {
return undefined;
}
Expand Down Expand Up @@ -249,7 +244,7 @@ export function parseMI(output: string): MINode {
return undefined;
};

parseValue = () => {
function parseValue() {
if (output[0] === '"') {
return parseCString();
} else if (output[0] === '{' || output[0] === '[') {
Expand All @@ -259,7 +254,7 @@ export function parseMI(output: string): MINode {
}
};

parseResult = () => {
function parseResult() {
const variableMatch = variableRegex.exec(output);
if (!variableMatch) {
return undefined;
Expand All @@ -269,15 +264,15 @@ export function parseMI(output: string): MINode {
return [variable, parseValue()];
};

parseCommaValue = () => {
function parseCommaValue() {
if (output[0] !== ',') {
return undefined;
}
output = output.substr(1);
return parseValue();
};

parseCommaResult = () => {
function parseCommaResult() {
if (output[0] !== ',') {
return undefined;
}
Expand Down
3 changes: 1 addition & 2 deletions src/live-watch-monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ export class VariablesHandler {
session.sendResponse(response);
return;
}
let id: number | string | VariableObject | ExtendedVariable;
id = this.variableHandles.get(args.variablesReference);
const id = this.variableHandles.get(args.variablesReference);
if (typeof id === 'object') {
if (id instanceof VariableObject) {
const pVar = id;
Expand Down
2 changes: 1 addition & 1 deletion src/remote/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class CortexDebugRemote {
constructor(public context: vscode.ExtensionContext) {
console.log('in CortexDebugRemote::constructor');
vscode.window.showInformationMessage('cortex-debug-remote activated!');
let disposable = vscode.commands.registerCommand('cortex-debug-remote.helloWorld', this.hello.bind(this));
const disposable = vscode.commands.registerCommand('cortex-debug-remote.helloWorld', this.hello.bind(this));

context.subscriptions.push(disposable);
this.server = new Server(context);
Expand Down
2 changes: 1 addition & 1 deletion src/remote/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Client {
new rpc.StreamMessageWriter(this.socket, 'utf-8')
);

let notification = new rpc.NotificationType<Interfaces.eventArgs>('event');
const notification = new rpc.NotificationType<Interfaces.eventArgs>('event');
this.connection.onNotification(notification, (param: Interfaces.eventArgs) => {
console.log(param);
});
Expand Down

0 comments on commit d855332

Please sign in to comment.