robolectric
robolectric copied to clipboard
[Warning] Eliminated AnnotateFormatMethod warnings
Overview
Eliminated the AnnotateFormatMethod across the entire project.
Proposed Changes
Added the changes in the following files to fix the error-prone warning
@hellosagar Look like new commit to applying google java format generates a reasonable change lines, instead of previous multi thousands lines.
@hellosagar Look like new commit to applying google java format generates a reasonable change lines, instead of previous multi thousands lines.
Yes :)
There are some formats don't look great, although it has passed checking. And I have wrote some comments for some wrong formats, I think.
um.. lme check that locally on my system
@utzcoz you are right, I little surprised how it passed in the CI but mainly AttributeResolution10.java contains a lot of weird indentation, Ive reformat it locally, pushing it again
Why formatted change lines increase a lot again?
Why formatted change lines increase a lot again?
because I open that file and pressed the cmd + ctrl + L
which performed the google style format as I've their plugin installed.
TDLR: Used the plugin to reformat the file according to the standards
![Screenshot 2022-06-11 at 10 00 10 PM](https://user-images.githubusercontent.com/50016799/173196537-c74c4bb1-64fd-45f1-932c-b302d69316d0.png)
It's not recommend to add not related formatted lines. Could you format with command in wiki? We just need add formatted lines that affected by this PR.
Okay, lme undo this
pushed again according to the wiki, but in that ALGOI
method has a weird indentation
Could you fix them manually one by one and check locally whether they can pass google format checking?
Could you fix them manually one by one and check locally whether they can pass google format checking?
I tried it first before pushing 😅, but it shows a google format error.
Okay, I will check and verify it tomorrow.
After manually, changing the indentation for ALGOI
, this log is generated
❯ /bin/zsh /Users/sagarkhurana/checkJavaFormat.sh
Please run google-java-format on the changes in this pull request
--- resources/src/main/java/org/robolectric/res/android/AttributeResolution10.java (before formatting)
+++ resources/src/main/java/org/robolectric/res/android/AttributeResolution10.java (after formatting)
@@ -94,9 +94,9 @@
int src_values_length, int[] attrs,
int attrs_length, int[] out_values, int[] out_indices) {
if (kDebugStyles) {
- ALOGI(
- "APPLY STYLE: theme=0x%s defStyleAttr=0x%x defStyleRes=0x%x",
- theme, def_style_attr, def_style_res);
+ ALOGI(
+ "APPLY STYLE: theme=0x%s defStyleAttr=0x%x defStyleRes=0x%x",
+ theme, def_style_attr, def_style_res);
}
CppAssetManager2 assetmanager = theme.GetAssetManager();
@@ -160,7 +160,7 @@
type_set_flags = def_style_flags.get();
value = entry.value;
if (kDebugStyles) {
- ALOGI("-> From def style: type=0x%x, data=0x%08x", value.dataType, value.data);
+ ALOGI("-> From def style: type=0x%x, data=0x%08x", value.dataType, value.data);
}
}
}
@@ -193,7 +193,7 @@
cookie = new_cookie;
}
if (kDebugStyles) {
- ALOGI("-> Resolved theme: type=0x%x, data=0x%08x", value.dataType, value.data);
+ ALOGI("-> Resolved theme: type=0x%x, data=0x%08x", value.dataType, value.data);
}
}
}
@@ -333,7 +333,7 @@
xml_parser.getAttributeValue(xml_attr_idx, value);
type_set_flags.set(style_flags.get());
if (kDebugStyles) {
- ALOGI("-> From XML: type=0x%x, data=0x%08x", value.get().dataType, value.get().data);
+ ALOGI("-> From XML: type=0x%x, data=0x%08x", value.get().dataType, value.get().data);
}
}
@@ -347,9 +347,9 @@
value.set(entry.value);
source_style_resid = entry.style;
if (kDebugStyles) {
- ALOGI(
- "-> From style: type=0x%x, data=0x%08x, style=0x%08x",
- value.get().dataType, value.get().data, entry.style);
+ ALOGI(
+ "-> From style: type=0x%x, data=0x%08x, style=0x%08x",
+ value.get().dataType, value.get().data, entry.style);
}
}
}
@@ -364,9 +364,9 @@
value.set(entry.value);
if (kDebugStyles) {
- ALOGI(
- "-> From def style: type=0x%x, data=0x%08x, style=0x%08x",
- value.get().dataType, value.get().data, entry.style);
+ ALOGI(
+ "-> From def style: type=0x%x, data=0x%08x, style=0x%08x",
+ value.get().dataType, value.get().data, entry.style);
}
source_style_resid = entry.style;
}
@@ -382,14 +382,14 @@
}
if (kDebugStyles) {
- ALOGI("-> Resolved attr: type=0x%x, data=0x%08x", value.get().dataType, value.get().data);
+ ALOGI("-> Resolved attr: type=0x%x, data=0x%08x", value.get().dataType, value.get().data);
}
} else if (value.get().data != Res_value.DATA_NULL_EMPTY) {
// If we still don't have a value for this attribute, try to find it in the theme!
ApkAssetsCookie new_cookie = theme.GetAttribute(cur_ident, value, type_set_flags);
if (new_cookie.intValue() != kInvalidCookie) {
if (kDebugStyles) {
- ALOGI("-> From theme: type=0x%x, data=0x%08x", value.get().dataType, value.get().data);
+ ALOGI("-> From theme: type=0x%x, data=0x%08x", value.get().dataType, value.get().data);
}
new_cookie =
assetmanager.ResolveReference(new_cookie, value, config, type_set_flags, resid);
@@ -398,9 +398,9 @@
}
if (kDebugStyles) {
- ALOGI(
- "-> Resolved theme: type=0x%x, data=0x%08x",
- value.get().dataType, value.get().data);
+ ALOGI(
+ "-> Resolved theme: type=0x%x, data=0x%08x",
+ value.get().dataType, value.get().data);
}
}
}
@@ -415,9 +415,9 @@
}
if (kDebugStyles) {
- ALOGI(
- "Attribute 0x%08x: type=0x%x, data=0x%08x",
- cur_ident, value.get().dataType, value.get().data);
+ ALOGI(
+ "Attribute 0x%08x: type=0x%x, data=0x%08x",
+ cur_ident, value.get().dataType, value.get().data);
}
// Write the final value back to Java.
@hellosagar could you rebase and squash commits for this PR? I think wrong formatting are generated by wrong HEAD when using google-java-format locally. We have analyzed this problem before. Maybe you can get correct code formatting after rebasing, squashing, and running google-java-format with correct command locally again.
I've ran the formatting locally and pushed it again
@utzcoz any update after I pushed the new commit?
@hellosagar Please fix incorrect format problem and rebase it to latest master.
:integration_tests:androidx_test:connectedDebugAndroidTest
test is even failing in master as well
Below is the log generated from master
branch
@utzcoz I've added a separate commit for easy review, later I'll squash it. Please have a look at it
@utzcoz I've added a separate commit for easy review, later I'll squash it. Please have a look at it
You can squash it. Hi @hoisie What about skipping format error for this special case?
Squashed :)
@hellosagar Could you enable kDebugStringPoolNoisy
and build and run tests locally to check whether your changes can work without error? The default value of kDebugStringPoolNoisy
is false, and I think current CI will not run into some code you modified.
Locally all checks are passing, without enabling the kDebugStringPoolNoisy
in ResTable
and ResXMLParser
and this is the output after enabling the kDebugStringPoolNoisy
in ResTable
and ResXMLParser
Hi @hoisie , because there are strange code formatting generated by google-java-format, so I leave format checking error here, and merge this PR firstly.