So,
I really have no idea where to ask this. StackOverflow is well, stack overflow, and GitHub is for actual issues. But I have wider ranges of curiosities and interests. I don't just think about the how, or what, I often times question the root origin of WHY.
Take for example the IComparable<T> interface in C#. It is a simpye designed interface allowing any object to write a comparison method for future evaluations.
The concept of an interface is such that the consuming code does not need to know or care about the implementation of the process only that, the calling convention follows a standard.
IComparable<T> has a single method: CompareTo.
Yet, SonarLint/Qube seem to suggest that by
just implementing the IComparable<T> interface this is somehow non-compliant code.
RSPEC-1210Who made the final word on that? No, seriously, I want to know? Where is it defined ANYWHERE that IComparable<T> implementation should also include the Equals() override, and the static operator overrides for ==, !=, <, > <=, and >=? Not to mention the
RSPEC-3875 rule which complains about overriding the == operand to begin with. Catch-22 there.
IComparable<T> is an interface that "Compares" the implementing object to an object of type T. There is no rule or requirement that says the "CompareTo" operation must abide by the same rules as the == operator or Equals(object) method. There is no rule that the generic T type parameter must be the same time as the class implementing IComparable<T>. I can have class Foo implement IComparable<Bar> and that is not non-compliant. That is what the generics and interfaces are for.
To be frank, actually, there is a rule: It's called IComparable<T> does NOT have a member called Equals(object). Which means, compliant implementation of IComparable<T> has nothing to do with the Equals() method, or the operator overrides.
I get the rules that say: this variable is unused. This assignment to this variable is unnecessary. But these "Compliant" and "Non-Compliant' determinations are arbitrary, and 100% opinion based. So, who, where, what is the group that manufactures these arbitrary "Compliance" determinations?
Regards
Jaeden "Sifo Dyas" al'Raec Ruiner