-
Notifications
You must be signed in to change notification settings - Fork 38.4k
remove UnusedLocalVariable
#34489
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
base: main
Are you sure you want to change the base?
remove UnusedLocalVariable
#34489
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
root = true | ||
|
||
[*.{adoc,bat,groovy,html,java,js,jsp,kt,kts,md,properties,py,rb,sh,sql,svg,txt,xml,xsd}] | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
# indent_style = tab todo: verify | ||
insert_final_newline = true | ||
|
||
[*.{groovy,java,kt,kts,xml,xsd}] | ||
indent_style = tab | ||
indent_size = 4 | ||
continuation_indent_size = 8 | ||
end_of_line = lf | ||
ij_continuation_indent_size = 8 | ||
|
||
[*.java] | ||
ij_java_class_count_to_use_import_on_demand = 999 | ||
ij_java_names_count_to_use_import_on_demand = 999 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,25 +16,19 @@ | |
|
||
package org.springframework.aot.test; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
/** | ||
* @author Brian Clozel | ||
* @since 6.0 | ||
*/ | ||
public class SampleReflection { | ||
|
||
@SuppressWarnings("unused") | ||
public void sample() { | ||
String value = "Sample"; | ||
Method[] methods = String.class.getMethods(); | ||
String.class.getMethods(); | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public void multipleCalls() { | ||
String value = "Sample"; | ||
Method[] methods = String.class.getMethods(); | ||
methods = Integer.class.getMethods(); | ||
String.class.getMethods(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure if the test is still working as expected, as I could not execute it locally. |
||
Integer.class.getMethods(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7145,8 +7145,7 @@ public TestClass9(int i) { | |
static class HttpServlet3RequestFactory { | ||
|
||
static Servlet3SecurityContextHolderAwareRequestWrapper getOne() { | ||
HttpServlet3RequestFactory outer = new HttpServlet3RequestFactory(); | ||
return outer.new Servlet3SecurityContextHolderAwareRequestWrapper(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. possible false positive on UnusedLocalVariable checkstyle/checkstyle#16419 |
||
return new HttpServlet3RequestFactory().new Servlet3SecurityContextHolderAwareRequestWrapper(); | ||
} | ||
|
||
// private class Servlet3SecurityContextHolderAwareRequestWrapper extends SecurityContextHolderAwareRequestWrapper | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,10 +70,9 @@ public void performGet() { | |
String responseBody = "{\"name\" : \"Ludwig van Beethoven\", \"someDouble\" : \"1.6035\"}"; | ||
|
||
this.mockServer.expect(requestTo("/composers/42")).andExpect(method(HttpMethod.GET)) | ||
.andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON)); | ||
.andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON)); | ||
|
||
@SuppressWarnings("unused") | ||
Person ludwig = this.restTemplate.getForObject("/composers/{id}", Person.class, 42); | ||
this.restTemplate.getForObject("/composers/{id}", Person.class, 42); | ||
|
||
// We are only validating the request. The response is mocked out. | ||
// hotel.getId() == 42 | ||
|
@@ -90,8 +89,7 @@ public void performGetManyTimes() { | |
this.mockServer.expect(manyTimes(), requestTo("/composers/42")).andExpect(method(HttpMethod.GET)) | ||
.andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON)); | ||
|
||
@SuppressWarnings("unused") | ||
Person ludwig = this.restTemplate.getForObject("/composers/{id}", Person.class, 42); | ||
this.restTemplate.getForObject("/composers/{id}", Person.class, 42); | ||
|
||
// We are only validating the request. The response is mocked out. | ||
// hotel.getId() == 42 | ||
|
@@ -142,8 +140,7 @@ public void performGetWithResponseBodyFromFile() { | |
this.mockServer.expect(requestTo("/composers/42")).andExpect(method(HttpMethod.GET)) | ||
.andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON)); | ||
|
||
@SuppressWarnings("unused") | ||
Person ludwig = this.restTemplate.getForObject("/composers/{id}", Person.class, 42); | ||
this.restTemplate.getForObject("/composers/{id}", Person.class, 42); | ||
|
||
// hotel.getId() == 42 | ||
// hotel.getName().equals("Holiday Inn") | ||
|
@@ -155,24 +152,19 @@ public void performGetWithResponseBodyFromFile() { | |
public void verify() { | ||
|
||
this.mockServer.expect(requestTo("/number")).andExpect(method(HttpMethod.GET)) | ||
.andRespond(withSuccess("1", MediaType.TEXT_PLAIN)); | ||
.andRespond(withSuccess("1", MediaType.TEXT_PLAIN)); | ||
|
||
this.mockServer.expect(requestTo("/number")).andExpect(method(HttpMethod.GET)) | ||
.andRespond(withSuccess("2", MediaType.TEXT_PLAIN)); | ||
.andRespond(withSuccess("2", MediaType.TEXT_PLAIN)); | ||
|
||
this.mockServer.expect(requestTo("/number")).andExpect(method(HttpMethod.GET)) | ||
.andRespond(withSuccess("4", MediaType.TEXT_PLAIN)); | ||
.andRespond(withSuccess("4", MediaType.TEXT_PLAIN)); | ||
|
||
this.mockServer.expect(requestTo("/number")).andExpect(method(HttpMethod.GET)) | ||
.andRespond(withSuccess("8", MediaType.TEXT_PLAIN)); | ||
|
||
@SuppressWarnings("unused") | ||
String result1 = this.restTemplate.getForObject("/number", String.class); | ||
// result1 == "1" | ||
.andRespond(withSuccess("8", MediaType.TEXT_PLAIN)); | ||
|
||
@SuppressWarnings("unused") | ||
String result2 = this.restTemplate.getForObject("/number", String.class); | ||
// result == "2" | ||
assertThat(this.restTemplate.getForObject("/number", String.class)).isEqualTo("1"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is some real benefit, imho. Testing the real assertion rather commenting about it |
||
assertThat(this.restTemplate.getForObject("/number", String.class)).isEqualTo("2"); | ||
|
||
try { | ||
this.mockServer.verify(); | ||
|
@@ -215,7 +207,7 @@ private ContentInterceptor(Resource resource) { | |
|
||
@Override | ||
public ClientHttpResponse intercept(HttpRequest request, byte[] body, | ||
ClientHttpRequestExecution execution) throws IOException { | ||
ClientHttpRequestExecution execution) throws IOException { | ||
|
||
ClientHttpResponse response = execution.execute(request, body); | ||
byte[] expected = FileCopyUtils.copyToByteArray(this.resource.getInputStream()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for clarification, is the intent to not make this the default?
I have never seen it otherwise, only globally, with the most common encoding being UTF-8.
This is new to me—my previous knowledge was that properties files were the only files not normally encoded in UTF-8, but now even they have switched.