Page MenuHomePhabricator

Assignment in conditions should be avoided
Closed, ResolvedPublic

Description

Details

Reference
bz25517

Related Objects

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:18 PM
bzimport set Reference to bz25517.
bzimport added a subscriber: Unknown Object (MLST).

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.

I'm not against them either, provided the code makes some attempt to show that it's not mistaking = for ==.

Fair enough. I'm fine with avoiding them if we are conforming to an established standard.

(In reply to comment #0)

[..] there are still 56 assignments in conditionals

Got a ack-grep regex to share?

(In reply to comment #5)

Got a ack-grep regex to share?

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

Looks usable

Krinkle added a project: Technical-Debt.
Krinkle set Security to None.
Krinkle removed a subscriber: Unknown Object (MLST).
Krinkle unsubscribed.
Jdforrester-WMF subscribed.

This has been enforced for a while via the Generic.CodeAnalysis.AssignmentInCondition.Found rule in CodeSniffer.