Skip to content

test(generator): add unit goldens for resumable upload stubs, client, and settings - #14323

Draft
whowes wants to merge 1 commit into
whowes/generator-transport-stub-delegationfrom
whowes/generator-resumable-upload-goldens
Draft

test(generator): add unit goldens for resumable upload stubs, client, and settings#14323
whowes wants to merge 1 commit into
whowes/generator-transport-stub-delegationfrom
whowes/generator-resumable-upload-goldens

Conversation

@whowes

@whowes whowes commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Work in progress, not yet ready for review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces tests and golden files for the new Resumable Upload feature in both gRPC and REST (HttpJson) stub and client generators. The review feedback highlights several code quality and efficiency issues in the generated golden files that should be addressed in the generator. These include double-escaped HTML tags in Javadocs, unused ProtoRestSerializer variables, inefficient empty collection instantiations, and split variable declarations.

/**
* REST stub transport for the resumable upload methods of ResumableUploadService.
*
* <p>&lt;p&gt;This class is for advanced usage and reflects the underlying API directly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The generated Javadoc contains a double-escaped paragraph tag: <p>&lt;p&gt;. This causes the literal text <p> to be rendered in the Javadoc HTML. The generator should be updated to produce a single, clean <p> tag (similar to the gRPC stub Javadoc generation).

 * <p>This class is for advanced usage and reflects the underlying API directly.

Comment on lines +49 to +52
Map<String, String> fields = new HashMap<>();
ProtoRestSerializer<UploadMediaRequest> serializer =
ProtoRestSerializer.create();
return fields;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The serializer variable is instantiated but never used because there are no path parameters to serialize in this request formatter. The generator should be updated to omit generating the ProtoRestSerializer instantiation when it is not used, avoiding unused variable warnings and unnecessary object allocation.

                            Map<String, String> fields = new HashMap<>();
                            return fields;

Comment on lines +56 to +59
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<UploadMediaRequest> serializer =
ProtoRestSerializer.create();
return fields;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The serializer variable is instantiated but never used because there are no query parameters to serialize in this query params extractor. The generator should be updated to omit generating the ProtoRestSerializer instantiation when it is not used, avoiding unused variable warnings and unnecessary object allocation.

                            Map<String, List<String>> fields = new HashMap<>();
                            return fields;

static {
ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
ImmutableMap.builder();
definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()) to define an empty set is inefficient and verbose. The generator should be updated to output ImmutableSet.of() instead.

      definitions.put("no_retry_codes", ImmutableSet.of());

Comment on lines +206 to +207
RetrySettings settings = null;
settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The generated code declares RetrySettings settings = null; and then immediately assigns a value to it on the next line. The generator should be updated to combine these into a single statement to improve readability and code quality.

      RetrySettings settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build();

Comment on lines +85 to +87
List<ApiMethodDescriptor> methodDescriptors = new ArrayList<>();
return methodDescriptors;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Instantiating a new ArrayList just to return it empty is inefficient. The generator should be updated to return an immutable empty list, such as java.util.Collections.emptyList(), when there are no method descriptors.

  public static List<ApiMethodDescriptor> getMethodDescriptors() {
    return java.util.Collections.emptyList();
  }

@whowes
whowes added this pull request to stack #14327 September 9, 2026 06:35
@sonarqubecloud

sonarqubecloud Bot commented Sep 9, 2026

Copy link
Copy Markdown

@sonarqubecloud

sonarqubecloud Bot commented Sep 9, 2026

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