Skip to content

Needless parentheses around return #770

Closed

Description

@boris-petrov

Prettier-Java 2.7.4

Playground link

--print-width 55

Input:

public abstract class Foo implements MyInterface {
  @Override public String foo() {
    return (
		true && false && true && false && true
	);
  }
}

Output:

public abstract class Foo implements MyInterface {

	@Override
	public String foo() {
		return (
			true && false && true && false && true
		);
	}
}

Expected behavior:

public abstract class Foo implements MyInterface {

	@Override
	public String foo() {
		return true && false && true && false && true;
	}
}

Note that making print-width 56 leads to a different (and still wrong result):

public abstract class Foo implements MyInterface {

	@Override
	public String foo() {
		return (true && false && true && false && true);
	}
}

In this case, it correctly puts the whole thing on a single line but it doesn't remove the parentheses.

Activity

  1. M-Vimal commented on Sep 21, 2025

    @M-Vimal

    Hi, I’d like to work on this issue. Could you please assign it to me?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions