+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

feat(rome_service): --apply-suggested argument to rome check #2952

Merged
merged 9 commits into from
Aug 4, 2022

Conversation

ematipico
Copy link
Contributor

@ematipico ematipico commented Jul 28, 2022

Summary

--apply-suggested argument

This PR adds a new argument --apply-suggested to the check.

As opposed to --apply, which only applies safe fixes, this argument tells to the workspace to apply fix actions that are marked with suggested fixes, marked with Applicability::MaybeIncorrect and safe fixes.

This argument is temporary and it will be replaced with another argument called --review, which will allow users to interactively choose the safe fixes.

Settings passed to format requests

Until now we were passing the IndentStyle coming from the editor, which would then override the one coming from the configuration. The PR removes the need to sending the indentation coming from the LSP. We now have a configuration file and Rome should rely on what the user specified there.

Messaging of the rome check --apply command

When using --apply, the workspace now tracks the fixes marked as suggested, and at the end it will present a message with the amount of suggested fixes that were not applied, and it will suggest the new argument added in this PR

Test Plan

I added new tests

@ematipico ematipico temporarily deployed to aws July 28, 2022 11:22 Inactive
@github-actions
Copy link

github-actions bot commented Jul 28, 2022

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jul 28, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7706549
Status: ✅  Deploy successful!
Preview URL: https://1a46ee69.tools-8rn.pages.dev
Branch Preview URL: https://fix-check-apply-command.tools-8rn.pages.dev

View logs

@ematipico ematipico force-pushed the fix/check-apply-command branch from 46a8ae7 to eae2c77 Compare July 28, 2022 12:54
@ematipico ematipico temporarily deployed to aws July 28, 2022 12:54 Inactive
@ematipico ematipico changed the title feat(rome_service): apply formatting when running check --apply feat(rome_service): new --apply-suggested argument to rome check Jul 29, 2022
@ematipico ematipico force-pushed the fix/check-apply-command branch 2 times, most recently from 71da2ac to 167156f Compare July 29, 2022 10:59
@ematipico ematipico temporarily deployed to aws July 29, 2022 10:59 Inactive
@ematipico ematipico temporarily deployed to aws July 29, 2022 11:11 Inactive
@ematipico ematipico marked this pull request as ready for review July 29, 2022 11:12
@ematipico ematipico requested review from leops and xunilrj as code owners July 29, 2022 11:12
@ematipico ematipico requested a review from a team July 29, 2022 11:12
pub(crate) struct SettingsHandle<'a, E> {
inner: RwLockReadGuard<'a, WorkspaceSettings>,
/// Additional per-request state injected by the editor
#[allow(dead_code)]
Copy link
Contributor

Choose a reason for hiding this comment

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

If this field is now unused let's remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you sure about it? It's definitely something that we will need in the future if we decided to have options in the editors.

Copy link
Contributor

Choose a reason for hiding this comment

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

At least at the moment I don't really see any use case for being able to provide configuration override into the workspace on a per-request basis

@MichaReiser
Copy link
Contributor

Until now we were passing the IndentStyle coming from the editor, which would then override the one coming from the configuration. The PR removes the need to sending the indentation coming from the LSP. We now have a configuration file and Rome should rely on what the user specified there.

What if there's no configuration in place? Shouldn't Rome then use the editor defaults?

Copy link
Contributor

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

What do you think of changing the --apply-suggested argument to --apply=suggested?

@ematipico
Copy link
Contributor Author

ematipico commented Aug 2, 2022

What do you think of changing the --apply-suggested argument to --apply=suggested?

From the description:

This argument is temporary and it will be replaced with another argument called --review, which will allow users to interactively choose the safe fixes.

--review comes from Rome classic, and it was the "way to go" to apply suggested fixes. So I am not sure if it's safe to change the --apply argument behaviour, to change it back when we will introduce --review

@ematipico
Copy link
Contributor Author

ematipico commented Aug 2, 2022

Until now we were passing the IndentStyle coming from the editor, which would then override the one coming from the configuration. The PR removes the need to sending the indentation coming from the LSP. We now have a configuration file and Rome should rely on what the user specified there.

What if there's no configuration in place? Shouldn't Rome then use the editor defaults?

I think we should not use editor's configuration, because they would go in conflict with commands like rome ci. If we can't keep the configuration stable across environments, we risk to create errors. Example: if spaces are set in the editor, we save and commit, then when we run rome ci in a CI environment, tabs will be used (Rome's default) and it will emit errors.

I am not saying we should remove it, but the ergonomics will be harder. What do you think?

@ematipico ematipico requested review from leops and MichaReiser August 2, 2022 11:11
@ematipico ematipico force-pushed the fix/check-apply-command branch from 1bfcea9 to e78d1a7 Compare August 2, 2022 11:14
@ematipico ematipico temporarily deployed to aws August 2, 2022 11:14 Inactive
@ematipico ematipico temporarily deployed to aws August 2, 2022 11:18 Inactive
@leops
Copy link
Contributor

leops commented Aug 2, 2022

Until now we were passing the IndentStyle coming from the editor, which would then override the one coming from the configuration. The PR removes the need to sending the indentation coming from the LSP. We now have a configuration file and Rome should rely on what the user specified there.

What if there's no configuration in place? Shouldn't Rome then use the editor defaults?

I think we should not use editor's configuration, because they would go in conflict with commands like rome ci. If we can't keep the configuration stable across environments, we risk to create errors. Example: if spaces are set in the editor, we save and commit, then when we run rome ci in a CI environment, tabs will be used (Rome's default) and it will emit errors.

I am not saying we should remove it, but the ergonomics will be harder. What do you think?

I think that's also what Prettier is doing, when no configuration file is present it doesn't read its settings from the incoming formatting request, it just uses the default configuration of 2 spaces for indentation

@ematipico ematipico force-pushed the fix/check-apply-command branch from 6ad137b to 396f98c Compare August 2, 2022 12:36
@ematipico ematipico temporarily deployed to aws August 2, 2022 12:37 Inactive
@ematipico ematipico added this to the 0.9.0 milestone Aug 3, 2022
@ematipico ematipico added the A-Linter Area: linter label Aug 3, 2022
@ematipico ematipico added the A-CLI Area: CLI label Aug 3, 2022
@ematipico ematipico force-pushed the fix/check-apply-command branch from 396f98c to 7706549 Compare August 3, 2022 10:21
@ematipico ematipico temporarily deployed to aws August 3, 2022 10:21 Inactive
@ematipico ematipico changed the title feat(rome_service): new --apply-suggested argument to rome check feat(rome_service): --apply-suggested argument to rome check Aug 4, 2022
@ematipico ematipico merged commit 6d725db into main Aug 4, 2022
@ematipico ematipico deleted the fix/check-apply-command branch August 4, 2022 07:34
IWANABETHATGUY pushed a commit to IWANABETHATGUY/tools that referenced this pull request Aug 22, 2022
@ematipico ematipico added A-CLI Area: CLI and removed A-CLI Area: CLI labels Aug 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-CLI Area: CLI A-Linter Area: linter
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载