Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting: keep simple if / else on the same line #51526

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .eclipseformat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
Expand Down Expand Up @@ -101,7 +101,7 @@
<setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
Expand Down Expand Up @@ -286,7 +286,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_tag_description" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="48"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ private static void setupRootJdkDownload(Project rootProject, String platform, S
String[] pathSegments = details.getRelativePath().getSegments();
int index = 0;
for (; index < pathSegments.length; index++) {
if (pathSegments[index].matches("jdk-.*"))
break;
if (pathSegments[index].matches("jdk-.*")) break;
}
assert index + 1 <= pathSegments.length;
String[] newPathSegments = Arrays.copyOfRange(pathSegments, index + 1, pathSegments.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ public Set<Pattern> getTaskNames() {

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TestingConventionRule that = (TestingConventionRule) o;
return Objects.equals(suffix, that.suffix);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ private boolean isChildOfVisitedSymbolicLink(final FileCopyDetailsInternal detai
return false;
}
for (final File symbolicLink : visitedSymbolicLinks) {
if (isChildOf(symbolicLink, file))
return true;
if (isChildOf(symbolicLink, file)) return true;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,8 @@ public String getFullName() {

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Descriptor that = (Descriptor) o;
return Objects.equals(name, that.name) && Objects.equals(className, that.className) && Objects.equals(parent, that.parent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,8 @@ public NamedDomainObjectContainer<ElasticsearchNode> getNodes() {

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ElasticsearchCluster that = (ElasticsearchCluster) o;
return Objects.equals(clusterName, that.clusterName) && Objects.equals(path, that.path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1209,10 +1209,8 @@ void waitForAllConditions() {

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ElasticsearchNode that = (ElasticsearchNode) o;
return Objects.equals(name, that.name) && Objects.equals(path, that.path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ private void writeSourceFile(Project project, String name, String... lines) thro
file.getParentFile().mkdirs();
file.createNewFile();

if (lines.length != 0)
Files.write(file.toPath(), Arrays.asList(lines), StandardCharsets.UTF_8);
if (lines.length != 0) Files.write(file.toPath(), Arrays.asList(lines), StandardCharsets.UTF_8);
}

private void checkAndAssertTaskSuccessful(ForbiddenPatternsTask task) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public Collection<Method> getTestMethods(Class<?> suiteClass, ClassModel classMo
ArrayList<Method> result = new ArrayList<>();
for (MethodModel mm : methods.values()) {
// Skip any methods that have overrieds/ shadows.
if (mm.getDown() != null)
continue;
if (mm.getDown() != null) continue;

Method m = mm.element;
if (m.getName().startsWith("test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
EnrichMetadata that = (EnrichMetadata) o;
return policies.equals(that.policies);
}
Expand Down