scapegoat icon indicating copy to clipboard operation
scapegoat copied to clipboard

Suggested rule: require override

Open dhorkin opened this issue 5 years ago • 4 comments

Suppose you have

trait FooTrait {
    def bar(): Unit
}

class Foo extends FooTrait {
    def bar() = {  }
}

Under this new rule, the above would give an error, but the below would pass

class Foo extends FooTrait {
    override def bar() = {  }
}

dhorkin avatar Jun 03 '20 05:06 dhorkin

I'd really like to have that rule but I'm not sure if it can be done using scapegoat.

xplosunn avatar Oct 03 '20 07:10 xplosunn

I think this is the article by @nrinaudo on the same topic: https://nrinaudo.github.io/scala-best-practices/oop/always_override.html

mccartney avatar Oct 04 '20 20:10 mccartney

I'd personally love to have this, but it's important to realise it's a controversial stance. Many people told me to never use override unless it'd result in a compilation error.

nrinaudo avatar Oct 05 '20 21:10 nrinaudo

Understood. Thanks for chipping in! I think we can implement that and if someone is against it, they can disable the rule. I bet we have other controversial rules already.

mccartney avatar Oct 06 '20 06:10 mccartney