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

New customPath parameter with test #199

Merged
merged 25 commits into from
Dec 5, 2023
Merged

Conversation

laurentschall
Copy link
Contributor

@laurentschall laurentschall commented Oct 25, 2023

Hi Invertase team,

This is the same as https://github.com/invertase/dart_custom_lint/pull/187, but including a test on the new customPath parameters.

Please let me know if this test is sufficient. I added no test for the other methods where the customPath parameter has been integrated as well in the pull request of Matthias, because I did not found any existing test to extend for those other methods. I even found no call at all to the addYamlFileEdit() method.

Thanks in advance for the review.

Best Regards,
Laurent

@vercel
Copy link

vercel bot commented Oct 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
custom-lint-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2023 10:32am

@CLAassistant
Copy link

CLAassistant commented Oct 25, 2023

CLA assistant check
All committers have signed the CLA.

@rrousselGit
Copy link
Collaborator

Sorry this flew under the radar.
LGTM, thanks!

@rrousselGit rrousselGit merged commit a6738cb into invertase:main Dec 5, 2023
7 checks passed
@laurentschall
Copy link
Contributor Author

You're welcome, thank you for the merge !

@unitmdev
Copy link

unitmdev commented Dec 3, 2024

I think this is problematic because the file doesn't get saved after applying a DartFix. I don't see a way to access the current, unsaved version of the file.

A simplified version of this is:

final path = 'some/file/path.txt';

// read file contents (this ignores unsaved changes)
final fileContents = File(path).readAsStringSync();

if (fileContents == '') {
  changeBuilder.addGenericFileEdit(
    (builder) => builder.addSimpleInsertion(0, 'foo'),
    customPath: path,
  );
}

Running the fix multiple times in a row results in foo being written to the file until some/file/path.txt is saved.

I noticed that the analyzer plugin gets file contents from ChangeWorkspace, but I don't see how to access that.

tldr; File(customPath).readAsStringSync() returns the latest saved version of a file. Applying a DartFix does not save the file.

@unitmdev
Copy link

unitmdev commented Dec 4, 2024

opened issue #296

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.

5 participants