Skip to content

Commit

Permalink
npm run lint to get const fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin authored and mattgodbolt committed Jan 24, 2023
1 parent 2a42cc4 commit 00b535b
Show file tree
Hide file tree
Showing 25 changed files with 71 additions and 71 deletions.
2 changes: 1 addition & 1 deletion lib/aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ let awsConfig = {};
let awsProps = null;

async function loadAwsConfig(properties) {
let region = properties('region');
const region = properties('region');
if (!region) return {};
const ssm = new AWS.SSM({region: region});
const path = '/compiler-explorer/';
Expand Down
2 changes: 1 addition & 1 deletion lib/cfg.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function getAsmDirective(txt) {
function filterTextSection(data) {
let useCurrentSection = true;
const result = [];
for (let i in data) {
for (const i in data) {
const x = data[i];
const directive = getAsmDirective(x.text);
if (directive != null) {
Expand Down
20 changes: 10 additions & 10 deletions lib/clientstate-normalizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ export class ClientStateGoldenifier extends GoldenLayoutComponents {
},
];

let stack = gl.content[0].content[0].content[1].content[0];
const stack = gl.content[0].content[0].content[1].content[0];

for (let idxCompiler = 0; idxCompiler < tree.compilers.length; idxCompiler++) {
const compiler = tree.compilers[idxCompiler];
Expand Down Expand Up @@ -936,7 +936,7 @@ export class ClientStateGoldenifier extends GoldenLayoutComponents {
],
};

let stack = this.newSourceStackFromSession(session, 100);
const stack = this.newSourceStackFromSession(session, 100);
this.golden.content[0].content[idxSession].content[0].content.push(stack);

const compilerWidth =
Expand All @@ -953,11 +953,11 @@ export class ClientStateGoldenifier extends GoldenLayoutComponents {

for (let idxCompiler = 0; idxCompiler < session.compilers.length; idxCompiler++) {
const compiler = session.compilers[idxCompiler];
let stack = this.newCompilerStackFromSession(session, compiler, compilerWidth);
const stack = this.newCompilerStackFromSession(session, compiler, compilerWidth);
this.golden.content[0].content[idxSession].content[1].content.push(stack);

for (const viewtype of compiler.specialoutputs) {
let stack = this.newStackWithOneComponent(
const stack = this.newStackWithOneComponent(
compilerWidth,
this.createSpecialOutputComponent(viewtype, session, idxCompiler),
);
Expand All @@ -968,7 +968,7 @@ export class ClientStateGoldenifier extends GoldenLayoutComponents {
}

for (const tool of compiler.tools) {
let stack = this.newToolStackFromCompiler(
const stack = this.newToolStackFromCompiler(
session,
idxCompiler + 1,
tool.id,
Expand All @@ -982,7 +982,7 @@ export class ClientStateGoldenifier extends GoldenLayoutComponents {

for (let idxExecutor = 0; idxExecutor < session.executors.length; idxExecutor++) {
const executor = session.executors[idxExecutor];
let stack = this.newExecutorStackFromSession(session, executor, compilerWidth);
const stack = this.newExecutorStackFromSession(session, executor, compilerWidth);
this.golden.content[0].content[idxSession].content[1].content.push(stack);
}
}
Expand All @@ -1008,11 +1008,11 @@ export class ClientStateGoldenifier extends GoldenLayoutComponents {

for (let idxCompiler = 0; idxCompiler < session.compilers.length; idxCompiler++) {
const compiler = session.compilers[idxCompiler];
let stack = this.newCompilerStackFromSession(session, compiler, width);
const stack = this.newCompilerStackFromSession(session, compiler, width);
this.golden.content[0].content.push(stack);

for (const viewtype of compiler.specialoutputs) {
let stack = this.newStackWithOneComponent(
const stack = this.newStackWithOneComponent(
width,
this.createSpecialOutputComponent(viewtype, session, idxCompiler),
);
Expand All @@ -1023,7 +1023,7 @@ export class ClientStateGoldenifier extends GoldenLayoutComponents {
}

for (const tool of compiler.tools) {
let stack = this.newToolStackFromCompiler(
const stack = this.newToolStackFromCompiler(
session,
compiler,
idxCompiler + 1,
Expand All @@ -1037,7 +1037,7 @@ export class ClientStateGoldenifier extends GoldenLayoutComponents {
}

for (const executor of session.executors) {
let stack = this.newExecutorStackFromSession(session, executor, width);
const stack = this.newExecutorStackFromSession(session, executor, width);
this.golden.content[0].content.push(stack);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/clientstate.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class ClientStateTree {

findOrCreateCompiler(id) {
let foundCompiler;
for (let compiler of this.compilers) {
for (const compiler of this.compilers) {
if (compiler._internalid === id) {
foundCompiler = compiler;
}
Expand Down Expand Up @@ -297,7 +297,7 @@ export class ClientStateSession {

findOrCreateCompiler(id) {
let foundCompiler;
for (let compiler of this.compilers) {
for (const compiler of this.compilers) {
if (compiler._internalid === id) {
foundCompiler = compiler;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/compilers/java.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export class JavaCompiler extends BaseCompiler {
}
}

let lineRegex = /line\s*(\d+):\s*(\d+)/g;
const lineRegex = /line\s*(\d+):\s*(\d+)/g;
let m;
let currentInstr = 0;
let currentSourceLine = -1;
Expand Down
2 changes: 1 addition & 1 deletion lib/compilers/mrustc.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class MrustcCompiler extends BaseCompiler {
// In our case, the actual file in -o is not even created because we are
// faking the last step (C compilation).
// Craft the 'outname' to have the intermediate .c file writen in outputFilename.
let outname = path.join(
const outname = path.join(
path.dirname(this.filename(outputFilename)),
path.basename(this.filename(outputFilename), '.c'),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/compilers/pascal-win.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class PascalWinCompiler extends BaseCompiler {
execOptions = this.getDefaultExecOptions();
}

let alreadyHasDPR = path.basename(inputFilename) === this.dprFilename;
const alreadyHasDPR = path.basename(inputFilename) === this.dprFilename;

const tempPath = path.dirname(inputFilename);
const projectFile = path.join(tempPath, this.dprFilename);
Expand Down
6 changes: 3 additions & 3 deletions lib/compilers/pascal.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class FPCCompiler extends BaseCompiler {
execOptions = this.getDefaultExecOptions();
}

let alreadyHasDPR = path.basename(inputFilename) === this.dprFilename;
const alreadyHasDPR = path.basename(inputFilename) === this.dprFilename;
const dirPath = path.dirname(inputFilename);

const projectFile = path.join(dirPath, this.dprFilename);
Expand Down Expand Up @@ -257,11 +257,11 @@ export class FPCCompiler extends BaseCompiler {

preProcessLines(asmLines) {
let i = 0;
let files = {};
const files = {};
let currentFileId = 1;

while (i < asmLines.length) {
let newFileId = this.tryGetFilenumber(asmLines[i], files);
const newFileId = this.tryGetFilenumber(asmLines[i], files);
if (newFileId) currentFileId = newFileId;

const extraHint = this.getExtraAsmHint(asmLines[i], currentFileId);
Expand Down
2 changes: 1 addition & 1 deletion lib/compilers/ppci.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class PPCICompiler extends BaseCompiler {
const pythonPath = matches[1];
const ppciName = `ppci.${matches[3].replace('/', '.')}`;
options.env = {PYTHONPATH: pythonPath};
let python_args = ['-m', ppciName].concat(args);
const python_args = ['-m', ppciName].concat(args);
return exec.execute(python, python_args, options);
}
logger.error(`Invalid ppci path ${compiler}`);
Expand Down
2 changes: 1 addition & 1 deletion lib/compilers/ptxas.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class PtxAssembler extends BaseCompiler {

async objdump(outputFilename, result, maxSize) {
const dirPath = path.dirname(outputFilename);
let args = ['-c', '-g', '-hex', outputFilename];
const args = ['-c', '-g', '-hex', outputFilename];
const objResult = await this.exec(this.compiler.objdumper, args, {maxOutput: maxSize, customCwd: dirPath});
result.asm = objResult.stdout;
if (objResult.code === 0) {
Expand Down
4 changes: 2 additions & 2 deletions lib/compilers/rustc-cg-gcc.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class RustcCgGCCCompiler extends RustCompiler {
optionsForFilter(filters, outputFilename, userOptions) {
// these options are direcly taken from rustc_codegen_gcc doc.
// See https://github.com/antoyo/rustc_codegen_gcc
let toolroot = path.resolve(path.dirname(this.compiler.exe), '..');
const toolroot = path.resolve(path.dirname(this.compiler.exe), '..');

let options = [
'-C',
Expand All @@ -67,7 +67,7 @@ export class RustcCgGCCCompiler extends RustCompiler {

// rust.js makes the asumption that LLVM is used. This may go away when cranelift is available.
// Until this is the case and the super() class is refactored, simply ditch -Cllvm arg.
let super_options = super
const super_options = super
.optionsForFilter(filters, outputFilename, userOptions)
.filter(arg => !/-Cllvm.*/.test(arg));
options = options.concat(super_options);
Expand Down
4 changes: 2 additions & 2 deletions lib/compilers/solidity.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class SolidityCompiler extends BaseCompiler {
// and reverting if a multiplication results in
// integer overflow, etc.
const processGeneratedSources = generatedSourcesData => {
let generatedSources = {};
const generatedSources = {};
for (const generatedSource of generatedSourcesData) {
generatedSources[generatedSource.id] = generatedSource.ast.statements.map(statement => {
const [begin, length] = statement.src.split(':').map(x => parseInt(x));
Expand Down Expand Up @@ -202,7 +202,7 @@ export class SolidityCompiler extends BaseCompiler {
// first iterate the opcodes to find all the tags,
// and assign human-readable names to as many of
// them as we can
let tagNames = {};
const tagNames = {};
const processPossibleTagOpcode = (opcode, funcList) => {
if (opcode.name === 'tag') {
const func = funcList.find(func => {
Expand Down
2 changes: 1 addition & 1 deletion lib/compilers/win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class Win32Compiler extends BaseCompiler {
}

exec(compiler, args, options_) {
let options = Object.assign({}, options_);
const options = Object.assign({}, options_);
options.env = Object.assign({}, options.env);

if (this.compiler.includePath) {
Expand Down
2 changes: 1 addition & 1 deletion lib/compilers/wsl-vc.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class WslVcCompiler extends Win32VcCompiler {
}

exec(compiler, args, options_) {
let options = Object.assign({}, options_);
const options = Object.assign({}, options_);
options.env = Object.assign({}, options.env);

let old_env = options.env['WSLENV'];
Expand Down
6 changes: 3 additions & 3 deletions lib/handlers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ export class ApiHandler {

handleLanguages(req, res) {
const availableLanguages = this.usedLangIds.map(val => {
let lang = this.languages[val];
let newLangObj = Object.assign({}, lang);
const lang = this.languages[val];
const newLangObj = Object.assign({}, lang);
if (this.options) {
newLangObj.defaultCompiler = this.options.options.defaultCompiler[lang.id];
}
Expand Down Expand Up @@ -218,7 +218,7 @@ export class ApiHandler {
return Object.keys(libsForLanguageObj).map(key => {
const language = libsForLanguageObj[key];
const versionArr = Object.keys(language.versions).map(key => {
let versionObj = Object.assign({}, language.versions[key]);
const versionObj = Object.assign({}, language.versions[key]);
versionObj.id = key;
return versionObj;
});
Expand Down
8 changes: 4 additions & 4 deletions lib/parsers/asm-parser-ewavr.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class AsmEWAVRParser extends AsmParser {
}
};

let asmLines = utils.splitLines(asm);
const asmLines = utils.splitLines(asm);

const stdInLooking = /<stdin>|^-$|example\.[^/]+$|<source>/;

Expand All @@ -106,7 +106,7 @@ export class AsmEWAVRParser extends AsmParser {
// ; initialLine: int
// ; file: string option
// ; require: string array }
let resultObject = {
const resultObject = {
prefix: [], // line array
labels: [], // label array
postfix: [], // line array
Expand Down Expand Up @@ -257,9 +257,9 @@ export class AsmEWAVRParser extends AsmParser {
const compilerGeneratedLabel = /^(initializer for |segment init: )([\w :]*)$/i;
const segInitLabel = /^segment init: ([\w :]*)$/i;

let result = [];
const result = [];
let lastLineWasWhitespace = true;
let pushLine = line => {
const pushLine = line => {
if (line.text.trim() === '') {
if (!lastLineWasWhitespace) {
result.push({text: '', source: null});
Expand Down
6 changes: 3 additions & 3 deletions lib/parsers/asm-parser-vc.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class VcAsmParser extends AsmParser {
// ; name: string | undefined
// ; initialLine: int
// ; file: string option | undefined }
let resultObject = {
const resultObject = {
prefix: [], // line array
functions: [], // func array
postfix: null, // line?
Expand Down Expand Up @@ -306,9 +306,9 @@ export class VcAsmParser extends AsmParser {
return collator.compare(f1.file, f2.file);
});

let result = [];
const result = [];
let lastLineWasWhitespace = true;
let pushLine = line => {
const pushLine = line => {
if (line.text.trim() === '') {
if (!lastLineWasWhitespace) {
result.push({text: '', source: null});
Expand Down
6 changes: 3 additions & 3 deletions lib/parsers/asm-parser-vc6.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class Vc6AsmParser extends AsmParser {
// ; name: string | undefined
// ; initialLine: int
// ; file: string option | undefined }
let resultObject = {
const resultObject = {
prefix: [], // line array
functions: [], // func array
postfix: null, // line?
Expand Down Expand Up @@ -308,9 +308,9 @@ export class Vc6AsmParser extends AsmParser {
return collator.compare(f1.file, f2.file);
});

let result = [];
const result = [];
let lastLineWasWhitespace = true;
let pushLine = line => {
const pushLine = line => {
if (line.text.trim() === '') {
if (!lastLineWasWhitespace) {
result.push({text: '', source: null});
Expand Down
4 changes: 2 additions & 2 deletions lib/parsers/asm-parser-z88dk.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class AsmParserZ88dk extends AsmParser {

let asmLines = asmResult.split('\n');
const startingLineCount = asmLines.length;
let source = null;
const source = null;

// Handle "error" documents.
if (asmLines.length === 1 && asmLines[0][0] === '<') {
Expand All @@ -42,7 +42,7 @@ export class AsmParserZ88dk extends AsmParser {
continue;
}

let match = line.match(this.asmOpcodeRe);
const match = line.match(this.asmOpcodeRe);
if (match) {
const address = parseInt(match.groups.address, 16);
const opcodes = (match.groups.opcodes || '').split(' ').filter(x => !!x);
Expand Down
4 changes: 2 additions & 2 deletions lib/parsers/asm-raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import {AsmRegex} from './asmregex';

export class AsmRaw extends AsmRegex {
processBinaryAsm(asm, filters) {
let result = [];
const result = [];
const asmLines = asm.split('\n');
const asmOpcodeRe = /^\s*([\da-f]+):\s*(([\da-f]{2} ?)+)\s*(.*)/;
const labelRe = /^([\da-f]+)\s+<([^>]+)>:$/;
const destRe = /.*\s([\da-f]+)\s+<([^>]+)>$/;
let source = null;
const source = null;

if (asmLines.length === 1 && asmLines[0][0] === '<') {
return {asm: [{text: asmLines[0], source: null}]};
Expand Down
2 changes: 1 addition & 1 deletion lib/tooling/microsoft-analysis-tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class MicrosoftAnalysisTool extends BaseTool {
}

async runCompilerTool(compilationInfo, inputFilepath, args, stdin /*, supportedLibraries*/) {
let execOptions = this.getDefaultExecOptions();
const execOptions = this.getDefaultExecOptions();
if (inputFilepath) execOptions.customCwd = path.dirname(inputFilepath);
execOptions.input = stdin;

Expand Down

0 comments on commit 00b535b

Please sign in to comment.