diff --git a/apps/remix-ide-e2e/src/tests/staticAnalysis.test.ts b/apps/remix-ide-e2e/src/tests/staticAnalysis.test.ts index 504148b266..2a2b39b523 100644 --- a/apps/remix-ide-e2e/src/tests/staticAnalysis.test.ts +++ b/apps/remix-ide-e2e/src/tests/staticAnalysis.test.ts @@ -30,6 +30,27 @@ module.exports = { }, 'Static Analysis': function (browser: NightwatchBrowser) { runTests(browser) + }, + 'run analysis and filter results': function (browser: NightwatchBrowser) { + browser + .clickLaunchIcon('filePanel') + .click('*[data-id="treeViewLitreeViewItemcontracts"]') + .click('*[data-id="treeViewLitreeViewItemcontracts/2_Owner.sol"]') + .clickLaunchIcon('solidity') + .pause(10000) + .clickLaunchIcon('solidityStaticAnalysis') + .waitForElementPresent('#staticanalysisresult .warning', 5000) + .assert.containsText('#verticalIconsKindsolidityStaticAnalysis .remixui_status', '1') // Check warning count + .verify.elementPresent('input[name="showLibWarnings"]') + .verify.elementNotPresent('input[name="showLibWarnings"]:checked') + .verify.elementPresent('label[id="headingshowLibWarnings"]') + .click('label[id="headingshowLibWarnings"]') + .pause(1000) + .assert.containsText('#verticalIconsKindsolidityStaticAnalysis .remixui_status', '382') + .click('label[id="headingshowLibWarnings"]') + .pause(1000) + .assert.containsText('#verticalIconsKindsolidityStaticAnalysis .remixui_status', '1') + .end() } } @@ -47,14 +68,12 @@ function runTests (browser: NightwatchBrowser) { 'TooMuchGas.() : Variables have very similar names "test" and "test1".', 'TooMuchGas.() : Variables have very similar names "test" and "test1".'], '#staticanalysisresult .warning', - browser, function () { - browser.end() - } + browser ) }) } -function listSelectorContains (textsToFind: string[], selector: string, browser: NightwatchBrowser, callback: VoidFunction) { +function listSelectorContains (textsToFind: string[], selector: string, browser: NightwatchBrowser) { browser.execute(function (selector) { const items = document.querySelectorAll(selector) const ret = [] @@ -68,6 +87,5 @@ function listSelectorContains (textsToFind: string[], selector: string, browser: console.log('testing `' + result.value[k] + '` against `' + textsToFind[k] + '`') browser.assert.equal(result.value[k].indexOf(textsToFind[k]) !== -1, true) } - callback() }) } diff --git a/libs/remix-analyzer/src/solidity-analyzer/index.ts b/libs/remix-analyzer/src/solidity-analyzer/index.ts index da6b5bb35e..d2c45ff635 100644 --- a/libs/remix-analyzer/src/solidity-analyzer/index.ts +++ b/libs/remix-analyzer/src/solidity-analyzer/index.ts @@ -15,13 +15,13 @@ export default class staticAnalysisRunner { * @param toRun module indexes (compiled from remix IDE) * @param callback callback */ - run (compilationResult: CompilationResult, toRun: number[], callback: ((reports: AnalysisReport[]) => void)): void { + run (compilationResult: CompilationResult, toRun: number[]): AnalysisReport[] { const modules: ModuleObj[] = toRun.map((i) => { const Module = this.modules()[i] const m = new Module() return { name: m.name, mod: m } }) - this.runWithModuleList(compilationResult, modules, callback) + return this.runWithModuleList(compilationResult, modules) } /** @@ -30,7 +30,7 @@ export default class staticAnalysisRunner { * @param modules analysis module * @param callback callback */ - runWithModuleList (compilationResult: CompilationResult, modules: ModuleObj[], callback: ((reports: AnalysisReport[]) => void)): void { + runWithModuleList (compilationResult: CompilationResult, modules: ModuleObj[]): AnalysisReport[] { let reports: AnalysisReport[] = [] // Also provide convenience analysis via the AST walker. const walker = new AstWalker() @@ -64,7 +64,7 @@ export default class staticAnalysisRunner { } return { name: item.name, report: report } })) - callback(reports) + return reports } /** diff --git a/libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.4.24.ts b/libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.4.24.ts index 67607d7a35..8052a1870a 100644 --- a/libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.4.24.ts +++ b/libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.4.24.ts @@ -814,12 +814,11 @@ test('Integration test forLoopIteratesOverDynamicArray module', function (t: tes function runModuleOnFiles (Module: any, t: test.Test, cb: ((fname: string, report: AnalysisReportObj[]) => void)): void { const statRunner: StatRunner = new StatRunner() testFiles.forEach((fileName: string) => { - statRunner.runWithModuleList(compilationResults[fileName], [{ name: new Module().name, mod: new Module() }], (reports: AnalysisReport[]) => { - let report: AnalysisReportObj[] = reports[0].report - if (report.some((x: AnalysisReportObj) => x.warning.includes('INTERNAL ERROR'))) { - t.comment('Error while executing Module: ' + JSON.stringify(report)) - } - cb(fileName, report) - }) + const reports = statRunner.runWithModuleList(compilationResults[fileName], [{ name: new Module().name, mod: new Module() }]) + let report: AnalysisReportObj[] = reports[0].report + if (report.some((x: AnalysisReportObj) => x.warning.includes('INTERNAL ERROR'))) { + t.comment('Error while executing Module: ' + JSON.stringify(report)) + } + cb(fileName, report) }) } diff --git a/libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.5.0.ts b/libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.5.0.ts index 780cfa2b63..aa14866a69 100644 --- a/libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.5.0.ts +++ b/libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.5.0.ts @@ -816,12 +816,11 @@ test('Integration test forLoopIteratesOverDynamicArray module', function (t: tes function runModuleOnFiles (Module: any, t: test.Test, cb: ((fname: string, report: AnalysisReportObj[]) => void)): void { const statRunner: StatRunner = new StatRunner() testFiles.forEach((fileName: string) => { - statRunner.runWithModuleList(compilationResults[fileName], [{ name: new Module().name, mod: new Module() }], (reports: AnalysisReport[]) => { - let report: AnalysisReportObj[] = reports[0].report - if (report.some((x: AnalysisReportObj) => x['warning'].includes('INTERNAL ERROR'))) { - t.comment('Error while executing Module: ' + JSON.stringify(report)) - } - cb(fileName, report) - }) + const reports = statRunner.runWithModuleList(compilationResults[fileName], [{ name: new Module().name, mod: new Module() }]) + let report: AnalysisReportObj[] = reports[0].report + if (report.some((x: AnalysisReportObj) => x['warning'].includes('INTERNAL ERROR'))) { + t.comment('Error while executing Module: ' + JSON.stringify(report)) + } + cb(fileName, report) }) } diff --git a/libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.4.24.ts b/libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.4.24.ts index de6303ef89..2a6091dc32 100644 --- a/libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.4.24.ts +++ b/libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.4.24.ts @@ -31,10 +31,9 @@ test('staticAnalysisIssues.functionParameterPassingError', function (t) { const statRunner: StatRunner = new StatRunner() t.doesNotThrow(() => { - statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports: AnalysisReport[]) => {}) + statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module()}]) }, 'Analysis should not throw') - statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports: AnalysisReport[]) => { - t.ok(!reports.some((mod: AnalysisReport) => mod.report.some((rep: AnalysisReportObj) => rep.warning.includes('INTERNAL ERROR')), 'Should not have internal errors')) - }) + const reports = statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module()}]) + t.ok(!reports.some((mod: AnalysisReport) => mod.report.some((rep: AnalysisReportObj) => rep.warning.includes('INTERNAL ERROR')), 'Should not have internal errors')) }) diff --git a/libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.5.0.ts b/libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.5.0.ts index beac78be6d..43234e4168 100644 --- a/libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.5.0.ts +++ b/libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.5.0.ts @@ -31,10 +31,9 @@ test('staticAnalysisIssues.functionParameterPassingError', function (t) { const statRunner: StatRunner = new StatRunner() t.doesNotThrow(() => { - statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports: AnalysisReport[]) => {}) + statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }]) }, 'Analysis should not throw') - statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports: AnalysisReport[]) => { - t.ok(!reports.some((mod: AnalysisReport) => mod.report.some((rep: AnalysisReportObj) => rep.warning.includes('INTERNAL ERROR')), 'Should not have internal errors')) - }) + const reports = statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }]) + t.ok(!reports.some((mod: AnalysisReport) => mod.report.some((rep: AnalysisReportObj) => rep.warning.includes('INTERNAL ERROR')), 'Should not have internal errors')) }) diff --git a/libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.tsx b/libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.tsx index 95913e533b..4b0d4fa9be 100644 --- a/libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.tsx +++ b/libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.tsx @@ -12,6 +12,7 @@ export interface RemixUiCheckboxProps { id?: string itemName?: string categoryId?: string + title?: string visibility?: string display?: string } @@ -26,11 +27,12 @@ export const RemixUiCheckbox = ({ onChange, itemName, categoryId, + title, visibility, display = 'flex' }: RemixUiCheckboxProps) => { return ( -