Skip to content

fix: resolve the open SonarCloud issues - #268

Open
adityamparikh wants to merge 1 commit into
apache:mainfrom
adityamparikh:fix/sonar-issues
Open

adityamparikh wants to merge 1 commit into
apache:mainfrom
adityamparikh:fix/sonar-issues

Conversation

@adityamparikh

@adityamparikh adityamparikh commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #269, #266 and #267: the first three commits here are those PRs, in that order, and only the top commit (fix: resolve the open SonarCloud issues) is new. #269 is underneath so that ./gradlew build runs the new buildSrc test below.

What

Resolves every open issue SonarCloud reports for apache_solr-mcp on main: 44 code smells, no bugs or vulnerabilities. #267 already fixes 5 of them (four unthrown throws Exception clauses and the unused createMockUpdateHandlerData). This PR fixes the other 39. The "new issues" on #264–#267 are a subset of these, flagged because reformatting touched those lines.

Main code

Rule Where Fix
S1118, S1186 SolrNativeHints It was an empty @Configuration whose only job was to import its nested Registrar. The class is now the RuntimeHintsRegistrar itself, and SolrConfig imports it with @ImportRuntimeHints(SolrNativeHints.class). That leaves one bean and one nested class fewer, and the same hints.
S1186 Main, SolrConfig constructors These exist only to carry Javadoc (javadoc warns on an implicit constructor; see #146). The body now says so.
S1186, S108 MarkdownDocumentCreator The empty addImplicitResolvers() override and the case null -> {} branch each get a comment saying why they are empty.
S6213, S9391 MarkdownDocumentCreator The loop with a variable named record is now a stream, and so is the source-span loop.
S9391 JsonDocumentCreator The array loop is now a filter/map stream; isContainer() replaces isObject() || isArray().
S8491 Dtos Javadoc on record components is dangling: the javadoc tool ignores it. The 38 component comments are now @param tags on each record, and the stray file-level comment above SolrMetrics is gone.
S125 CollectionService A comment containing totalTime/requests read as commented-out code; it's reworded.
S3457 CollectionService The prompt's purpose line is now built by concatenation, not "\n...%s\n".formatted(...). The \n is prompt text, so %n would be wrong.
S7467 SolrConfigurationProperties The unused catch parameter is now _.
S1075 SolrConfig NOSONAR, with a comment. The "/" is a URL path separator. The rule's remedy, File.separator, would put a \ into the Solr URL on Windows.
S1874 buildSrc GenerateBinaryLicense CycloneDX 13 deprecates LicenseChoice.getLicenses() and getExpression(), so licenses are now read through getItems(). A new test covers the SPDX-expression branch, which had no test.

Tests

Rule Where Fix
S2699 MainTest.contextLoads It had no assertion. It now asserts that each Solr-calling service in the context is its mock.
S5976, S4144 DistributedTracingTest shouldCreateSpanHierarchy, shouldSetCorrectSpanKind, and shouldIncludeServiceNameInResource had identical bodies that only checked some span exists, which shouldCreateSpanForSearchServiceMethod already does. Their names promised checks SimpleTracer can't make, so they are removed, along with the class Javadoc's hierarchy claim.
S5778 SchemaServiceTest, SearchServiceTest, SearchServiceIntegrationTest, SortClauseTest Arguments are built before assertThrows, so only the call under test can throw.
S2925 DockerImageStdioIntegrationTest Thread.sleep(5000) is now Awaitility's during(5s), which also fails as soon as the container exits.
S1172 ClientHttp main(String[] args) is now static void main(), matching ClientStdio.
S9397 BuildInfoReader, ClientStdio String.format with plain %s slots is now concatenation.

Verification

🤖 Generated with Claude Code

Fixes the code smells SonarCloud reports on main that the nullness
change does not already cover.

- SolrNativeHints is now the RuntimeHintsRegistrar itself, imported by
  SolrConfig, instead of an empty @configuration wrapping a nested
  Registrar.
- Empty bodies say why they are empty; Dtos record components document
  themselves with @PARAM instead of dangling Javadoc.
- buildSrc reads SBOM licenses through LicenseChoice.getItems(), as
  CycloneDX 13 deprecates getLicenses() and getExpression(); a new test
  covers the SPDX-expression branch.
- Tests: MainTest asserts the mocked context, assertThrows lambdas hold
  only the call under test, three DistributedTracingTest duplicates that
  asserted only "some span exists" are removed, and the Docker stdio
  test waits with Awaitility instead of Thread.sleep.
- The one false positive, a '/' URL path separator flagged as a file
  path delimiter, is suppressed in place with the reason.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant