mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 05:53:49 -05:00
Add noUnusedLocals to tsconfig + fix the new alerts (#6396)
<!-- THIS COMMENT IS INVISIBLE IN THE FINAL PR, BUT FEEL FREE TO REMOVE IT Thanks for taking the time to improve CE. We really appreciate it. Before opening the PR, please make sure that the tests & linter pass their checks, by running `make check`. In the best case scenario, you are also adding tests to back up your changes, but don't sweat it if you don't. We can discuss them at a later date. Feel free to append your name to the CONTRIBUTORS.md file Thanks again, we really appreciate this! -->
This commit is contained in:
@@ -169,7 +169,7 @@ export class D8Compiler extends BaseCompiler implements SimpleOutputFilenameComp
|
||||
let files = await fs.readdir(dirPath);
|
||||
const dexFile = files.find(f => f.endsWith('.dex'));
|
||||
const baksmaliOptions = ['-jar', this.compiler.objdumper, 'd', `${dexFile}`, '-o', dirPath];
|
||||
const baksmaliResult = await this.exec(javaCompiler.javaRuntime, baksmaliOptions, {
|
||||
await this.exec(javaCompiler.javaRuntime, baksmaliOptions, {
|
||||
maxOutput: maxSize,
|
||||
customCwd: dirPath,
|
||||
});
|
||||
|
||||
@@ -61,7 +61,7 @@ export class SolidityEravmCompiler extends BaseCompiler {
|
||||
|
||||
const combinedJson = JSON.parse(result.asm);
|
||||
const asm: any[] = [];
|
||||
for (const [path, build] of Object.entries(combinedJson.contracts) as [string, JSON][]) {
|
||||
for (const build of Object.values(combinedJson.contracts) as JSON[]) {
|
||||
asm.push({text: build['asm']});
|
||||
}
|
||||
return {asm};
|
||||
|
||||
@@ -125,8 +125,6 @@ export class LlvmAstParser {
|
||||
// Refers to the user's source file rather than a system header
|
||||
const sourceRegex = /<source>/g;
|
||||
|
||||
const slocRegex = /<<invalid sloc>>/;
|
||||
|
||||
// <<invalid sloc>, /app/hell.hpp:5:1>
|
||||
const userSource = /<<invalid sloc>, \/app\/.*:\d+:\d+>/;
|
||||
|
||||
@@ -178,7 +176,6 @@ export class LlvmAstParser {
|
||||
} else if (userSource.test(output[i].text)) {
|
||||
continue;
|
||||
} else {
|
||||
// if (!slocRegex.test(output[i].text)) {
|
||||
mostRecentIsSource = isBlockUserSource(output, i, mostRecentIsSource);
|
||||
if (mostRecentIsSource) continue;
|
||||
}
|
||||
|
||||
@@ -114,13 +114,10 @@ export class MadsAsmParser extends AsmParser {
|
||||
const startTime = process.hrtime.bigint();
|
||||
const asm: ParsedAsmResultLine[] = [];
|
||||
const labelDefinitions: Record<string, number> = {};
|
||||
const dontMaskFilenames = filters.dontMaskFilenames;
|
||||
|
||||
let asmLines = utils.splitLines(asmResult);
|
||||
const startingLineCount = asmLines.length;
|
||||
const source: AsmResultSource | undefined | null = null;
|
||||
const func: string | null = null;
|
||||
const mayRemovePreviousLabel = true;
|
||||
|
||||
// Handle "error" documents.
|
||||
if (asmLines.length === 1 && asmLines[0][0] === '<') {
|
||||
@@ -195,7 +192,7 @@ export class MadsAsmParser extends AsmParser {
|
||||
|
||||
match = line.match(this.constAssignment);
|
||||
if (match) {
|
||||
const value = parseInt(match[1], 16);
|
||||
// const value = parseInt(match[1], 16);
|
||||
|
||||
const label = match[3];
|
||||
labelDefinitions[label] = asm.length;
|
||||
|
||||
@@ -808,7 +808,7 @@ export class AsmParser extends AsmRegex implements IAsmParser {
|
||||
const relocname = match.groups.relocname;
|
||||
const relocdata = match.groups.relocdata;
|
||||
// value/addend matched but not used yet.
|
||||
const match_value = relocdata.match(this.relocDataSymNameRe);
|
||||
// const match_value = relocdata.match(this.relocDataSymNameRe);
|
||||
asm.push({
|
||||
text: ` ${relocname} ${relocdata}`,
|
||||
address: address,
|
||||
|
||||
@@ -34,7 +34,6 @@ import {
|
||||
TypicalExecutionFunc,
|
||||
UnprocessedExecResult,
|
||||
} from '../../types/execution/execution.interfaces.js';
|
||||
import {unwrap} from '../assert.js';
|
||||
import {CompilationEnvironment} from '../compilation-env.js';
|
||||
import {executeDirect} from '../exec.js';
|
||||
import {logger} from '../logger.js';
|
||||
@@ -133,7 +132,6 @@ export class HeaptrackWrapper extends BaseRuntimeTool {
|
||||
}
|
||||
|
||||
private async interpretAndSave(execOptions: ExecutionOptions, result: UnprocessedExecResult) {
|
||||
const dirPath = unwrap(execOptions.appHome);
|
||||
execOptions.input = fs.readFileSync(this.rawOutput).toString('utf8');
|
||||
|
||||
const interpretResults = await this.interpret(execOptions);
|
||||
@@ -162,8 +160,6 @@ export class HeaptrackWrapper extends BaseRuntimeTool {
|
||||
}
|
||||
|
||||
public async exec(filepath: string, args: string[], execOptions: ExecutionOptions): Promise<UnprocessedExecResult> {
|
||||
const dirPath = unwrap(execOptions.appHome);
|
||||
|
||||
const runOptions = JSON.parse(JSON.stringify(execOptions));
|
||||
const interpretOptions = JSON.parse(JSON.stringify(execOptions));
|
||||
interpretOptions.maxOutput = 1024 * 1024 * 1024;
|
||||
|
||||
@@ -310,12 +310,6 @@ export class CompilerService {
|
||||
});
|
||||
}
|
||||
|
||||
private getFilenameFromUrl(url: string): string {
|
||||
const jsurl = new URL(url);
|
||||
const urlpath = jsurl.pathname;
|
||||
return urlpath.substring(urlpath.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
public async expandToFiles(source: string): Promise<SourceAndFiles> {
|
||||
const includesOrEmbeds = new IncludeDownloads();
|
||||
|
||||
|
||||
@@ -73,11 +73,11 @@ export class CompilerShared implements ICompilerShared {
|
||||
private initButtons(onChange: () => void) {
|
||||
this.overridesButton = this.domRoot.find('.btn.show-overrides');
|
||||
|
||||
this.overridesWidget = new CompilerOverridesWidget(this.domRoot, this.overridesButton, onChange);
|
||||
this.overridesWidget = new CompilerOverridesWidget(this.overridesButton, onChange);
|
||||
|
||||
this.runtimeToolsButton = this.domRoot.find('.btn.show-runtime-tools');
|
||||
if (this.runtimeToolsButton.length > 0) {
|
||||
this.runtimeToolsWidget = new RuntimeToolsWidget(this.domRoot, this.runtimeToolsButton, onChange);
|
||||
this.runtimeToolsWidget = new RuntimeToolsWidget(this.runtimeToolsButton, onChange);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,6 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
private readonly id: number;
|
||||
private sourceTreeId: number | null;
|
||||
private sourceEditorId: number | null;
|
||||
private originalCompilerId: string;
|
||||
private readonly infoByLang: Record<string, {compiler: string; options: string}>;
|
||||
private deferCompiles: boolean;
|
||||
private needsCompile: boolean;
|
||||
@@ -173,7 +172,6 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
private linkedFadeTimeoutId: NodeJS.Timeout | null;
|
||||
private toolsMenu: JQuery<HTMLElement> | null;
|
||||
private revealJumpStack: (monaco.editor.ICodeEditorViewState | null)[];
|
||||
private compilerPickerElement: JQuery<HTMLElement>;
|
||||
private compilerPicker: CompilerPicker;
|
||||
private compiler: CompilerInfo | null;
|
||||
private recentInstructionSet: InstructionSet | null;
|
||||
@@ -238,7 +236,6 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
private bottomBar: JQuery<HTMLElementTagNameMap[keyof HTMLElementTagNameMap]>;
|
||||
private statusLabel: JQuery<HTMLElementTagNameMap[keyof HTMLElementTagNameMap]>;
|
||||
private statusIcon: JQuery<HTMLElementTagNameMap[keyof HTMLElementTagNameMap]>;
|
||||
private monacoPlaceholder: JQuery<HTMLElementTagNameMap[keyof HTMLElementTagNameMap]>;
|
||||
private rustHirButton: JQuery<HTMLElement>;
|
||||
private libsWidget: LibsWidget | null;
|
||||
private isLabelCtxKey: monaco.editor.IContextKey<boolean>;
|
||||
@@ -363,7 +360,6 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
this.deviceViewOpen = !!state.deviceViewOpen;
|
||||
this.flagsViewOpen = state.flagsViewOpen || false;
|
||||
this.wantOptInfo = state.wantOptInfo;
|
||||
this.originalCompilerId = state.compiler;
|
||||
this.selection = state.selection;
|
||||
}
|
||||
|
||||
@@ -2539,7 +2535,6 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
this.optionsField.val(this.options);
|
||||
|
||||
this.shortCompilerName = this.domRoot.find('.short-compiler-name');
|
||||
this.compilerPickerElement = this.domRoot.find('.compiler-picker');
|
||||
this.setCompilerVersionPopover();
|
||||
|
||||
this.topBar = this.domRoot.find('.top-bar');
|
||||
@@ -2549,8 +2544,6 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
this.hideable = this.domRoot.find('.hideable');
|
||||
this.statusIcon = this.domRoot.find('.status-icon');
|
||||
|
||||
this.monacoPlaceholder = this.domRoot.find('.monaco-placeholder');
|
||||
|
||||
$(this.domRoot).on('keydown', event => {
|
||||
if ((event.ctrlKey || event.metaKey) && String.fromCharCode(event.which).toLowerCase() === 's') {
|
||||
event.preventDefault();
|
||||
@@ -3788,11 +3781,6 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private getCurrentLangCompilers(): Record<string, CompilerInfo> {
|
||||
return this.compilerService.getCompilersForLang(this.currentLangId ?? '') ?? {};
|
||||
}
|
||||
|
||||
updateCompilersSelector(info: {options?: string}) {
|
||||
if (this.compilerPicker instanceof CompilerPicker)
|
||||
this.compilerPicker.update(this.currentLangId ?? '', this.compiler?.id ?? '');
|
||||
|
||||
@@ -46,11 +46,6 @@ import {SourceAndFiles} from '../download-service.js';
|
||||
import {escapeHTML, unique} from '../../shared/common-utils.js';
|
||||
import {unwrapString} from '../assert.js';
|
||||
|
||||
type ConformanceStatus = {
|
||||
allowCompile: boolean;
|
||||
allowAdd: boolean;
|
||||
};
|
||||
|
||||
type CompilerEntry = {
|
||||
parent: JQuery<HTMLElement>;
|
||||
picker: CompilerPicker | null;
|
||||
@@ -79,7 +74,6 @@ export class Conformance extends Pane<ConformanceViewState> {
|
||||
private compilerPickers: CompilerEntry[] = [];
|
||||
private expandedSourceAndFiles: SourceAndFiles | null;
|
||||
private currentLibs: Lib[];
|
||||
private status: ConformanceStatus;
|
||||
private readonly stateByLang: Record<string, ConformanceViewState>;
|
||||
private libsButton: JQuery<HTMLElement>;
|
||||
private conformanceContentRoot: JQuery<HTMLElementTagNameMap[keyof HTMLElementTagNameMap]>;
|
||||
@@ -97,10 +91,6 @@ export class Conformance extends Pane<ConformanceViewState> {
|
||||
this.sourceNeedsExpanding = true;
|
||||
this.expandedSourceAndFiles = null;
|
||||
|
||||
this.status = {
|
||||
allowCompile: false,
|
||||
allowAdd: true,
|
||||
};
|
||||
this.stateByLang = {};
|
||||
|
||||
this.paneRenaming = new PaneRenaming(this, state);
|
||||
|
||||
@@ -57,7 +57,6 @@ export class Tree {
|
||||
private readonly hub: Hub;
|
||||
private eventHub: EventHub;
|
||||
private readonly settings: SiteSettings;
|
||||
private httpRoot: string;
|
||||
private readonly alertSystem: Alert;
|
||||
private root: JQuery;
|
||||
private rowTemplate: JQuery;
|
||||
@@ -88,9 +87,6 @@ export class Tree {
|
||||
this.hub = hub;
|
||||
this.eventHub = hub.createEventHub();
|
||||
this.settings = Settings.getStoredSettings();
|
||||
|
||||
this.httpRoot = window.httpRoot;
|
||||
|
||||
this.alertSystem = new Alert();
|
||||
this.alertSystem.prefixMessage = 'Tree #' + this.id;
|
||||
|
||||
@@ -728,12 +724,12 @@ export class Tree {
|
||||
this.sendCompileRequests();
|
||||
}, newSettings.delayAfterChange);
|
||||
}
|
||||
|
||||
private getPaneName() {
|
||||
return `Tree #${this.id}`;
|
||||
}
|
||||
|
||||
private updateTitle() {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
updateTitle() {
|
||||
const name = this.paneName ? this.paneName : this.getPaneName();
|
||||
this.container.setTitle(escapeHTML(name));
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ class ActiveState {}
|
||||
type OverrideState = IncompatibleState | InactiveState | ActiveState;
|
||||
|
||||
export class CompilerOverridesWidget {
|
||||
private domRoot: JQuery;
|
||||
private popupDomRoot: JQuery<HTMLElement>;
|
||||
private envVarsInput: JQuery<HTMLElement>;
|
||||
private dropdownButton: JQuery;
|
||||
@@ -65,8 +64,7 @@ export class CompilerOverridesWidget {
|
||||
private configured: ConfiguredOverrides = [];
|
||||
private compiler: CompilerInfo | undefined;
|
||||
|
||||
constructor(domRoot: JQuery, dropdownButton: JQuery, onChangeCallback: CompilerOverridesChangeCallback) {
|
||||
this.domRoot = domRoot;
|
||||
constructor(dropdownButton: JQuery, onChangeCallback: CompilerOverridesChangeCallback) {
|
||||
this.popupDomRoot = $('#overrides-selection');
|
||||
this.dropdownButton = dropdownButton;
|
||||
this.envVarsInput = this.popupDomRoot.find('.envvars');
|
||||
|
||||
@@ -49,7 +49,6 @@ type FavRuntimeTool = {
|
||||
type FavRuntimeTools = FavRuntimeTool[];
|
||||
|
||||
export class RuntimeToolsWidget {
|
||||
private domRoot: JQuery;
|
||||
private popupDomRoot: JQuery<HTMLElement>;
|
||||
private envVarsInput: JQuery<HTMLElement>;
|
||||
private dropdownButton: JQuery;
|
||||
@@ -58,8 +57,7 @@ export class RuntimeToolsWidget {
|
||||
private compiler: CompilerInfo | undefined;
|
||||
private possibleTools: PossibleRuntimeTools;
|
||||
|
||||
constructor(domRoot: JQuery, dropdownButton: JQuery, onChangeCallback: RuntimeToolsChangeCallback) {
|
||||
this.domRoot = domRoot;
|
||||
constructor(dropdownButton: JQuery, onChangeCallback: RuntimeToolsChangeCallback) {
|
||||
this.popupDomRoot = $('#runtimetools-selection');
|
||||
this.dropdownButton = dropdownButton;
|
||||
this.envVarsInput = this.popupDomRoot.find('.envvars');
|
||||
|
||||
@@ -107,7 +107,7 @@ describe('Basic compiler invariants', () => {
|
||||
describe('Compiler execution', () => {
|
||||
let ce: CompilationEnvironment;
|
||||
let compiler: BaseCompiler;
|
||||
let compilerNoExec: BaseCompiler;
|
||||
// let compilerNoExec: BaseCompiler;
|
||||
let win32compiler: Win32Compiler;
|
||||
|
||||
const executingCompilerInfo = makeFakeCompilerInfo({
|
||||
@@ -163,22 +163,22 @@ describe('Compiler execution', () => {
|
||||
ce = makeCompilationEnvironment({languages});
|
||||
compiler = new BaseCompiler(executingCompilerInfo, ce);
|
||||
win32compiler = new Win32Compiler(win32CompilerInfo, ce);
|
||||
compilerNoExec = new BaseCompiler(noExecuteSupportCompilerInfo, ce);
|
||||
// compilerNoExec = new BaseCompiler(noExecuteSupportCompilerInfo, ce);
|
||||
});
|
||||
|
||||
// afterEach(() => restore());
|
||||
|
||||
function stubOutCallToExec(execStub, compiler, content, result, nthCall) {
|
||||
execStub.onCall(nthCall || 0).callsFake((compiler, args) => {
|
||||
const minusO = args.indexOf('-o');
|
||||
expect(minusO).toBeGreaterThanOrEqual(0);
|
||||
const output = args[minusO + 1];
|
||||
// Maybe we should mock out the FS too; but that requires a lot more work.
|
||||
fs.writeFileSync(output, content);
|
||||
result.filenameTransform = (x: string) => x;
|
||||
return Promise.resolve(result);
|
||||
});
|
||||
}
|
||||
// function stubOutCallToExec(execStub, compiler, content, result, nthCall) {
|
||||
// execStub.onCall(nthCall || 0).callsFake((compiler, args) => {
|
||||
// const minusO = args.indexOf('-o');
|
||||
// expect(minusO).toBeGreaterThanOrEqual(0);
|
||||
// const output = args[minusO + 1];
|
||||
// // Maybe we should mock out the FS too; but that requires a lot more work.
|
||||
// fs.writeFileSync(output, content);
|
||||
// result.filenameTransform = (x: string) => x;
|
||||
// return Promise.resolve(result);
|
||||
// });
|
||||
// }
|
||||
|
||||
it('basecompiler should handle spaces in options correctly', () => {
|
||||
const userOptions = [];
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noImplicitAny": false,
|
||||
"noImplicitOverride": true
|
||||
"noImplicitOverride": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"noUnusedLocals": true,
|
||||
"noImplicitThis": true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user