Closed henryruhs closed 11 years ago
Hi,
Have you tried using the standard as an option for your grunt configuration?
Cheers,
James
Why did you close this? I see no relatation between this issue and the merged pull request.
I like to do something similar to: phpcs --standard=ruleset.xml source/
options: { bin: 'vendor/bin/phpcs', standard: 'ruleset.xml' }
is not working for me!
Yeah - sorry my fault! Wrong commit. However, you should be able to use ruleset.xml with standard options. Is ruleset.xml in the root directory?
Can you post your ruleset.xml please?
Root of my project: https://github.com/redaxmedia/redaxscript Ruleset: https://github.com/redaxmedia/redaxscript/blob/master/ruleset.xml
At the moment I do a work arround by copying the ruleset^^ see gruntfile.js
See task copy.ruleset ... the ruleset is working onced inside the standards folder
Thanks - will do. I've just run a test locally with:
<?xml version="1.0"?>
<ruleset name="Custom Standard">
<description>A custom coding standard</description>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/data/*</exclude-pattern>
<rule ref="PEAR"/>
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="90"/>
<property name="absoluteLineLimit" value="100"/>
</properties>
</rule>
</ruleset>
And this works fine.
i did not look into your code but i guess there is a problem between your options's bin and the location it is searching for the ruleset.xml ?
Just run a local copy of your custom ruleset.xml against our tests in the plugin repo:
Starting phpcs (target: application) in php/modules
Exec: vendor/bin/phpcs --standard=ruleset.xml -v php/modules
Registering sniffs in Redaxscript standard... DONE (195 sniffs registered)
Creating file list... DONE (1 files in queue)
Changing into directory /Users/james/projects/grunt-phpcs/php/modules/Grunt/PhpCs
Processing World.php [139 tokens in 47 lines]... DONE in < 1 second (69 errors, 1 warnings)
FILE: /Users/james/projects/grunt-phpcs/php/modules/Grunt/PhpCs/World.php
--------------------------------------------------------------------------------
FOUND 69 ERROR(S) AND 1 WARNING(S) AFFECTING 29 LINE(S)
--------------------------------------------------------------------------------
1 | ERROR | End of line character is invalid; expected "\r\n" but found
| | "\n"
1 | ERROR | Filename "World.php" doesn't match the expected filename
| | "world.php"
1 | ERROR | The PHP open tag does not have a corresponding PHP close tag
1 | ERROR | Class found in ".php" file; use ".inc" extension instead
3 | ERROR | File comment short description must end with a full stop
6 | WARNING | PHP version not specified
6 | ERROR | Missing @category tag in file comment
6 | ERROR | Missing @author tag in file comment
6 | ERROR | Missing @license tag in file comment
6 | ERROR | Missing @link tag in file comment
6 | ERROR | Missing @subpackage tag in file comment
6 | ERROR | Missing @author tag in file comment
6 | ERROR | Missing @copyright tag in file comment
6 | ERROR | Missing @license tag in file comment
6 | ERROR | There must be exactly one blank line after the file comment
9 | ERROR | Missing class doc comment
9 | ERROR | Missing class doc comment
12 | ERROR | Tabs must be used to indent lines; spaces are not allowed
12 | ERROR | Missing short description in variable doc comment
13 | ERROR | There must be exactly one blank line before the tags in
| | variable comment
16 | ERROR | Tabs must be used to indent lines; spaces are not allowed
16 | ERROR | Private member variable "name" must be prefixed with an
| | underscore
16 | ERROR | Private member variable "name" must contain a leading
| | underscore
16 | ERROR | Private member variable "name" must contain a leading
| | underscore
18 | ERROR | Tabs must be used to indent lines; spaces are not allowed
19 | ERROR | Function comment short description must end with a full stop
19 | ERROR | Function comment short description must end with a full stop
21 | ERROR | Missing comment for param "$name" at position 1
21 | ERROR | Missing comment for param "$name" at position 1
21 | ERROR | Missing comment for param "$name" at position 1
23 | ERROR | Tabs must be used to indent lines; spaces are not allowed
23 | ERROR | Expected 2 blank lines before function; 1 found
24 | ERROR | Tabs must be used to indent lines; spaces are not allowed
24 | ERROR | Opening brace should be on the same line as the declaration
25 | ERROR | Tabs must be used to indent lines; spaces are not allowed
26 | ERROR | Tabs must be used to indent lines; spaces are not allowed
26 | ERROR | Expected //end __construct()
26 | ERROR | Expected 1 blank line before closing function brace; 0 found
26 | ERROR | Expected 2 blank lines after function; 1 found
28 | ERROR | Tabs must be used to indent lines; spaces are not allowed
29 | ERROR | Function comment short description must end with a full stop
29 | ERROR | Function comment short description must end with a full stop
31 | ERROR | Missing comment for param "$name" at position 1
31 | ERROR | Missing comment for param "$name" at position 1
31 | ERROR | Missing comment for param "$name" at position 1
32 | ERROR | Missing @return tag in function comment
32 | ERROR | Missing @return tag in function comment
32 | ERROR | Missing @return tag in function comment
33 | ERROR | Tabs must be used to indent lines; spaces are not allowed
34 | ERROR | Tabs must be used to indent lines; spaces are not allowed
34 | ERROR | Opening brace should be on the same line as the declaration
35 | ERROR | Tabs must be used to indent lines; spaces are not allowed
36 | ERROR | Tabs must be used to indent lines; spaces are not allowed
36 | ERROR | Expected //end setName()
36 | ERROR | Expected 1 blank line before closing function brace; 0 found
36 | ERROR | Expected 2 blank lines after function; 1 found
38 | ERROR | Tabs must be used to indent lines; spaces are not allowed
39 | ERROR | Function comment short description must end with a full stop
39 | ERROR | Function comment short description must end with a full stop
43 | ERROR | Tabs must be used to indent lines; spaces are not allowed
44 | ERROR | Tabs must be used to indent lines; spaces are not allowed
44 | ERROR | Opening brace should be on the same line as the declaration
45 | ERROR | Tabs must be used to indent lines; spaces are not allowed
46 | ERROR | Tabs must be used to indent lines; spaces are not allowed
46 | ERROR | Expected //end getName()
46 | ERROR | Expected 1 blank line before closing function brace; 0 found
46 | ERROR | Expected 2 blank lines after function; 0 found
47 | ERROR | Closing brace of a class must be followed by a blank line and
| | then a closing PHP tag
47 | ERROR | Expected //end class
47 | ERROR | PHP files must not end with a newline character
--------------------------------------------------------------------------------
Time: 0 seconds, Memory: 11.25Mb
Fatal error: Command failed:
same here, but it does look like it is not taking my ruleset and jumps to another default!? my Redaxscript rulset is so limited, it should not show any errors or warnings...
Gruntfile.js is as:
phpcs: {
application: {
dir: 'php/modules'
},
options: {
bin: 'vendor/bin/phpcs',
standard: 'ruleset.xml'
}
}
OK - but when you running it, you are seeing it register with phpcs?
nope, i cannot see the register to many errors that finally fail with maxbuffer^^
could you please clone / checkout my repo... run composer install and npm install and give it a try?
If you run with --verbose as a grunt command, we include the actual command run. You can see below:
Starting phpcs (target: application) in php/modules
Exec: vendor/bin/phpcs --standard=ruleset.xml -v php/modules
Registering sniffs in Redaxscript standard... DONE (195 sniffs registered)
Creating file list... DONE (1 files in queue)
Changing into directory /Users/james/projects/grunt-phpcs/php/modules/Grunt/PhpCs
Processing World.php [139 tokens in 47 lines]... DONE in < 1 second (69 errors, 1 warnings)
I've just attempted and can see that ruleset.xml does include a lot more sniffs. Whilst creating an independent standard only includes 7 sniffs. I believe this is more of an issue with PHPCS than the grunt plugin.
Running:
vendor/bin/phpcs --standard=ruleset.xml -v php/modules
Does the same as the grunt plugin - e.g. the plugin isn't ignore the ruleset.xml. However, copying your ruleset into the standards folder does only load the 7 sniffs.
so copying into own standard folder does only load my sniffs but loading ruleset.xml loads my sniffs plus the generic rulset collection? correct? quite confusing to me^^
Yeah - you can use the -vvv command with phpcs to see the sniffs run:
vendor/bin/phpcs --standard=ruleset.xml -vvv php/modules
Will show you the sniffs runs:
Squiz_Sniffs_PHP_CommentedOutCodeSniff: 0.0043 secs
MySource_Sniffs_Commenting_FunctionCommentSniff: 0.0024 secs
Squiz_Sniffs_Commenting_FunctionCommentSniff: 0.0022 secs
PEAR_Sniffs_Commenting_FunctionCommentSniff: 0.0019 secs
Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff: 0.0016 secs
Squiz_Sniffs_Commenting_DocCommentAlignmentSniff: 0.0014 secs
PEAR_Sniffs_Commenting_FileCommentSniff: 0.0012 secs
Generic_Sniffs_WhiteSpace_DisallowSpaceIndentSniff: 0.0011 secs
Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff: 0.001 secs
Squiz_Sniffs_Commenting_FileCommentSniff: 0.001 secs
Generic_Sniffs_WhiteSpace_ScopeIndentSniff: 0.0009 secs
Squiz_Sniffs_Commenting_VariableCommentSniff: 0.0009 secs
Squiz_Sniffs_NamingConventions_ValidVariableNameSniff: 0.0009 secs
Zend_Sniffs_NamingConventions_ValidVariableNameSniff: 0.0008 secs
Generic_Sniffs_Files_LineLengthSniff: 0.0008 secs
PEAR_Sniffs_WhiteSpace_ScopeIndentSniff: 0.0008 secs
Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff: 0.0007 secs
Squiz_Sniffs_Commenting_InlineCommentSniff: 0.0007 secs
PEAR_Sniffs_NamingConventions_ValidVariableNameSniff: 0.0006 secs
Squiz_Sniffs_WhiteSpace_MemberVarSpacingSniff: 0.0005 secs
PSR2_Sniffs_Classes_PropertyDeclarationSniff: 0.0005 secs
Squiz_Sniffs_Scope_MemberVarScopeSniff: 0.0005 secs
Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff: 0.0004 secs
Generic_Sniffs_Classes_DuplicateClassNameSniff: 0.0004 secs
Squiz_Sniffs_Commenting_BlockCommentSniff: 0.0004 secs
Squiz_Sniffs_Commenting_ClosingDeclarationCommentSniff: 0.0004 secs
Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff: 0.0004 secs
Squiz_Sniffs_Classes_ClassDeclarationSniff: 0.0004 secs
Generic_Sniffs_Commenting_FixmeSniff: 0.0004 secs
Squiz_Sniffs_WhiteSpace_FunctionSpacingSniff: 0.0004 secs
Squiz_Sniffs_Functions_FunctionDeclarationSniff: 0.0003 secs
Generic_Sniffs_Commenting_TodoSniff: 0.0003 secs
PSR2_Sniffs_Methods_MethodDeclarationSniff: 0.0003 secs
Generic_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff: 0.0003 secs
PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff: 0.0003 secs
Generic_Sniffs_NamingConventions_ConstructorNameSniff: 0.0003 secs
Squiz_Sniffs_NamingConventions_ValidFunctionNameSniff: 0.0003 secs
Squiz_Sniffs_PHP_DisallowComparisonAssignmentSniff: 0.0003 secs
Generic_Sniffs_Functions_CallTimePassByReferenceSniff: 0.0003 secs
Squiz_Sniffs_PHP_DisallowMultipleAssignmentsSniff: 0.0002 secs
Generic_Sniffs_CodeAnalysis_UselessOverridingMethodSniff: 0.0002 secs
Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff: 0.0002 secs
Generic_Sniffs_Formatting_DisallowMultipleStatementsSniff: 0.0002 secs
Squiz_Sniffs_Scope_StaticThisUsageSniff: 0.0002 secs
PSR1_Sniffs_Classes_ClassDeclarationSniff: 0.0002 secs
PEAR_Sniffs_Functions_FunctionCallSignatureSniff: 0.0002 secs
PEAR_Sniffs_Functions_FunctionDeclarationSniff: 0.0002 secs
Generic_Sniffs_PHP_ClosingPHPTagSniff: 0.0002 secs
Squiz_Sniffs_PHP_LowercasePHPFunctionsSniff: 0.0002 secs
Generic_Sniffs_PHP_DeprecatedFunctionsSniff: 0.0002 secs
Squiz_Sniffs_Functions_MultiLineFunctionDeclarationSniff: 0.0002 secs
PSR2_Sniffs_Files_EndFileNewlineSniff: 0.0002 secs
Squiz_Sniffs_PHP_ForbiddenFunctionsSniff: 0.0002 secs
Generic_Sniffs_PHP_ForbiddenFunctionsSniff: 0.0002 secs
Squiz_Sniffs_PHP_DiscouragedFunctionsSniff: 0.0002 secs
Squiz_Sniffs_WhiteSpace_FunctionClosingBraceSpaceSniff: 0.0002 secs
PEAR_Sniffs_WhiteSpace_ScopeClosingBraceSniff: 0.0002 secs
Squiz_Sniffs_PHP_EmbeddedPhpSniff: 0.0002 secs
Squiz_Sniffs_WhiteSpace_ScopeClosingBraceSniff: 0.0002 secs
Squiz_Sniffs_Scope_MethodScopeSniff: 0.0002 secs
Generic_Sniffs_Files_OneClassPerFileSniff: 0.0001 secs
Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff: 0.0001 secs
Squiz_Sniffs_WhiteSpace_ScopeKeywordSpacingSniff: 0.0001 secs
Generic_Sniffs_Metrics_CyclomaticComplexitySniff: 0.0001 secs
MySource_Sniffs_PHP_AjaxNullComparisonSniff: 0.0001 secs
Generic_Sniffs_Functions_OpeningFunctionBraceKernighanRitchieSniff: 0.0001 secs
Squiz_Sniffs_Functions_FunctionDeclarationArgumentSpacingSniff: 0.0001 secs
Squiz_Sniffs_Operators_IncrementDecrementUsageSniff: 0.0001 secs
PSR2_Sniffs_Classes_ClassDeclarationSniff: 0.0001 secs
PEAR_Sniffs_WhiteSpace_ObjectOperatorIndentSniff: 0.0001 secs
Squiz_Sniffs_Functions_LowercaseFunctionKeywordsSniff: 0.0001 secs
Squiz_Sniffs_PHP_DisallowObEndFlushSniff: 0.0001 secs
PEAR_Sniffs_Formatting_MultiLineAssignmentSniff: 0.0001 secs
MySource_Sniffs_PHP_GetRequestDataSniff: 0.0001 secs
PEAR_Sniffs_Functions_ValidDefaultValueSniff: 0.0001 secs
Squiz_Sniffs_Files_FileExtensionSniff: 0.0001 secs
Squiz_Sniffs_WhiteSpace_SemicolonSpacingSniff: 0.0001 secs
Squiz_Sniffs_Commenting_LongConditionClosingCommentSniff: 0.0001 secs
PSR1_Sniffs_Files_SideEffectsSniff: 0.0001 secs
Squiz_Sniffs_PHP_NonExecutableCodeSniff: 0.0001 secs
Squiz_Sniffs_Classes_ValidClassNameSniff: 0.0001 secs
Squiz_Sniffs_WhiteSpace_FunctionOpeningBraceSpaceSniff: 0.0001 secs
Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff: 0.0001 secs
Generic_Sniffs_Files_EndFileNoNewlineSniff: 0.0001 secs
Generic_Sniffs_Metrics_NestingLevelSniff: 0.0001 secs
Squiz_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff: 0.0001 secs
PEAR_Sniffs_Commenting_ClassCommentSniff: 0.0001 secs
Generic_Sniffs_Files_LineEndingsSniff: 0.0001 secs
Generic_Sniffs_Files_LowercasedFilenameSniff: 0.0001 secs
Generic_Sniffs_VersionControl_SubversionPropertiesSniff: 0.0001 secs
Squiz_Sniffs_PHP_InnerFunctionsSniff: 0 secs
Squiz_Sniffs_Commenting_ClassCommentSniff: 0 secs
Squiz_Sniffs_Functions_FunctionDuplicateArgumentSniff: 0 secs
Zend_Sniffs_Debug_CodeAnalyzerSniff: 0 secs
Generic_Sniffs_Files_EndFileNewlineSniff: 0 secs
PEAR_Sniffs_NamingConventions_ValidClassNameSniff: 0 secs
MySource_Sniffs_PHP_ReturnFunctionValueSniff: 0 secs
Squiz_Sniffs_Functions_GlobalFunctionSniff: 0 secs
Squiz_Sniffs_Classes_ClassFileNameSniff: 0 secs
MySource_Sniffs_Channels_DisallowSelfActionsSniff: 0 secs
PEAR_Sniffs_Classes_ClassDeclarationSniff: 0 secs
PSR2_Sniffs_Namespaces_NamespaceDeclarationSniff: 0 secs
Generic_Sniffs_CodeAnalysis_UnnecessaryFinalModifierSniff: 0 secs
Squiz_Sniffs_Strings_DoubleQuoteUsageSniff: 0 secs
Squiz_Sniffs_WhiteSpace_LanguageConstructSpacingSniff: 0 secs
Squiz_Sniffs_Classes_LowercaseClassKeywordsSniff: 0 secs
Generic_Sniffs_PHP_DisallowShortOpenTagSniff: 0 secs
Generic_Sniffs_PHP_CharacterBeforePHPOpeningTagSniff: 0 secs
*** END SNIFF PROCESSING REPORT ***
DONE in < 1 second (69 errors, 1 warnings)
Copying your standard into the folder results in:
vendor/bin/phpcs --standard=Redaxscript -vvv php/modules
Then you get:
Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff: 0.0016 secs
Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff: 0.0006 secs
Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff: 0.0004 secs
Generic_Sniffs_Files_LineEndingsSniff: 0.0001 secs
Generic_Sniffs_PHP_DisallowShortOpenTagSniff: 0 secs
In summary, this issue should remain closed.
okay, thanks a lot for your support!
No worries! However, can't see anything with using copy and this plugin together. Seems to fit nicely :+1:
I cannot get this to work, only by adding new folder under Standards with the related ruleset.xml - I dislike to do that step on every checkout.