Disable checkstyle validation for specific variables
I am working in a PHP project that uses checkstyle to validate the code. I have a problem with a part of the code that reads XML's with simplexml, the XML is all in uppercase and for example:
$response = simplexml_load_string($xml);
$code = $response->CODE; // checkstyle won't validate this because it is in uppercase
this piece of code gives me warnings because the variable name is in uppercase (the variables are required to be in camelcase). There are lots of warnings in the code because of this.
The question is: can I disable checking specific variables,开发者_JAVA技巧 or an entire region of code? How?
Thank you very much.
I dont know how to do that with checkstyle, but PHPCS can also create reports in CheckStyle format. So if you are not fixed on using Checkstyle, you could switch. With PHPCS you can add pseudo annotations into the code to skip checking, e.g.
// @codingStandardsIgnoreFile
or just portions on code
$response = simplexml_load_string($xml);
// @codingStandardsIgnoreStart
$code = $response->CODE;
// @codingStandardsIgnoreEnd
echo $code->asXml();
Also check for http://phpqatools.org and http://jenkins-php.org/ for additional QA tools.
精彩评论