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 #3394: Ktlint Custom RuleSet #5558

Closed
wants to merge 9 commits into from
Closed

Conversation

manas-yu
Copy link
Contributor

@manas-yu manas-yu commented Oct 24, 2024

Fix: #3394
This PR introduces two key features:

  • Custom Ruleset Provider: A new custom ruleset provider is implemented, allowing the integration of custom Ktlint rules.

  • KDocFormatRule: The KDocFormatRule is added to enforce correct closing syntax in KDoc comments.

To create the JAR file for the custom ruleset:
gradlew.bat :utility:customRulesJar

Use the custom ruleset with Ktlint by executing:
ktlint --ruleset=../oppia-android-tools/custom-ktlint-rules.jar "path/to/file"

Essential Checklist

  • The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • Any changes to scripts/assets files have their rationale included in the PR explanation.
  • The PR follows the style guide.
  • The PR does not contain any unnecessary code changes from Android Studio (reference).
  • The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • The PR is assigned to the appropriate reviewers (reference).

@manas-yu manas-yu requested a review from a team as a code owner October 24, 2024 08:26
@adhiamboperes adhiamboperes self-assigned this Oct 24, 2024
@manas-yu
Copy link
Contributor Author

@adhiamboperes PTAL, i will integrate the custom rules into scripts too.
please review and tell if there is anything else to do.

Copy link

oppiabot bot commented Nov 4, 2024

Hi @manas-yu, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue.
If you are still working on this PR, please make a follow-up commit within 3 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Nov 4, 2024
@manas-yu manas-yu marked this pull request as draft November 4, 2024 15:52
@oppiabot oppiabot bot removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Nov 4, 2024
@manas-yu manas-yu marked this pull request as ready for review November 6, 2024 17:49
@manas-yu manas-yu requested a review from a team as a code owner November 6, 2024 17:49
@manas-yu manas-yu marked this pull request as draft November 11, 2024 09:35
Copy link
Collaborator

@adhiamboperes adhiamboperes left a comment

Choose a reason for hiding this comment

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

@manas-yu, after reviewing this solution, I do not think it is the best approach to solve this for now. Your solution proposes a custom Gradle integration, which is not ideal for two reasons:

  1. This won't work with Bazel, and we will soon remove Gradle in favor of Bazel. Move lintchecks to bazel #4106 proposes creating Bazel scripts for lint checks, to run in parallel with our existing custom Bash scripts until Gradle is removed.
  2. Integrate with ktfmt #2799 proposes using ktfmt, which is still pending invvestigation.

#3195 was created to track KDoc checks. Ben's comment was inconclusive on the approach (cc/ @jainv4156). It is my opinion that the two best options for this issue is:

  1. Use the existing script pattern to write a script that a)finds Kdocs and b)checks the Kdoc formatting.
  2. Investigate and do a writeup on Integrate with ktfmt #2799, e.g. Add support for Dagger Hilt [Blocked: #59] #1720 (comment), so we can make a decision on how to go about this.

Either way, I am closing this PR, and you can create a new. replacement once we have chosen a better approach. (Please feel free to use Discussions or the relevant issue thread to explore options.)

@manas-yu
Copy link
Contributor Author

I encountered some issues with this approach, so i marked it as a draft to investigate further. If I find a more effective solution, I’ll open a new PR.

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.

Ktlint check comment block
2 participants