Skip to content

Commit

Permalink
Merge pull request #2887 from kbase/DATAUP-737_misc_fixes
Browse files Browse the repository at this point in the history
DATAUP-737: more Deepscan fixes for global variables and function params
  • Loading branch information
ialarmedalien authored Apr 14, 2022
2 parents b393ee6 + a28d67a commit 97f8fa6
Show file tree
Hide file tree
Showing 62 changed files with 368 additions and 919 deletions.
6 changes: 3 additions & 3 deletions kbase-extension/static/kbase/js/common/iframe/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ define(['bluebird', 'uuid'], (Promise, Uuid) => {

let lastId = 0; //: number;
const partners = {}; // Object<String, any>;
const listeners = {}; //Object<String, Array<any>>;
const awaitingResponse = {}; //: Object<String, any>;
const listeners = {}; // Object<String, Array<any>>;
const awaitingResponse = {}; // Object<String, any>;

function genId() {
lastId += 1;
Expand All @@ -30,7 +30,7 @@ define(['bluebird', 'uuid'], (Promise, Uuid) => {
const message = event.data;
let response;

if (!message.address && !message.address.to) {
if (!message.address || !message.address.to) {
console.warn('Message without address.to - ignored (iframe)', message);
return;
}
Expand Down
16 changes: 5 additions & 11 deletions kbase-extension/static/kbase/js/common/parameterSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ define([], () => {
}

function isAdvanced() {
if (spec.advanced === 1) {
return true;
}
return false;
return spec.advanced === 1;
}

function dataType() {
Expand Down Expand Up @@ -150,7 +147,7 @@ define([], () => {
case 'float':
return parseFloat(_defaultValue);
case 'boolean':
return coerceToBoolean(_defaultValue);
return !!_defaultValue;
case 'string':
case 'workspaceObjectName':
default:
Expand All @@ -177,7 +174,7 @@ define([], () => {
if (typeof value !== 'string') {
return 0;
}
switch (value.toLowerCase(value)) {
switch (value.toLowerCase()) {
case 'true':
case 't':
case 'yes':
Expand Down Expand Up @@ -237,13 +234,10 @@ define([], () => {
if (value === undefined || value === null) {
return true;
}
if (
return !!(
(dataType() === 'string' || dataType() === 'workspaceObjectName') &&
value.length === 0
) {
return true;
}
return false;
);
}

function uiClass() {
Expand Down
27 changes: 8 additions & 19 deletions kbase-extension/static/kbase/js/common/sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ define(['common/props'], (Props) => {
if (typeof value !== 'string') {
return false;
}
switch (value.toLowerCase(value)) {
switch (value.toLowerCase()) {
case 'true':
case 't':
case 'yes':
Expand All @@ -39,7 +39,7 @@ define(['common/props'], (Props) => {
if (converted.multipleItems) {
return [];
}
const nullValue = (function () {
return (function () {
switch (converted.data.type) {
case 'string':
return '';
Expand All @@ -59,7 +59,6 @@ define(['common/props'], (Props) => {
return null;
}
})();
return nullValue;
}

function updateNullValue(converted) {
Expand Down Expand Up @@ -578,7 +577,7 @@ define(['common/props'], (Props) => {
if (spec.allow_multiple) {
// except, ahem, for the custom_subdata, at least for now...
if (spec.field_type === 'custom_textsubdata') {
spec.allow_multiple === 0;
spec.allow_multiple = 0;
spec.textsubdata_options = {
multiselection: 1,
};
Expand Down Expand Up @@ -633,17 +632,14 @@ define(['common/props'], (Props) => {
});
const required = group.optional ? false : true;

let defaultValue;
let nullValue;

nullValue = null;
defaultValue = {};
const nullValue = null;
const defaultValue = {};
Object.keys(groupParams).forEach((id) => {
defaultValue[id] = groupParams[id].data.defaultValue;
});
const zeroValue = defaultValue;

const structSpec = {
return {
id: group.id,
multipleItems: false,
ui: {
Expand All @@ -669,7 +665,6 @@ define(['common/props'], (Props) => {
specs: groupParams,
},
};
return structSpec;
}

// just differs from the makeParameterSequence in that the
Expand Down Expand Up @@ -770,10 +765,7 @@ define(['common/props'], (Props) => {
// and then add the groups in.
const parameterLayout = sdkAppSpec.parameters
.filter((parameter) => {
if (parameterSpecs[parameter.id]) {
return true;
}
return false;
return !!parameterSpecs[parameter.id];
})
.map((parameter) => {
return {
Expand All @@ -786,10 +778,7 @@ define(['common/props'], (Props) => {
// first filter out any groups which were not added to the parameters.
// This includes ones with no parameters specified
.filter((group) => {
if (parameterSpecs[group.id]) {
return true;
}
return false;
return !!parameterSpecs[group.id];
})
.map((group) => {
return {
Expand Down
2 changes: 1 addition & 1 deletion kbase-extension/static/kbase/js/common/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ define([
fontSize = jsonBlockWidgetConfig.fontSize || 0.8;

function render(obj) {
const specText = JSON.stringify(obj, false, indent),
const specText = JSON.stringify(obj, null, indent),
fixedText = specText.replace(/</g, '&lt;').replace(/>/g, '&gt;');
return pre(
{
Expand Down
Loading

0 comments on commit 97f8fa6

Please sign in to comment.