Skip to content

Commit b437eb3

Browse files
authored
Merge pull request #34 from DealerDirect/hotfix/change-installed-paths-behavior
Fixes #33. Changes the way the installed_paths are set.
2 parents 0abc65e + 5e1bf1e commit b437eb3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Plugin.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -286,24 +286,25 @@ private function updateInstalledPaths()
286286
->in($searchPaths);
287287

288288
// Only version 3.x and higher has support for having coding standard in the root of the directory.
289-
$allowCodingStandardsInRoot = $this->isPHPCodeSnifferInstalled('>= 3.0.0');
290-
291-
if ($allowCodingStandardsInRoot !== true) {
289+
if ($this->isPHPCodeSnifferInstalled('>= 3.0.0') !== true) {
292290
$finder->depth('>= 1');
293291
}
294292

293+
// Process each found possible ruleset.
295294
foreach ($finder as $ruleset) {
296295
$standardsPath = $ruleset->getPath();
297296

298-
if ($allowCodingStandardsInRoot === false) {
297+
// Pick the directory above the directory containing the standard, unless this is the project root.
298+
if ($standardsPath !== getcwd()) {
299299
$standardsPath = dirname($standardsPath);
300300
}
301301

302-
// Use relative paths for local project repositories
302+
// Use relative paths for local project repositories.
303303
if ($this->isRunningGlobally() === false) {
304304
$standardsPath = $this->getRelativePath($standardsPath);
305305
}
306306

307+
// De-duplicate and add when directory is not configured.
307308
if (in_array($standardsPath, $this->installedPaths, true) === false) {
308309
$this->installedPaths[] = $standardsPath;
309310
$changes = true;

0 commit comments

Comments
 (0)