bare-script 3.7.5 → 3.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/include/diff.bare +1 -1
- package/lib/include/unittest.bare +1 -1
- package/lib/model.js +5 -4
- package/package.json +1 -1
package/lib/include/diff.bare
CHANGED
|
@@ -393,7 +393,7 @@ endfunction
|
|
|
393
393
|
|
|
394
394
|
function unittestReportScriptLines(codeLineElements, lines, color, noNewline):
|
|
395
395
|
if lines:
|
|
396
|
-
linesStr = arrayJoin(lines,
|
|
396
|
+
linesStr = arrayJoin(lines, '\n') + if(noNewline, '', '\n')
|
|
397
397
|
if !color:
|
|
398
398
|
arrayPush(codeLineElements, {'text': linesStr})
|
|
399
399
|
else:
|
package/lib/model.js
CHANGED
|
@@ -361,7 +361,8 @@ export function lintScript(script) {
|
|
|
361
361
|
const fnVarAssigns = {};
|
|
362
362
|
const fnVarUses = {};
|
|
363
363
|
const args = (statement.function.args ?? null);
|
|
364
|
-
|
|
364
|
+
const fnStatements = statement.function.statements;
|
|
365
|
+
getVariableAssignmentsAndUses(fnStatements, fnVarAssigns, fnVarUses);
|
|
365
366
|
for (const varName of Object.keys(fnVarAssigns)) {
|
|
366
367
|
// Ignore re-assigned function arguments
|
|
367
368
|
if (args !== null && args.indexOf(varName) !== -1) {
|
|
@@ -369,7 +370,7 @@ export function lintScript(script) {
|
|
|
369
370
|
}
|
|
370
371
|
if (varName in fnVarUses && fnVarUses[varName] <= fnVarAssigns[varName]) {
|
|
371
372
|
lintScriptWarning(
|
|
372
|
-
warnings, script,
|
|
373
|
+
warnings, script, fnStatements[fnVarUses[varName]],
|
|
373
374
|
`Variable "${varName}" of function "${statement.function.name}" used before assignment`
|
|
374
375
|
);
|
|
375
376
|
}
|
|
@@ -379,7 +380,7 @@ export function lintScript(script) {
|
|
|
379
380
|
for (const varName of Object.keys(fnVarAssigns)) {
|
|
380
381
|
if (!(varName in fnVarUses)) {
|
|
381
382
|
lintScriptWarning(
|
|
382
|
-
warnings, script,
|
|
383
|
+
warnings, script, fnStatements[fnVarAssigns[varName]],
|
|
383
384
|
`Unused variable "${varName}" defined in function "${statement.function.name}"`
|
|
384
385
|
);
|
|
385
386
|
}
|
|
@@ -410,7 +411,7 @@ export function lintScript(script) {
|
|
|
410
411
|
// Iterate function statements
|
|
411
412
|
const fnLabelsDefined = {};
|
|
412
413
|
const fnLabelsUsed = {};
|
|
413
|
-
for (const [ixFnStatement, fnStatement] of
|
|
414
|
+
for (const [ixFnStatement, fnStatement] of fnStatements.entries()) {
|
|
414
415
|
const [fnStatementKey] = Object.keys(fnStatement);
|
|
415
416
|
|
|
416
417
|
// Function expression statement checks
|