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

Allow fixing directory structure not matching package paths #1035

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

anderseknert
Copy link
Member

@anderseknert anderseknert commented Sep 1, 2024

Following the recent addition of the directory-package-mismatch rule, this PR brings a corresponding regal fix remediator as well as a code action to fix this directly in the editor.

Fixes #1025

Todo:

  •  Make it possible to set roots like how the OPA VS Code extension does
    • For VS Code, we can send opa.roots as part of the init options, but what about updates?
    • For regal lint we will need to either add a flag or read from config (or both)
  •  Docs for regal fix (including settings for DAS compliance)
  • Docs for LSP integration (Code Action / Execute Command)
  • Setting config without exclude-test-suffix or to false leads to no Code Action shown
  • For regal fix: determine if clean git working directory #1029
  • Show before/after paths in Code Action hover, and ideally in regal fix
    • Later... allow --dry-run for all fixes of regal lint

@anderseknert anderseknert force-pushed the regal-fix-directories branch 3 times, most recently from 6c227b9 to cbb257f Compare September 2, 2024 12:45
@@ -0,0 +1 @@
foo
Copy link
Member

Choose a reason for hiding this comment

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

Added by mistake?

Copy link
Member Author

Choose a reason for hiding this comment

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

Certainly! I’m surprised there aren’t more given how many tempdirs I’ve burned in this process 😄 Thanks for catching that. Will fix!

// FixResult is returned from the Fix method and contains the new contents or fix recommendations.
// In future this might support diff based updates, or renames.
// In future this might support diff based updates.
Copy link
Member

Choose a reason for hiding this comment

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

Very nice! as intended 🙂

@anderseknert anderseknert force-pushed the regal-fix-directories branch 6 times, most recently from 4fa5b2b to b4bd54a Compare September 3, 2024 10:10
Following the recent addition of the `directory-package-mismatch` rule,
this PR brings a corresponding `regal fix` remediator as well as a code
action to fix this directly in the editor.

Fixes #1025

Signed-off-by: Anders Eknert <anders@styra.com>
@anderseknert anderseknert marked this pull request as ready for review September 3, 2024 12:41
@anderseknert
Copy link
Member Author

Will defer docs to new PRs once this is in main.

Copy link
Member

@charlieegan3 charlieegan3 left a comment

Choose a reason for hiding this comment

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

lgtm, have been testing in my own PR and will open shortly as a follow on.

@charlieegan3 charlieegan3 merged commit 8e890ae into main Sep 3, 2024
3 checks passed
@charlieegan3 charlieegan3 deleted the regal-fix-directories branch September 3, 2024 12:46
anderseknert added a commit that referenced this pull request Sep 3, 2024
This is a follow-up PR to #1035, documenting the new capabilities
of Regal added there

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this pull request Sep 3, 2024
This is a follow-up PR to #1035, documenting the new capabilities
of Regal added there

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this pull request Sep 4, 2024
This is a follow-up PR to #1035, documenting the new capabilities
of Regal added there

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this pull request Sep 4, 2024
This is a follow-up PR to #1035, documenting the new capabilities
of Regal added there

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this pull request Sep 4, 2024
This is a follow-up PR to #1035, documenting the new capabilities
of Regal added there

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this pull request Sep 4, 2024
This is a follow-up PR to #1035, documenting the new capabilities
of Regal added there

Signed-off-by: Anders Eknert <anders@styra.com>
charlieegan3 pushed a commit that referenced this pull request Sep 4, 2024
This is a follow-up PR to #1035, documenting the new capabilities
of Regal added there

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this pull request Sep 4, 2024
This is a follow-up PR to #1035, documenting the new capabilities
of Regal added there

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this pull request Sep 4, 2024
This is a follow-up PR to #1035, documenting the new capabilities
of Regal added there

Signed-off-by: Anders Eknert <anders@styra.com>
srenatus pushed a commit to srenatus/regal that referenced this pull request Oct 1, 2024
…#1035)

Following the recent addition of the `directory-package-mismatch` rule,
this PR brings a corresponding `regal fix` remediator as well as a code
action to fix this directly in the editor.

Fixes StyraInc#1025

Signed-off-by: Anders Eknert <anders@styra.com>
srenatus pushed a commit to srenatus/regal that referenced this pull request Oct 1, 2024
…nc#1043)

This is a follow-up PR to StyraInc#1035, documenting the new capabilities
of Regal added there

Signed-off-by: Anders Eknert <anders@styra.com>
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.

Provide regal fix and LSP Code Action for directory-package-mismatch
2 participants