gradle-baseline icon indicating copy to clipboard operation
gradle-baseline copied to clipboard

[IllegalSafeLoggingArgument] Prevent subclasses from overriding methods to be less safe

Open ash211 opened this issue 1 year ago • 2 comments

What happened?

While working on another PR, I saw something that was roughly this situation:

interface MyInterface {
  @Safe
  String myMethod();
}

class MyClass implements MyInterface {
  @Unsafe
  String myMethod() {
    return "The secret is 42";
  }
}

(with SafeLoggable and RemoteException)

What did you want to happen?

I would expect IllegalSafeLoggingArgument to throw an error, but it did not.

Next Steps

Should verify what the current behavior is with a test in this repo.

ash211 avatar Nov 07 '23 01:11 ash211

Yes, we should cause compilation to fail in that case, as well as the case where an unmarked class attempts to implement two interfaces with different safety values for a given method -- these examples violate the liskov substitution principle.

carterkozak avatar Nov 09 '23 15:11 carterkozak

https://github.com/palantir/gradle-baseline/pull/2699

carterkozak avatar Jan 08 '24 17:01 carterkozak