Skip to content

Commit 87a6c1c

Browse files
committed
fix: remove risky own fixers if non-risky is asked
1 parent 206ffee commit 87a6c1c

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

spec/PedroTroller/CS/Fixer/RuleSetFactorySpec.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,24 @@ function it_adds_my_own_fixer_set()
312312

313313
ksort($rules);
314314

315-
$this->pedrotroller()->getRules()->shouldReturn($rules);
315+
$this->pedrotroller(true)->getRules()->shouldReturn($rules);
316+
}
317+
318+
function it_adds_my_own_fixer_set_except_privates()
319+
{
320+
$rules = [];
321+
322+
foreach (new Fixers() as $fixer) {
323+
if ($fixer->isDeprecated() || $fixer->isRisky()) {
324+
continue;
325+
}
326+
327+
$rules[$fixer->getName()] = true;
328+
}
329+
330+
ksort($rules);
331+
332+
$this->pedrotroller(false)->getRules()->shouldReturn($rules);
316333
}
317334

318335
function it_enables_a_rule()

src/PedroTroller/CS/Fixer/RuleSetFactory.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ public function php($version, $risky = false)
144144
switch (true) {
145145
case $version >= 7.1:
146146
$config = array_merge(['list_syntax' => ['syntax' => 'short']], $config);
147+
147148
// no break
148149
case $version >= 5.4:
149150
$config = array_merge(['array_syntax' => ['syntax' => 'short']], $config);
@@ -183,6 +184,10 @@ public function pedrotroller($risky = false)
183184
continue;
184185
}
185186

187+
if (false === $risky && $fixer->isRisky()) {
188+
continue;
189+
}
190+
186191
$rules[$fixer->getName()] = true;
187192
}
188193

0 commit comments

Comments
 (0)