3

I already have lines indented with Tabs inside my plugin file. But PHPCS still reports the following:

Tabs must be used to indent lines; spaces are not allowed

32 | ERROR   | [x] Tabs must be used to indent lines; spaces are not allowed
      |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)

Command line sniff command is

$ phpcs --standard=phpcs.xml.dist cool-media.filter.php > phpcs_errors.txt

Sample code snippet:

function __construct() {
<TAB>$this->plugin      = plugin_basename( __FILE__ );
<TAB>$this->taxonomy    = 'category';
<TAB>$this->post_type   = 'attachment';
<TAB>$this->text_domain = 'cool-media-filter';

<TAB>$this->taxonomy    = apply_filters( 'cool_media_taxonomy', $this->taxonomy );
}

I don't know how to fix!

Editor: PHPStorm
Coding standard used in project: WordPress Core
Ruleset: https://github.com/Automattic/_s/blob/master/phpcs.xml.dist

Any suggestion would be helpful. I am new to Code Sniffer.

EDIT (Screenshot from code editor)

enter image description here

Subrata Sarkar
  • 2,975
  • 6
  • 45
  • 85

1 Answers1

3

Although you might have pressed the tab key to get the indentation, I suspect that your editor is set to automatically replace that tab with spaces.

Check your editor's code standards settings, add in an .editorconfig file, and/or run phpcbf --standard=WordPress-Core cool-media.filter.php to autofix this issue (and any other issues).

GaryJ
  • 1,878
  • 2
  • 16
  • 22
  • This is not a solution for the tabs fixt, this is just for that particular file and replaces the standard for that file – Timberman Jul 04 '23 at 09:22