This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Recent php code sniffer (phpcs) loads phpcs.xml or phpcs.xml.dist form the current directory (or any parent directory, see [1]). But when configuring code sniffer in options, I have to select a coding standard which overwrites this settings (because --standard=XXX disables looking for default configuration). Please allow to select no standard (for loading the default), or/and to select a path as standard (is supported by --standard, see [2]). [1] https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file [2] https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage#specifying-a-coding-standard
Could you please attach a sample project and provide exact steps to reproduce? Just to ensure that NetBeans will support it correctly. Thanks for reporting.
More bug than enhancement.
As a project using phpcs.xml.dist we can take PHP_CodeSniffer as an example: https://github.com/squizlabs/PHP_CodeSniffer/ When running "phpcs any/file.php" in the console in a directory of the project (the root folder, CodeSniffer/DocGenerators/, ...) the phpcs.xml.dist is used. This is what I expect to happen inside netbeans as well. steps: * clone or copy https://github.com/squizlabs/PHP_CodeSniffer/ * create new php project in netbeans, select "PHP Application with Existing Sources", select "PHP_CodeSniffer" as source (and finish the assistant) * open a php file (example CodeSniffer/DocGenerators/Generator.php) * (to be sure to see wrong configuration, go in menu Tools->Options, then to "PHP, Tab "Code Analysis", select "Code Sniffer"; select Zend as Default standard) * in Menu, select Source->Inspect * in the dialogue, select "Code Sniffer" as configuration and continue (click "Inspect") Expected: phpcs.xml.dist is used, you should see no errors in the results Current: --standard=Zend is used, many errors in the results Is this helpful? Or do you prefer a repo with phpcs.xml.dist and nbproject/ included?
(In reply to simohe from comment #3) > Expected: phpcs.xml.dist is used, you should see no errors in the results > Current: --standard=Zend is used, many errors in the results So, does it mean that if phpcs.xml[.dist] file exists in the project directory, NetBeans should not use CLI param --standard? Is it correct? In all situations? Or only sometimes (if e.g. standard is not defined in the XML file, if possible)? > Is this helpful? Or do you prefer a repo with phpcs.xml.dist and nbproject/ > included? I guess the steps you provided should be enough, will let you know if not. Thanks for it! I will get to it quite soon I hope, definitely will try to fix it for the next stable version of NetBeans. Thanks for reporting.
Right, it will work like you describe. Alternative to checking if phpcs.xml{,.dist} exists: do not provide "--standard XXX" but "--runtime-set default_standard XXX". Then XXX is used when no standard config file is found. I generally do not see why I am forced to provide a value for --standard. phpcs has a default standard. I can change it with phpcs --config-set default_standard XXX. (And --standard would also allow a path to a config file or multiple standards [1]) Thank you very much for looking into this. [1] https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage#specifying-a-coding-standard
Note: The working directory of the phpcs process must be the project root (or the directory containing the file being checked).
Should be done now, please verify if possible. Please note that the config file must be in a project directory (at least this is the workdir of the command NetBeans runs). Thanks. http://hg.netbeans.org/web-main/rev/5a0809700013
Integrated into 'main-silver', will be available in build *201604200001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/5a0809700013 User: Tomas Mysik <tmysik@netbeans.org> Log: #258832 - Code Sniffer does not support default project config file phpcs.xml