Skip to content

Commit f825104

Browse files
committed
feat(linter): add redundancy rules for literal returns and inline variables
- Add `no-redundant-literal-return` rule to detect patterns like `if ($x === null) { return null; } return $x;` - Add `inline-variable-return` rule to detect patterns like `$x = getValue(); return $x;` Signed-off-by: azjezz <[email protected]>
1 parent 5227a25 commit f825104

File tree

6 files changed

+1270
-0
lines changed

6 files changed

+1270
-0
lines changed

crates/linter/src/rule/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ define_rules! {
193193
NoRedundantNullsafe(no_redundant_nullsafe @ NoRedundantNullsafeRule),
194194
NoRedundantMath(no_redundant_math @ NoRedundantMathRule),
195195
NoRedundantLabel(no_redundant_label @ NoRedundantLabelRule),
196+
NoRedundantLiteralReturn(no_redundant_literal_return @ NoRedundantLiteralReturnRule),
196197
NoRedundantFinal(no_redundant_final @ NoRedundantFinalRule),
197198
NoRedundantReadonly(no_redundant_readonly @ NoRedundantReadonlyRule),
198199
NoRedundantFile(no_redundant_file @ NoRedundantFileRule),
@@ -227,6 +228,7 @@ define_rules! {
227228
LowercaseTypeHint(lowercase_type_hint @ LowercaseTypeHintRule),
228229
IdentityComparison(identity_comparison @ IdentityComparisonRule),
229230
IneffectiveFormatIgnoreNext(ineffective_format_ignore_next @ IneffectiveFormatIgnoreNextRule),
231+
InlineVariableReturn(inline_variable_return @ InlineVariableReturnRule),
230232
IneffectiveFormatIgnoreRegion(ineffective_format_ignore_region @ IneffectiveFormatIgnoreRegionRule),
231233
InstanceofStringable(instanceof_stringable @ InstanceofStringableRule),
232234
InterfaceName(interface_name @ InterfaceNameRule),

0 commit comments

Comments
 (0)