-
Notifications
You must be signed in to change notification settings - Fork 531
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
Add an XML Linter to the project #970
Comments
@vinitamurthi Can I work on the first task? I was thinking of using |
Sure you can work on this. The Android Studio lint command works for every file right? I am worried that lint would end up affecting our kotlin/protobuf files as well |
Another thing to keep in mind is that we need to run the linter on circleCI as well, which will not have android studio installed. Also avoid using gradle linting because we will be switching to bazel soon |
We can manually set up the
|
Okay, let's first verify if it will work as expected for CircleCI as well as on individual machines. One thing to consider is that different people would have different android SDK versions installed so it would be good to verify that the lint tool wouldn't get affected by that. Also, It may be a good idea to look into CircleCI and the configuration we have set up (You can see that here) |
It would be a good idea to write this down into a small design doc, and we can review it before going forward! |
@NullByte08 Any update on this issue? |
@vinitamurthi sorry I was busy in other stuff. If the style guidelines are set then I can run the lint according to that on the codebase and make a pull request to correct the lint errors. Or else, I will check the default lint constraints in android studio and inform you about those. About the circleCI, I have no experience in it so I will read some docs and tutorials and the link you provided to check how we can integrate the I ran the lint before and found these basic errors and warnings and typos: |
I ran the above only on the |
Sounds good, if we can run it on CircleCI then I am totally open to using this. As far as the style guide goes, we have a guide written down here. Is that useful? |
@vinitamurthi Ok I will work on it and update you on the go. |
@vinitamurthi I am unable to take out time to work on the issue so I am currently unassigning myself from this issue. If I get enough time and nobody works on the issue I will work on this issue in the future. |
If anyone wants to check on xmllint how does it works:
|
Keeping here for reference - https://github.com/alexjlockwood/android-lint-checks-demo |
@vinitamurthi Should this issue be blocked on this issue as per the comment - #1742 (comment) ? |
If you mean #1742 be blocked on this issue then yes I think it should be |
@vinitamurthi I am thinking opposite here, if we add Android Lint then we can directly use the lint for lining XML files so, in that way, this issue is blocked till the #1742 gets solved |
I believe this is part of our static analyses GSoC project. @anandwana001 can you confirm? |
Yes, I guess.
I am bit worry on this here, as this is something which require Bazel support, and not be done using Gradle, is it ok under the project timeline? @BenHenning |
That's fair @anandwana001. I think the main requirements that need to be met here are:
Am I missing anything? Correctly formatted example (from home_fragment.xml): <?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="org.oppia.android.R" />
<variable
name="viewModel"
type="org.oppia.android.app.home.HomeViewModel" />
</data>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:gravity="center">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:overScrollMode="never"
android:paddingTop="36dp"
android:paddingBottom="148dp"
android:scrollbars="none"
app:data="@{viewModel.homeItemViewModelListLiveData}" />
<View
android:layout_width="match_parent"
android:layout_height="6dp"
android:background="@drawable/toolbar_drop_shadow" />
</FrameLayout>
</layout> |
Our project has a lot of XML files that describe the look and feel of the application. We would like to add a linter that ensures all the XML files follow the same style.
Xmllint seems to be a good fit for us and we would like to use that for our XML files. If you have recommendations for some other linter, please reach out to me to discuss if its a viable option before using it for the project.
Steps that need to be completed to add the linter:
Run the linter on our existing XML files. Create a PR that fixes all lint problems that the linter catches
Add steps in the linter job of our CircleCI workflow (similar to the Kotlin linting step) that will install and run the linter on our XML files
Verify that the Android Studio auto-formatter is using the same rules as the linter configuration. If not, make changes to the code style of the XML files in Android Studio (that will create changes to the files present in the .idea/codeStyles/ directory). Create a PR that checks in the changes in these files.
Add documentation on how to install the linter in the prerequisites section of our wiki
The text was updated successfully, but these errors were encountered: