Question

I seem to be getting a strange situation where CodeSniffer is applying 2 indent space conditions on some lines of code. An example is below, where, if I set 0 indent on the line for demo purposes, it outputs the following error:

336 | ERROR | Line indented incorrectly; expected 4 spaces, found 0

336 | ERROR | Line indented incorrectly; expected 6 spaces, found 0

As you can see, it is expecting 4 spaces and 6 spaces on the same line. Has anyone ever seen this behaviour?

Was it helpful?

Solution

The line of code in question is enclosed in an if else {} block, which is in turn enclosed in an if {} block.

If I change the if else to ifelse, it fixes the problem, with the Indent sniff reporting correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top