Skip to content

Conversation

AronNovak
Copy link

This rule detects when a class uses both a trait A and trait B, where trait A already uses trait B (either directly or transitively).

Features

  • Detects direct redundancy (class uses A and B, A uses B)
  • Detects transitive redundancy (class uses A and C, A uses B, B uses C)
  • Configurable via strictRules.noRedundantTraitUse parameter

Example

trait BarTrait {}
trait FooTrait { use BarTrait; }

class MyClass {
    use FooTrait;
    use BarTrait; // Error: redundant, already included via FooTrait
}

@AronNovak AronNovak changed the title Add NoRedundantTraitUseRule to detect redundant trait usage Add rule to detect redundant trait usage Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant