-
Notifications
You must be signed in to change notification settings - Fork 55
DATAUP-737: Second set of deepscan.io fixes #2889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
| if ($field.is('input') && $field.attr('type') === 'text') { | ||
| $field.val(state[fieldName]); | ||
| } | ||
|
|
||
| // If it's a select field, do the same... we'll have comboboxen or something, | ||
| // eventually, so I'm just leaving this open for that. | ||
| else if ($field.is('select')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these do the same thing
| } | ||
| $datalist.empty(); | ||
| for (let j = 0; j < objList.length; j++) { | ||
| for (const element of objList) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sonarcloud substitution
| feature_location[i][2] === '+' | ||
| ? start + length - 1 | ||
| : start - length + 1; | ||
| for (const element of feature_location) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sonarcloud substitution
| feature_location[i][2] === '+' | ||
| ? start + length - 1 | ||
| : start - length + 1; | ||
| for (const element of feature_location) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sonarcloud substitution
|
This pull request introduces 5 alerts and fixes 105 when merging 9b77b83 into f1075d1 - view on LGTM.com new alerts:
fixed alerts:
|
Codecov Report
@@ Coverage Diff @@
## develop #2889 +/- ##
========================================
Coverage 73.24% 73.24%
========================================
Files 36 36
Lines 3899 3899
========================================
Hits 2856 2856
Misses 1043 1043 Continue to review full report at Codecov.
|
| Instantiate as follows: | ||
| var $fancy = $('some-jquery-selector').myFancyNewWidget( | ||
| const $fancy = $('some-jquery-selector').myFancyNewWidget( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a big search for var and replaced them all with let, and then ran eslint --fix, which caught some of the lets that could be changed to consts. Fixed the rest by hand.
| switch (this.validateAs) { | ||
| default: | ||
| return value; | ||
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need return and break
| let inputMapping = methodSpec['behavior']['kb_service_input_mapping']; | ||
| if (!inputMapping) { | ||
| inputMapping = methodSpec['behavior']['script_input_mapping']; | ||
| isScript = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this variable never gets used
| //// FIX: modules are tagged, rather than categorized | ||
| // deferred.resolve([pre, asms, post]); | ||
| const all = JSON.parse(mod_avail); | ||
| // const pre = [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
none of these vars were used so I commented the code out
| width = 540 - margin.left - margin.right, | ||
| height = 500 - margin.top - margin.bottom; | ||
|
|
||
| const padding = margin.left + margin.right; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused
| '<span class="kb-parameter-data-selection">' + object.id + '</span>'; | ||
| return display; | ||
| }, | ||
| formatResult: function (object, container, query) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unused variables
| let arg; | ||
| for (arg in args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
combined
| render: function (index) { | ||
| const renderer = rendererListselect[index]; | ||
|
|
||
| let button_span, result_list; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to be declared at this level as the previous code took advantage of variable hoisting
| ? 'max-height: 200px; overflow: auto;' | ||
| : 'max-height: 200px; overflow: auto;' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love me some ternaries, but this one seems a little unnecessary...
| } else { | ||
| return this.uncheckedValue; | ||
| } | ||
| return ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never reached
| 'data object names cannot be a number, in field ' + | ||
| self.spec.ui_name | ||
| ); | ||
| } else if (!/^[a-z0-9|\.|\||_\-]*$/i.test(pVal)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incorrect syntax for a character range
| version : "1.0.0", //future proofing, but completely unused | ||
| _accessors : [ //optional. A list of values to automatically create setter/getters for. | ||
| 'foo' //you'll now be able to store something at $widget.foo('newValue') and access it via var foo = $widget.foo(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally I have tried to add comments whenever there's a change that isn't var -> let/const, removing an unused argument, renaming a var that is used in the upper scope, or something else that's similarly trivial.
| return prom; | ||
| }; | ||
|
|
||
| const get_job_report_log = function (job_id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused
| _token, | ||
| _fba_url, | ||
| _ws_url, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
args unused => prefix them with _ so that linters don't complain
| tabFunctions.append(tableFunctions); | ||
| const func_data = []; | ||
| var tableSettings = { | ||
| const tableTwoSettings = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reused var name ==> change the name to something new and very original!
| const rect = stage.core_rect(obj, x, y, r_width, r_height, show_flux); | ||
| //var text = stage.text(x+r_width/2+50, y+r_height/2, obj.rxns.join('\n')) | ||
| //text.attr({'font-size':8}) | ||
| // rect = stage.core_rect(obj, x, y, r_width, r_height, show_flux); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These vars never get used so commented out (for now). Who knows what is going on in this code... maybe they will be useful to a hypothetical future code reader.
| var y3 = (xys[2][1] - 2) * grid + radius * 3; | ||
| x1 = (xys[0][0] - 2) * grid + r_width / 2; | ||
| y1 = (xys[0][1] - 2) * grid + radius * 3; | ||
| // x2 = (xys[1][0] - 2) * grid + r_width / 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x2 is not used
| container.empty(); | ||
| var data = data[0].data; | ||
| console.log(data); | ||
| const dataData = data[0].data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data already used in upper scope, so I'm calling this dataData to reflect its origins
| ); | ||
| return 1; | ||
| } | ||
| } else if (typeof params.externalProgressTarget == 'undefined') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never called
| error.statusText + | ||
| '\ | ||
| </div>'; | ||
| if (typeof uploader.callback == 'function') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uploader is not defined -- guessed it probably mean ul, which is the abbrev used elsewhere
| this.modelreactions[i]['name'] = namearray[0]; | ||
| this.modelreactions[i].dispid = idarray[0] + '[' + idarray[1] + ']'; | ||
| this.rxnhash[this.modelreactions[i].id] = this.modelreactions[i]; | ||
| for (const element of this.modelreactions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sonar cloud auto substitution
| } | ||
| for (var j = 0; j < this.modelreactions[i].stoichiometry.length; j++) { | ||
| const rgt = this.modelreactions[i].stoichiometry[j]; | ||
| for (let j = 0; j < element.stoichiometry.length; j++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately sonar cloud can't do nested for-of loops
| this._rewireIds($elem, this); | ||
|
|
||
| if (this.options.onMouseover && this.options.type == 'floating') { | ||
| const overControls = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lots of unused vars in this file
9b77b83 to
69ef736
Compare
|
This pull request introduces 4 alerts and fixes 104 when merging 69ef736 into d6ff0d5 - view on LGTM.com new alerts:
fixed alerts:
|
|
SonarCloud Quality Gate failed.
|
briehl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks pretty good to me, even tinkering with ancient code.
I'm a little nervous about sweeping changes to the data viewers - even minor structural changes - without testing or tinkering. I'd like to just have some quick data checks to make sure these still work as expected.
Also, I'm pretty sure there are several that aren't used or associated with any app. Though I'm not sure how they get used or invoked, then. I think the kbaseAssembly and kbaseModelCoreNarrative are a couple examples of that.
I think as long as we can show that they're structurally identical, though, this is probably ok to merge and break everything on CI, then apply spot fixes from there.
| ); | ||
|
|
||
| var update_asm_pool = function (assembler_pool, pool) { | ||
| const update_asm_pool = function (ass_pool, pool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You did that on purpose. 😈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possibly...








Description of PR purpose/changes
Second set of of deep scan.io fixes. The majority of these modules have many eslint errors and couldn't be used in strict mode without terrible things happening.
Because there were a lot of issues raised by deepscan, I concentrated on fixing the 'undeclared global' errors and those that could easily be fixed by search and replace. The VSCode sonar cloud plugin highlights various errors like unused variables, and allows automatic replacement of array iteration using
for (let i = 0; i < arr.length; i++)with for/of loops, so I fixed those and as many of the eslint issues as I could do without spending too much time on it. Most of these files still have problems due to undeclared variables or referencing modules/classes that appear to be in the global scope.Jira Ticket / Issue
Related Jira ticket: https://kbase-jira.atlassian.net/browse/DATAUP-737
DATAUP-69 Adds a PR template)Testing Instructions
Dev Checklist: