Opened 9 years ago
Closed 9 years ago
#3259 closed enhancement (wontfix)
[PATCH] Clean javascript code syntax of for loops
Reported by: | elexis | Owned by: | |
---|---|---|---|
Priority: | If Time Permits | Milestone: | |
Component: | UI & Simulation | Keywords: | patch |
Cc: | Patch: |
Description
The attached patch fixes the code style of all for loops and changes all occurances of i++ to ++i (for all variable names). I created the patch the following way:
- Identify loops with undesired style:
cd "trunk/binaries/data/mods/public"; grep -R "++)" --include=*.js *
- Extract all variable names by hand and save to variables.txt
- Replace all increments with sed (execute in binaries/data/mods/public)
while read v; do find . -name "*.js" -print | xargs sed -i "s/ ${v}++/ ++${v}/g" done <variables.txt
- Create a minimalist patch without unified context:
svn diff --diff-cmd diff -x "-U0" http://svn.wildfiregames.com/public/ps/trunk/ > patch
leper suggested some sed magic to combine steps 1-3 (not tested):
s/(for[ ]*\([^;];[^;];)([ ]*[^)+])+\+/$1\+\+$2/g
The patch should be ready to commit anyway.
Another thing that might be corrected automatically are those brackets {
after for
keywords, where a newline should be inserted and not only a space.
Attachments (1)
Change History (3)
by , 9 years ago
Attachment: | t3259_clean_for_loops_v1.patch.7z added |
---|
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Keywords: | review removed |
---|---|
Milestone: | Backlog |
Resolution: | → wontfix |
Status: | new → closed |
Especially since some of those loops could be changed to other ones if it makes more sense so I'd rather do it when we touch code in that files already instead of doing one big commit that might not fix things in the best way possible.
I think someone else said it on IRC but this kind of patch is not really good, it's nicer to include style enhancements in other patches.