Closed kkmuffme closed 1 year ago
@kkmuffme IMO, this is not an issue.
while
conditions so if there are good reasons for it, you can selectively exclude that specific error message.@jrfnl 1) thanks I am aware I can disable a rule, however for fgetcsv it ALWAYS has to be disabled in a while loop. 2) I think this cannot be rewritten without making the code longer & ugly. Bc in a do while loop the reading would happen after the first iteration, thus be empty & not the same thing.
The handbook now contains the rule that assignments in conditions are not allowed.
It's perfectly fine if you don't want to comply and you clearly know how to exclude a rule, but that is not a reason to adjust the sniff.
So there is no valid way to process files/csv with fgetcsv, if you want to adhere to the WPCS? Isn't this clearly a bug?
@kkmuffme There are perfectly valid ways to do this, such as the do ... while
I suggested, which may be a little more verbose, but will work perfectly fine. In other words: this is not a bug.
Bug Description
fgetcsv reads the file line by line, thus we need to assign the data to a variable in the condition like:
However this triggers: WordPress.CodeAnalysis.AssignmentInCondition.Found Variable assignment found within a condition. Did you mean to do a comparison?
Minimal Code Snippet
Tested Against
develop
branch?develop
branch of WPCS.