Opened 8 years ago
Closed 7 years ago
#4102 closed defect (fixed)
Garrison Holder code style fixes
Reported by: | Stan | Owned by: | Stan |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 23 |
Component: | UI & Simulation | Keywords: | |
Cc: | Patch: |
Description
Garrison Holder has some code style issues, for example bad linebreaks, uses deprecated for each, variables out of scope, redeclared variables and the like that ought to be fixed. Most of them can be found using jshint.
Attachments (8)
Change History (25)
by , 8 years ago
comment:1 by , 8 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:2 by , 8 years ago
Don't add new var's use let instead. This should ofc. be done in the whole file, but that should be a separate patch to avoid megapatches and make the review easier.
L378-381 no need for braces, this happens on some other places in the file too, not sure if it should be splitted.
Old L285 space error too would be nice to fix that one in same commit
comment:3 by , 8 years ago
If someone wants to write more cleanup patches, GUIInterface.js
is changed often and JShint always complains about a range of issues.
by , 8 years ago
Attachment: | garrison-4102.patch added |
---|
updated version of the garrisonHolder cleanup
follow-up: 6 comment:5 by , 8 years ago
Keywords: | review removed |
---|
No tests, no cookies. The good news is that writing tests for the garrison holder should be pretty simple and I think Stan could do it :)
follow-up: 7 comment:6 by , 8 years ago
Replying to elexis:
No tests, no cookies. The good news is that writing tests for the garrison holder should be pretty simple and I think Stan could do it :)
Not sure what is the expected gain compared to an independant patch with tests? this patch and the test one are independant, and as this patch is already quite big, the more we wait, the more chance we have that it will need a rebase with some chance to introduce new bugs. But ok if you take charge of it from now.
comment:7 by , 8 years ago
When you modify or add methods to simulation components, you should add unit tests that test all added or modified changes.
comment:11 by , 7 years ago
Keywords: | rfc added |
---|
comment:13 by , 7 years ago
Component: L22 isn't "hit point" one word "hitpoint"? Shouldn't JsDoc comments have a period on the end of a sentence?
Are checks for cmpTimer actually necessary as it is a SYSTEM_ENTITY? When we should add them L261 can be change to
if (cmpTimer) this.timer = cmpTimer.SetTimeout(this.entity, IID_GarrisonHolder, "HealTimeout", 1000, {});
So we nuke the error
L451 missing whitespace L452 missing whitespaces, maybe meh
L517 Shouldn't we check for if (!cmpHealth)
? and I guess we should {return true
if the check is true.
L518-9 Those variables can be inlined imo. I would keep ejectHitpoints
for readability.
L520 Why is that floor needed? And unneeded parenthesis.
L541-5 unneeded parenthesis. L584-7 unneeded parenthesis.
L667 var -> let
L670 check for cmpPosition
too.
L703 unneeded parenthesis.
IIRC some patch tools complain when there is no newline at the end of a file, so probably leave it.
Test: The test doesn't seem to test the function UnloadByPlayer and UnloadByTemplate. Might be nice too Unload some units with those functions too. (I guess we should add some more units for this.) Also GetCapacity is tested more than ones as it is called by other function too, but we now test for the exact number so I think it is ok.
L26, L27, L64, L78 arrow functions with one parameter doesn't need parenthesis.
JsHint output: binaries/data/mods/public/simulation/components/tests/test_GarrisonHolder.js: line 9, col 60, Missing semicolon. binaries/data/mods/public/simulation/components/tests/test_GarrisonHolder.js: line 12, col 51, Missing semicolon. binaries/data/mods/public/simulation/components/tests/test_GarrisonHolder.js: line 71, col 24, Don't make functions within a loop. binaries/data/mods/public/simulation/components/tests/test_GarrisonHolder.js: line 72, col 24, Don't make functions within a loop. binaries/data/mods/public/simulation/components/tests/test_GarrisonHolder.js: line 73, col 28, Don't make functions within a loop.
(those functions are false positives I guess)
comment:14 by , 7 years ago
Keywords: | patch rfc removed |
---|---|
Summary: | [PATCH] Garrison Holder code style fixes → Garrison Holder code style fixes |
Differential Revision:
comment:15 by , 7 years ago
Milestone: | Alpha 22 → Work In Progress |
---|
Moving to the Work In Progress milestone, since there is a patch asking for feedback, but since it is not strictly bound to a specific release.
comment:17 by , 7 years ago
Milestone: | Work In Progress → Alpha 23 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Looks fixed by me for me. Thanks Imarok :D
Proposal