Last modified: 2012-12-06 20:59:51 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T27517, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 25517 - Assignment in conditions should be avoided
Assignment in conditions should be avoided
Status: NEW
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
unspecified
All All
: Normal minor (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on: 25407
Blocks: code_quality
  Show dependency treegraph
 
Reported: 2010-10-13 23:35 UTC by Sam Reed (reedy)
Modified: 2012-12-06 20:59 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Sam Reed (reedy) 2010-10-13 23:35:26 UTC
After r74742, r74743, r74745 there are still 56 assignments in conditionals in MW phase3

Related to that r74727 was found (bug where = had been wrongly used in a comparison)
Comment 1 Trevor Parscal 2010-10-13 23:53:31 UTC
I'm not personally against them. Take http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/ResourceLoader.php?view=markup#l324 for instance. I think it's clear that we aren't mistakenly doing assignment rather than comparison.
Comment 2 Roan Kattouw 2010-10-15 18:17:33 UTC
I'm not against them either, provided the code makes some attempt to show that it's not mistaking = for ==.
Comment 3 Sam Reed (reedy) 2010-10-31 23:52:50 UTC
http://www.mediawiki.org/wiki/Manual:Coding_conventions#Assignment_expressions

Turns out it's in the coding conventions...
Comment 4 Trevor Parscal 2010-11-01 17:59:07 UTC
Fair enough. I'm fine with avoiding them if we are conforming to an established standard.
Comment 5 Krinkle 2012-10-26 05:06:44 UTC
(In reply to comment #0)
> [..] there are still 56 assignments in conditionals

Got a ack-grep regex to share?
Comment 6 db [inactive,noenotif] 2012-12-06 20:59:51 UTC
(In reply to comment #5)

Got a ack-grep regex to share?

\(\s*\$[^=\n&|'");]+[^!<>=]=\s*\$[^\n)'";]+\)

Looks usable

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links