github-api icon indicating copy to clipboard operation
github-api copied to clipboard

Add check that verifies public or protected methods do not take private or internal parameters

Open bitwiseman opened this issue 4 years ago • 2 comments

#1015 fixed an issue where a public annotation had a public constructor that had a package-private enum parameter. This didn't break immediately, but caused issue for mocking. If it were a more generally used method, that method would be visible but not callable.

We should add an ArchUnit tests that:

  • find all public methods and verifies that all parameters of those method are also public
  • find all protected methods and verify that all parameters of those method are also at least protected - might be harder to write this test
  • find all public classes and verify they extend public classes - this may or may not be strictly required, but it makes for better testing and clarity.

bitwiseman avatar Jan 07 '21 23:01 bitwiseman

Consider https://siom79.github.io/japicmp/ to flag/prevent breaking API changes.

bitwiseman avatar Feb 14 '22 23:02 bitwiseman

JApiCmp added in #1398. This does not address the issue noted in the title. For that we will need a tool like RevApi or might be able to check this kind of problem via ArchUnit since it is not a surface area change problem, but a basic API correctness issue.

bitwiseman avatar Mar 07 '22 19:03 bitwiseman