Formatting add redundant whitespaces
Open
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 4.4k
- Forks
- 627
- Avg merge
- 3d 15m
- Merged PRs (30d)
- 20
Description
I'm not sure if this can be considered a bug.
But my idea is to reformat the file after these changes.
I expected only an empty string between string a = 1; string b = 2;, but I actually got an empty string with two whitespaces.
@Test
public void should_format_file_without_empty_line_with_whitespaces() {
// given
var loader = new SchemaLoader(FileSystems.getDefault());
var linker = new Linker(loader, new ErrorCollector(), true, true);
var testFileLocation = Location.get("<TEST_PROTO_FILE>");
loader.initRoots(List.of(testFileLocation), List.of(testFileLocation));
var file = loader.load("test/file.proto");
var schema = linker.link(List.of(file));
// when
var protoFile = schema.protoFile("test/file.proto");
// then
assertThat(protoFile.toSchema())
.isEqualTo("""
// Proto schema formatted by Wire, do not edit.
// Source: test/file.proto
syntax = "proto3";
package test.dependency;
message TestMessage {
message NestedMessage {
string a = 1;
string b = 2;
}
}
""");
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the test shown in the issue, especially SchemaLoader, Linker, and protoFile.toSchema(), and trace how test/file.proto is formatted. Confirm the expected output for empty lines between string a = 1 and string b = 2, then update or add the relevant regression test and verify the generated schema contains no redundant whitespace.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100