-
-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass the value of variables to checkers #72
Conversation
Sounds good. Just make sure there is no default set in flycheck because the usual way to the default is via the phpcs config file, e.g. /etc/php-codesniffer/CodeSniffer.conf (flymake-phpcs had that set to PEAR as default which I found pretty annoying) Cheers |
Does |
I couldn't find one... I think it's hard coded into the package, not sure though |
Hmm, my phpcs (installed from pear) is a php script. I quickly looked through the php libraries it calls, and didn't see a reference to a config file. But maybe I just missed it. Anyway, on my system, if there is a config file, phpcs did a good job of hiding it. So I think passing an argument to flycheck is the most solid way of setting the 'Standard'. See phpcs source Edit (lunaryorn): Replaced pasted source code with source link |
@dhaley Please do not just dump large code listings into comments, the more if the listings don't provide any insight at all. I've taken the liberty to edit your comment to replace the source code snippet with a link to the source code repository of phpcs. |
lunaryorn, thanks for cleaning that up. A link makes a lot more sense. |
this is how the default standard is set:
http://pear.php.net/manual/en/package.php.php-codesniffer.config-options.php it then creates the config file:
<?php
$phpCodeSnifferConfig = array (
'default_standard' => 'Squiz',
) |
@steckerhalter I assume that there is no option to specify a project-specific configuration file, is there? |
No, there is no way to specify a project specific configuration file. The "--standard" option can also be used to point to the path / file with a specific standard though. |
steckerhalter, thanks your details on creating the Code Sniffer config file. For me, with "mac ports" installed pear, the conf file lives at: /opt/local/lib/php/data/PHP_CodeSniffer/CodeSniffer.conf Since I only do Drupal php these days, I can probably live with just setting the standard in the Code Sniffer config file. But it would be nice to switch the standard dynamically based on php derived minor modes, as you guys are proposing. |
This change prepares for [#72] and the subsequent support for coding standards in the PHP CodeSniffer checker, which does only accept options and values given as single argument.
Add `option` cell, and `flycheck-def-option-var` macro to declare syntax checkers.
Analogous to
config
, addoption
tag to checker commands to pass the value of a variable to a checker. Accompany this tag with a macroflycheck-def-option-var
that declares the corresponding variable.Interface
The first element of
config
is the option to use, the second the variable symbol.The first argument is the variable name, the second the associated checker, the third the default value, and the forth is the docstring. Any further options will be pass to
defcustom
. The variable will be made buffer local and customizable within a groupflycheck-checker-options
.Rationale
Allow to configure checkers beyond configuration files. See #71 for an example.