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

Enforce default formatter, imports and license headers on OpenRewrite contributions #45

Closed
timtebeek opened this issue Feb 27, 2023 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@timtebeek
Copy link
Contributor

Right now https://github.com/openrewrite/rewrite/blob/main/CONTRIBUTING.md does not mention the formatter or import order; I believe we assume IntelliJ defaults. Might be good to make that explicit, so contributors are made aware and reviewers are less likely to have to point it out. Even better if we enforce adherence (lightly) through an automated check that signals or even fixes violations. We should have all the necessary components to do that already.

@timtebeek
Copy link
Contributor Author

timtebeek commented May 25, 2023

Now documented in https://github.com/openrewrite/.github/blob/main/CONTRIBUTING.md and the pull request template from the same repository.

Still even better to enforce this through integrating with GitHub Actions, so renaming the issue for that use case.

@timtebeek timtebeek changed the title Document, and potentially enforce, default formatter & imports on OpenRewrite contributions Enforce default formatter, imports and license headers on OpenRewrite contributions May 25, 2023
@mike-solomon
Copy link

@timtebeek Should this perhaps be in the rewrite repository instead? If this is a GitHub action to enforce formatting for rewrite - I'm not sure what the docs would have to do with that but maybe I'm missing something.

@timtebeek timtebeek transferred this issue from openrewrite/rewrite-docs Jun 26, 2023
@timtebeek
Copy link
Contributor Author

Should this perhaps be in the rewrite repository instead? If this is a GitHub action to enforce formatting for rewrite - I'm not sure what the docs would have to do with that but maybe I'm missing something.

Yes thanks! I've moved it to openrewrite/.github, which contains all our pipeline scripts; When I opened this one I hadn't realized we had this repository as well. We can keep the issue here, unless we end up creating a GitHub Action for it that would fit even better.

@timtebeek timtebeek added enhancement New feature or request and removed documentation Improvements or additions to documentation labels Jun 28, 2023
@timtebeek timtebeek transferred this issue from openrewrite/.github Nov 19, 2023
@timtebeek
Copy link
Contributor Author

We can likely combine some of the existing Rewrite best practices together into a declarative recipe such as

type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.recipes.RewriteBestPractices
displayName: OpenRewrite best practices
description: |
  A collection of recipes that are generally considered to be best practices for Rewite modules.
recipeList:
  - org.openrewrite.java.upgrade.MigrateToRewrite8
  - org.openrewrite.java.recipes.ExecutionContextParameterName
  - org.openrewrite.java.recipes.SelectRecipeExamples
  - org.openrewrite.java.recipes.SourceSpecTextBlockIndentation

# TODO Move to rewrite-all or something, such that we can also add recipes like UseTextblocks of test sources
# Further ideas
# - Flag any use of System.err/out
# - Flag any use of throwing Exceptions
# - Flag asserting latest version of dependency
# - Apply testing best practices
# - Apply formatter
# -
# -

@timtebeek
Copy link
Contributor Author

Another good option here is to nudge folks to provide example values on options; as identified on the OSS Slack by @koppor :

Would it be possible to provide default configurations for recipts? The example at https://docs.openrewrite.org/recipes/java/simplifymethodchain is a good one which can be used in any repository? Maybe, it's just a case of that recipt?

timtebeek added a commit to openrewrite/rewrite that referenced this issue Jan 15, 2024
timtebeek added a commit to openrewrite/rewrite that referenced this issue Jan 15, 2024
* Find `@Option` annotations without `example` values

As came up in Slack: openrewrite/gh-automation#45 (comment)

* Skip boolean fields
@timtebeek timtebeek self-assigned this Feb 4, 2024
@timtebeek
Copy link
Contributor Author

We now run a first set of recipes on every pull request, to produce code suggestions such as these openrewrite/rewrite-testing-frameworks#343 (review) . That concludes the first iteration of this feature; we will expand and refine still but can already close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

2 participants