cakephp / cakephp/cakephp-codesniffer

TabAndSpace.DoubleSpace incorrectly detects within the line

Open
#423 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

sniffs
Dominant language
PHP
Stars
232
Forks
85
PR merge metrics
No merged PRs in 30d

Description

The documentation for this sniff clearly states the following:

Check for any line starting with 2 spaces

However, the sniff will incorrectly trigger on line 2 in this example:

	private array $bufferRequests = [];
	private bool $inBuffer        = false;

The first 2 characters of both lines are tab. The failure of this sniff is that it is checking the entire contents of the line, looking for double space. This is not what the docs say this sniff does. Furthermore, as currently implemented, this behavior conflicts with Generic.Formatting.MultipleStatementAlignment which says that multiple assignment lines should be aligned, as the example above shows.

Please fix this sniff to correctly, and only, search the beginning of the line for violation.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the implementation of the TabAndSpace.DoubleSpace sniff and its documentation, then reproduce the reported two-line example. Done means only lines beginning with two spaces are flagged, while spaces used for alignment later in a line are ignored.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.