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)

4102.diff (7.0 KB ) - added by Stan 8 years ago.
Proposal
4102.1.diff (7.3 KB ) - added by Stan 8 years ago.
Fix the above and and three warnings
4102-GUIInterface.diff (8.4 KB ) - added by Stan 8 years ago.
Code Fixes for GUIInterface
garrison-4102.patch (18.0 KB ) - added by mimo 8 years ago.
updated version of the garrisonHolder cleanup
4102.3.diff (22.8 KB ) - added by Stan 8 years ago.
Should be nice
4102.4.diff (23.5 KB ) - added by Stan 8 years ago.
Some other stuff elexis reported
4102.5.diff (23.5 KB ) - added by Stan 8 years ago.
Fix a vector
4102.10.diff (23.7 KB ) - added by Stan 8 years ago.
Version Bump, Multiple fixes

Download all attachments as: .zip

Change History (25)

by Stan, 8 years ago

Attachment: 4102.diff added

Proposal

comment:1 by Stan, 8 years ago

Owner: set to Stan
Status: newassigned

comment:2 by bb, 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

by Stan, 8 years ago

Attachment: 4102.1.diff added

Fix the above and and three warnings

comment:3 by elexis, 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.

comment:4 by Stan, 8 years ago

Will do next.

by Stan, 8 years ago

Attachment: 4102-GUIInterface.diff added

Code Fixes for GUIInterface

by mimo, 8 years ago

Attachment: garrison-4102.patch added

updated version of the garrisonHolder cleanup

comment:5 by elexis, 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 :)

by Stan, 8 years ago

Attachment: 4102.3.diff added

Should be nice

by Stan, 8 years ago

Attachment: 4102.4.diff added

Some other stuff elexis reported

by Stan, 8 years ago

Attachment: 4102.5.diff added

Fix a vector

by Stan, 8 years ago

Attachment: 4102.10.diff added

Version Bump, Multiple fixes

in reply to:  5 ; comment:6 by mimo, 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.

in reply to:  6 comment:7 by elexis, 8 years ago

See @wiki:SubmittingPatches

When you modify or add methods to simulation components, you should add unit tests that test all added or modified changes. 

comment:8 by elexis, 8 years ago

Milestone: Alpha 21Alpha 22

Feature freeze in 2 days.

comment:9 by elexis, 7 years ago

(Still) Reviewable?

comment:10 by Stan, 7 years ago

If it's not i'll rebase it later today.

comment:11 by elexis, 7 years ago

Keywords: rfc added

comment:12 by Stan, 7 years ago

Patch applies fine on my end.

comment:13 by bb, 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)

Last edited 7 years ago by bb (previous) (diff)

comment:14 by Stan, 7 years ago

Keywords: patch rfc removed
Summary: [PATCH] Garrison Holder code style fixesGarrison Holder code style fixes

Differential Revision:

https://code.wildfiregames.com/D90

Last edited 7 years ago by Stan (previous) (diff)

comment:15 by elexis, 7 years ago

Milestone: Alpha 22Work 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:16 by Imarok, 7 years ago

In 19927:

Garrison Holder code style fixes

Reviewed By: Imarok, bb
Refs #4102, D90

comment:17 by Stan, 7 years ago

Milestone: Work In ProgressAlpha 23
Resolution: fixed
Status: assignedclosed

Looks fixed by me for me. Thanks Imarok :D

Note: See TracTickets for help on using tickets.