False positive for java:S1172 in a graphQL Api service

Make sure to read this post before raising a thread here:

Then tell us:

  • What language is this for?
  • Which rule?
  • Why do you believe it’s a false-positive/false-negative?
    It is a graphQL specification to pass the parent object of the child object which is getting resolved and hence not an unused parameter.
  • Are you using =>
    SonarLint SonarSource within IntelliJ 2022.3.1 (Ultimate version)
  • How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
     * Do NOT remove the Author author parameter as it is required for graphql resolver
     * It is a graphQL specification to pass the parent object of the child object which is getting resolved.
     * Author is the parent.
     * @param author
     * @param env
     * @return AuthorProfile
    public AuthorProfile profile(final Author author, final DataFetchingEnvironment env) {

        return authorService.getAuthorProfile(env);


To be able to reproduce this problem I have to give you the repo :wink: .

Hi Liliane,

Welcome to the community, and thanks for reporting!

Just to give us some context: was this code generated by a tool from a GraphQL API specification? Or the other way: you wrote it manually, and the purpose is further processing by GraphQL tools, e.g., to generate client/server stubs, documentation et c.?

Anyway, since the need for the additional parameters comes from outside Java and outside your code, we have no chance to recognize that there’s a special semantic here and that the rule should not be applied. The only thing you can do is to suppress the rule for the respective methods, classes or files. In case this is generated code, it should not be checked anyway, because you have no control over it.

The rule can be turned off via @SuppressWarnings("java:S1172") at the method or class level. In case you need some more information, you can find it in our SonarQube Docs → Turning issues off.

Yes i wrote it manually and indeed the purpose is to parse the objects.
I did solve it by using the SuppressWarnings.
Thank you for responding.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.