-
Notifications
You must be signed in to change notification settings - Fork 528
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
Fix #1735: Add Java Linter to the project #2101
Fix #1735: Add Java Linter to the project #2101
Conversation
app/src/main/java/org/oppia/android/app/databinding/ImageViewBindingAdapters.java
Show resolved
Hide resolved
checkstyle.xml
Outdated
<!-- | ||
Checkstyle configuration that checks the Google coding conventions from Google Java Style | ||
that can be found at https://google.github.io/styleguide/javaguide.html | ||
|
||
Checkstyle is very configurable. Be sure to read the documentation at | ||
http://checkstyle.org (or in your downloaded distribution). | ||
|
||
To completely disable a check, just comment it out or delete it from the file. | ||
To suppress certain violations please review suppression filters. | ||
|
||
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov. | ||
--> |
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.
I am a bit conflicted about this comment. I understand we have picked up the google style xml file but should we be adding their comment or should we add our own and mention that we have picked it up from this particular xml file and reference it? @seanlip can you comment on this - this is more of a open source question?
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.
Could you or @anandwana001 please point me to the repo where this code snippet was taken from, and link to the original file from which these lines were taken? I think I need that info in order to weigh in.
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.
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.
OK, I did some reading and I think it would be better not to include an LGPL file as part of an Apache repo. Can you write a custom XML checkstyle for Oppia Android rather than using the default?
Also, in general, please never submit any code that's copied verbatim from other places to this repo. All code submitted in PRs must be original (including XML files).
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.
@seanlip This checkstyle file (Google Java Style Guide) is something we need to follow as per Ben's comment - #1735 (comment)
If I create a custom, all I could do is remove comments, else all properties will remain the same as we want the same style to follow.
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 to check, have you confirmed that this correctly fails in CI with missing Java style issues checked in?
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.
@anandwana001 can you confirm this?
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.
yes, it fails correctly.
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.
ah, corrected, I was using sh earlier. fixed it now.
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.
Thanks for checking!
checkstyle.xml
Outdated
|
||
<property name="severity" value="error"/> | ||
|
||
<property name="fileExtensions" value="java, properties, xml"/> |
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.
Does this checker even do XML layout files?
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.
It doesn't work with Android XML layout file.
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.
PTAL @anandwana001
app/src/main/java/org/oppia/android/app/databinding/ViewBindingAdapters.java
Outdated
Show resolved
Hide resolved
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.
Thanks @anandwana001! PR LGTM. Looks like the CI failure is a flake. Re-running tests.
@Pranav-Bobde Have you used the correct xml file - https://github.com/checkstyle/checkstyle/blob/14005e371803bd52dff429904b354dc3e72638c0/src/main/resources/google_checks.xml ? |
Let me know, if you follow the installation steps correctly - https://github.com/oppia/oppia-android/wiki#installation |
@anandwana001 Yes, I have used the correct file and followed correct steps. In fact, i've deleted, re-forked and done all steps more than 4-5 times now. |
Could you check the |
@Pranav-Bobde can you delete the current google_check.xml and add this file it is supposed to be 17KB size here |
@FareesHussain We had faced this issue earlier, could you confirm is the correct file of 18KB? |
The correct files is of 17KB |
@FareesHussain @anandwana001 It's 17.1 Kb only . |
@Pranav-Bobde Could we confirm it's the same file from that particular we had mentioned in the link? |
can you try be deleting and adding the new one |
In my case, the file is 17.4KB |
@FareesHussain |
@FareesHussain @anandwana001 |
The issue is, you are downloading code and using the file from maste branch, not from that particular commit we had mentioned in the link. |
To download open this link https://raw.githubusercontent.com/checkstyle/checkstyle/14005e371803bd52dff429904b354dc3e72638c0/src/main/resources/google_checks.xml and CTRL + D to download the file |
Or you can simply right click on raw button and download the file. |
@anandwana001 @FareesHussain |
Explanation
Fix #1735
For Reviewers
.jar
file is located.java -jar checkstyle-8.37-all.jar -c=checkstyle.xml /ABSOLUTE_PATH_TO_OPPIA_ANDROID/app/src/ /ABSOLUTE_PATH_TO_OPPIA_ANDROID/data/src/ /ABSOLUTE_PATH_TO_OPPIA_ANDROID/domain/src/ /ABSOLUTE_PATH_TO_OPPIA_ANDROID/utility/src/ /ABSOLUTE_PATH_TO_OPPIA_ANDROID/testing/src/
Once this PR gets merge, I will add a new guide page in our wiki.
Checklist