Conversation
1a75e68 to
b6c30f1
Compare
dorian-burihabwa-sonarsource
left a comment
There was a problem hiding this comment.
I think the change looks simple enough to integrated as-is, but there are a couple of questions I have left for you to look at.
In addition, I thin that he ticket attached to this PR should be a SONARJAVA ticket because this change implies a modification of the public API and should be properly documented as part of the release
b223127 to
c20a76d
Compare
|
|
I think what bothers me most is the need to test an empty method and the lack of guidance for what a good implementation of After discussing with @kaufco, it looks like we have 2 options to improve the current proposal.
My preference goes for option 2 because it enables us to write a test where we can implement a child class and test what the default behavior is. @Test
void registerCustomFileScanner_default_implementation_returns_expected_value() {
class Child extends CheckRegistrar.RegistrarContext {
// Nothing overridden here
}
var context = new Child();
assertThat(context.registerCustomFileScanner(null, null)).isEqualTo(EXPECTED_VALUE);
} |
c20a76d to
e486513
Compare
e486513 to
e3731be
Compare
|
leonardo-pilastri-sonarsource
left a comment
There was a problem hiding this comment.
LGTM, let's just change the test in SonarComponents to an end-to-end check that the scanner is actually invoked when registered through the new API
dorian-burihabwa-sonarsource
left a comment
There was a problem hiding this comment.
Thanks for coming back to this. I just left a question about the Javadoc and a small typo
| * Registers a custom file scanner not related to any rule or repository. | ||
| * CheckRegistrars call this function to register a custom file scanner for execution during the analysis | ||
| * on all source files that match the given rule scope (MAIN, TEST or ALL). | ||
| * Custom file scanners reporting an issue will have no effect, since no rule is associated. |
There was a problem hiding this comment.
will have no effect: meaning that it is safe to report and not trigger any issue at runtime?
There was a problem hiding this comment.
Exactly. There's also a test for this. Reason: there was a null check somewhere in the implementation chain of reportIssue / addIssue (I don't remember in which class/function exactly) triggering the underlying low-level function only if ruleKey != null, doing nothing otherwise.
| JavaFileScanner customScanner = scannerContext -> { | ||
| // empty | ||
| }; | ||
| CheckRegistrar registrar =registrarContext -> |
There was a problem hiding this comment.
| CheckRegistrar registrar =registrarContext -> | |
| CheckRegistrar registrar = registrarContext -> |
|




SONARCH-708