Bug->Req #19404 [Opn]: Improve the exact mode of ScopeIndentSniff
| From: | gsherwood at squiz dot net | Date: | Tue, 08 May 2012 05:31:08 +0000 |
| Subject: | Bug->Req #19404 [Opn]: Improve the exact mode of ScopeIndentSniff | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-8621@lists.php.net to get a copy of this message | ||
Edit report at https://pear.php.net/bugs/bug.php?id=19404&edit=1
ID: 19404
Updated by: gsherwood@squiz.net
Reported By: klaus dot purer at gmail dot com
Summary: Improve the exact mode of ScopeIndentSniff
Status: Open
-Type: Bug
+Type: Feature/Change Request
Package: PHP_CodeSniffer
Operating System: Ubuntu 12.04
Package Version: SVN
PHP Version: 5.3.9
-Assigned To:
+Assigned To: squiz
Roadmap Versions:
New Comment:
-Type: Bug
+Type: Feature/Change Request
-Assigned To:
+Assigned To: squiz
I agree with the comment indent change because the sniff already needs
to check if
it is inside a comment. It fits nicely and doesn't take any more time to
check. I only
changed that part of your patch slightly:
https://github.com/squizlabs/PHP_CodeSniffer/commit/c0c677be0e85de4a5ee93fe35
79fc0e2921fd420
The other bit is harder. I agree with it in principle, but it needs more
work to ensure
it doesn't slow things down. A flag to indicate that you are inside a
parenthesis block
is easy enough, and then not apply the exact flag, but checking if you
are inside the
same statement is a bit slower. I really don't want to be looking back
through the
tokens array for each line to find the last non-whitespace/non-comment
taken on a
line (or even one several lines higher). PHP is so flexible that you
can't assume code
structures for generic sniffs, so things could get a bit messy.
The one thing really going for the change though is the fact that the
exact settings is
hardly ever used, so it is unlikely to affect a large number of
developers if something
does go wrong. And possible, given the nature of the flag, it would be
used by
developers who have a more strict standard than others, possible meaning
the code
is cleaner anyway.
Previous Comments:
------------------------------------------------------------------------
[2012-05-01 02:48:24] klausi
Added #patch bug:19404;patch:exact-indent.patch;revision:1335836904;.
------------------------------------------------------------------------
[2012-05-01 02:47:36] klausi
Added #patch bug:19404;patch:exact-indent.patch;revision:1335836856;.
------------------------------------------------------------------------
[2012-05-01 02:47:07] klausi
Description:
------------
If you configure Generic_Sniffs_Whitespace_ScopeIndentSniff with $exact
= true; then it will throw a few false positives on multi line
statements and T_DOC_COMMENTs.
Here is a valid example that uses an indentation of 2 spaces. I will
also attach a patch how I solved it for drupalcs.
Test script:
---------------
class Bar {
/**
* Enter description here ...
*/
public function foo() {
$result = db_select('node')
->condition('type', 'article')
->execute();
}
}
Expected result:
----------------
There should be no indentation error.
Actual result:
--------------
The sniff complains about the indentation of the doc block and the
chained method invocations.
------------------------------------------------------------------------
--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=19404&edit=1