Skip to content

Commit

Permalink
Merge pull request #45 from universityofadelaide/phpcs-xml
Browse files Browse the repository at this point in the history
Use phpcs.xml file for configuration and simplify commands
  • Loading branch information
acbramley authored Aug 23, 2018
2 parents beac21d + c5eb5b6 commit e03c944
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
27 changes: 2 additions & 25 deletions RoboFileBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,6 @@ abstract class RoboFileBase extends \Robo\Tasks {
protected $config_new_directory = 'config_new';
protected $config_old_directory = 'config_old';

/**
* The folders to scan for php coding standards violations.
*
* @var string
*/
protected $phpcsFolders = 'web/modules/custom web/profiles';

/**
* The php extensions to scan for php coding standards violations.
*
* @var string
*/
protected $phpcsExtensions = 'php,module,inc,install,test,profile,theme';

/**
* The path to the phpcs ruleset to use.
*
* @var string
*/
protected $phpcsRuleset = 'vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml';

/**
* The path to the config dir.
*
Expand Down Expand Up @@ -637,8 +616,7 @@ public function devExportDb($name = 'dump') {
* An optional path to lint.
*/
public function lintPhp($path = '') {
$path = $path ?: $this->phpcsFolders;
$this->_exec("$this->phpcsCmd --report=full --standard=$this->phpcsRuleset --extensions=$this->phpcsExtensions $path");
$this->_exec("$this->phpcsCmd $path");
}

/**
Expand All @@ -648,8 +626,7 @@ public function lintPhp($path = '') {
* An optional path to fix.
*/
public function lintFix($path = '') {
$path = $path ?: $this->phpcsFolders;
$this->_exec("$this->phpcbfCmd --report=full --standard=$this->phpcsRuleset --extensions=$this->phpcsExtensions $path");
$this->_exec("$this->phpcbfCmd $path");
}

/**
Expand Down
26 changes: 26 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="uoa">
<description>Default PHP CodeSniffer configuration for UoA projects.</description>
<!-- folders to scan -->
<file>./web/modules/custom</file>
<file>./web/profiles</file>
<file>./web/themes</file>
<exclude-pattern>*md</exclude-pattern>
<!-- additional arguments -->
<arg name="report" value="full"/>
<!-- inherit from coder -->
<rule ref="./vendor/drupal/coder/coder_sniffer/Drupal"/>
<!-- Additional detailed sniff configuration -->
<!-- You can determine sniff names by running with -s flag -->
<!-- Example 1 - ignore Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
<rule ref="Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps">
<severity>0</severity>
</rule>
// End example 1 -->
<!-- Example 2 - ignore rule for specific files
<rule ref="Drupal.NamingConventions.ValidVariableName.LowerCamelName">
<exclude-pattern>OfferNormalizerTrait.php</exclude-pattern>
<exclude-pattern>TimeOfUseValidationTrait.php</exclude-pattern>
</rule>
// End example 2 -->
</ruleset>
1 change: 1 addition & 0 deletions src/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function updateShepherdScaffoldFiles()
'RoboFile.php',
'drush/config-ignore.yml',
'drush/config-delete.yml',
'phpcs.xml',
]
);
}
Expand Down

0 comments on commit e03c944

Please sign in to comment.