FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=19437&edit=1

ID: 19437
Updated by: gsherwood@squiz.net
Reported By: jakub dot boucek@socialbakers.com
Summary: Ingoring Sniffs with dots on Windows
-Status: Feedback
+Status: Duplicate
Type: Bug
Package: PHP_CodeSniffer
Operating System: Windows 7, 64-bit
Package Version: 1.3.4
PHP Version: 5.3.13
Assigned To: squiz
Roadmap Versions:
New Comment:

-Status: Feedback
+Status: Duplicate
If this turns out to be a different issue, please reopen.


Previous Comments:
------------------------------------------------------------------------

[2012-06-19 01:16:26] squiz

-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: squiz
I think this is the same as bug #19471, which I committed a fix for. Can
you please
try the latest git version of PHPCS to see if this resolves the issue.

Instructions for running from a git clone are here:
https://github.com/squizlabs/PHP_CodeSniffer/blob/master/README.markdown#insta
llation

------------------------------------------------------------------------

[2012-06-05 02:33:04] juanmf

$sniffPos = strrpos($file,
DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR);
false === $sniffPos && $sniffPos = strrpos($file,
'/Sniffs/');

added the 2nd line. at line 660. made it work.

------------------------------------------------------------------------

[2012-05-24 17:12:01] jakubboucek

Description:
------------
If i use some rules with dots in name like a
<rule ref="Generic.Files.LineLength">
then will be library path defined as
\pear\PHP\CodeSniffer/Standards/Generic/Sniffs/Files\LineLengthSniff.php

See the shlashes - some is right-shlash, other is backshlash.

While running test, this rule is ignored.

Why? Function setTokenListeners() tests, if the sniff's path is in the
right conventions and check it with DIRECTORY_SEPARATOR. Specifically
check if the string contains '\Sniffs\'. As I said, this part of string
is directly defined with / (right-slash). Test fails and Sniff
definition is ignored.

The simpliest fix is appending the line above path checking:
//File: <pear_root>\PHP\CodeSniffer.php:656
//Notmalize path
$file = realpath($file);

Test script:
---------------
ruleset.xml

<?xml version="1.0"?>
<ruleset name="Bug check">
<rule ref="Generic.Commenting.Todo" />
</ruleset>


Expected result:
----------------
Registering sniffs in Bug check standard... DONE (1 sniffs registered)

Actual result:
--------------
Registering sniffs in Bug check standard... DONE (0 sniffs registered)

------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJul 10, '12 at 12:23a
activeJul 10, '12 at 12:23a
posts1
users1
websitepear.php.net

1 user in discussion

Gsherwood: 1 post

People

Translate

site design / logo © 2022 Grokbase