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

Fix #1735: Add Java Linter to the project #2101

Merged
merged 66 commits into from
Feb 10, 2021

Conversation

anandwana001
Copy link
Contributor

@anandwana001 anandwana001 commented Nov 10, 2020

Explanation

Fix #1735

For Reviewers

  1. Download .jar file from here - https://github.com/checkstyle/checkstyle/releases/download/checkstyle-8.37/checkstyle-8.37-all.jar
  2. Open terminal
  3. Move to the path where the .jar file is located.
  4. Run the command 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.

Screenshot 2020-11-11 at 08 24 00

Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The PR explanation includes the words "Fixes #bugnum: ..." (or "Fixes part of #bugnum" if the PR only partially fixes an issue).
  • The PR follows the style guide.
  • The PR does not contain any unnecessary auto-generated code from Android Studio.
  • The PR is made from a branch that's not called "develop".
  • The PR is made from a branch that is up-to-date with "develop".
  • The PR's branch is based on "develop" and not on any other branch.
  • The PR is assigned to an appropriate reviewer in both the Assignees and the Reviewers sections.

@anandwana001 anandwana001 marked this pull request as draft November 10, 2020 10:07
checkstyle.xml Outdated Show resolved Hide resolved
@anandwana001 anandwana001 marked this pull request as ready for review November 11, 2020 02:46
.github/workflows/main.yml Outdated Show resolved Hide resolved
.github/workflows/main.yml Outdated Show resolved Hide resolved
checkstyle.xml Outdated
Comment on lines 6 to 17
<!--
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.
-->
Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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).

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it fails correctly.

Copy link
Contributor Author

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.

Copy link
Member

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"/>
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@rt4914 rt4914 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rt4914 rt4914 removed their assignment Nov 12, 2020
Copy link
Member

@BenHenning BenHenning left a 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.

@BenHenning BenHenning enabled auto-merge (squash) February 10, 2021 02:01
@BenHenning BenHenning merged commit f950016 into oppia:develop Feb 10, 2021
@Pranav-Bobde
Copy link
Contributor

Pranav-Bobde commented Mar 25, 2021

error
image
image

Can anyone help me resolve this error...Please!

@anandwana001
Copy link
Contributor Author

@anandwana001
Copy link
Contributor Author

Let me know, if you follow the installation steps correctly - https://github.com/oppia/oppia-android/wiki#installation

@Pranav-Bobde
Copy link
Contributor

@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.

@anandwana001
Copy link
Contributor Author

Could you check the google_checks.xml file is correct and only the required file presented in the system, not the other version of this file in the system?

@Pranav-Bobde
Copy link
Contributor

image
yup just one google_checks.xml here

@FareesHussain
Copy link
Contributor

@Pranav-Bobde can you delete the current google_check.xml and add this file
https://github.com/checkstyle/checkstyle/blob/14005e371803bd52dff429904b354dc3e72638c0/src/main/resources/google_checks.xml

it is supposed to be 17KB size here

@anandwana001
Copy link
Contributor Author

@FareesHussain We had faced this issue earlier, could you confirm is the correct file of 18KB?

@FareesHussain
Copy link
Contributor

The correct files is of 17KB

@Pranav-Bobde
Copy link
Contributor

@FareesHussain @anandwana001 It's 17.1 Kb only .
image

@anandwana001
Copy link
Contributor Author

@Pranav-Bobde Could we confirm it's the same file from that particular we had mentioned in the link?
https://github.com/checkstyle/checkstyle/blob/14005e371803bd52dff429904b354dc3e72638c0/src/main/resources/google_checks.xml

@Pranav-Bobde
Copy link
Contributor

@anandwana001

  1. Gone to the link
    1image
  2. Gone to code and downloaded zip
    image
  3. Extracted & Pasted the file in the Git Directory
    image

@FareesHussain
Copy link
Contributor

can you try be deleting and adding the new one

@FareesHussain
Copy link
Contributor

In my case, the file is 17.4KB

@Pranav-Bobde
Copy link
Contributor

@FareesHussain
Deleted and added. Nothing Changed.

@Pranav-Bobde
Copy link
Contributor

@FareesHussain @anandwana001
Would you like to anydesk with me?

@anandwana001
Copy link
Contributor Author

anandwana001 commented Mar 25, 2021

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.

@FareesHussain
Copy link
Contributor

@anandwana001
Copy link
Contributor Author

Or you can simply right click on raw button and download the file.

@Pranav-Bobde
Copy link
Contributor

@anandwana001 @FareesHussain
Ok. It's working . I just copied the content and made a xml file from sublime.
TYSM for your help. Really Appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Java Linter to the project
9 participants