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

Search for pubspecs surrounding analysis contexts #152

Closed
wants to merge 14 commits into from

Conversation

TimWhiting
Copy link
Contributor

@TimWhiting TimWhiting commented May 22, 2023

Fixes #148

@docs-page
Copy link

docs-page bot commented May 22, 2023

To view this pull requests documentation preview, visit the following URL:

docs.custom-lint.dev/~152

Documentation is deployed and generated using docs.page.

@vercel
Copy link

vercel bot commented May 22, 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 Jun 24, 2023 4:56am

@TimWhiting TimWhiting marked this pull request as draft May 22, 2023 16:07
@TimWhiting TimWhiting changed the title guard against project directories Search for pubspecs surrounding analysis contexts May 22, 2023
@TimWhiting TimWhiting marked this pull request as ready for review May 23, 2023 03:56
@TimWhiting
Copy link
Contributor Author

TimWhiting commented May 23, 2023

@rrousselGit

I figured I'd investigate some of the issues that users have been having getting custom_lint to work in their projects so that more people can adopt it and start using it with Riverpod.

An analysis option file by itself seems to delimit the analysis context, but it isn't required to have a pubspec file alongside it. I believe searching the parent directories for the pubspec.yaml is the best solution for this particular issue. Let me know if you forsee any issues with this approach.

@rrousselGit rrousselGit self-assigned this May 24, 2023
workspace.dir('package').createSync(recursive: true);
test(
'throws MissingPubspecError if package does not contain a pubspec',
skip: true, //#148
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not fond of skips. We should update the test to match instead

@rrousselGit
Copy link
Collaborator

Overall I'm fine with the changes, but this needs testing.

To begin with, I'm not sure when this happens exactly. I haven't tried to reproduce this, and I haven't had this issue.

I do have analysis_options.yamls which are not associated with a pubspec.yaml myself. Riverpod is exactly in this situation. But custom_lint is working fine for me.

///
/// This is a folder that contains both a `pubspec.yaml` and a `.dart_tool/package_config.json` file.
/// It is either alongside the analysis_options.yaml file, or in a parent directory.
Directory findProjectDirectory(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This handles looking for a project directory which contains at minimum a pubspec next to a .dart_tool/package_config.json (and in the case of hosted dependencies in the pubcache, the package config file is not necessary).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we care about searching for the existence of a package_config.json here? Shouldn't searching only for a pubspec be enough?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure why this was resolved. I still don't get why we are looking for package_config.jsons

To begin with, there's a high chance that if there's a missing package_config, then #168 should take care of it.

@TimWhiting
Copy link
Contributor Author

I've iterated on this and hopefully solved the test errors. Ready for another review.

@rrousselGit
Copy link
Collaborator

Note that the CI is passing on master. Could you maybe sync with master (while fixing conflicts)?

@rrousselGit
Copy link
Collaborator

Thanks for fixing the CI. Is this good to review for you?

@TimWhiting
Copy link
Contributor Author

Yeah

);
// Expect one context root for the workspace and one for the test folder
expect(customLintWorkspace.contextRoots.length, equals(2));
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you remove those trailing commas and format again? Tests typically don't use them

@shilangyu
Copy link

shilangyu commented Nov 8, 2023

Can someone write down what has been done, what is left, and what are the blockers? It would simplify the process for someone else to take this over. This is quite an annoying issue (no good workaround exists). I am considering picking this up, please explain the current status.

cc @TimWhiting @rrousselGit

@rrousselGit
Copy link
Collaborator

@shilangyu There are still unresolved conversations and there are now conflicts. Both need to be fixed :)

@TimWhiting
Copy link
Contributor Author

Sorry for not replying earlier. I'm no longer using flutter much in my day job, and don't really have the time to dedicate to this PR, I'm happy for someone else to take my work and finish it.

@shilangyu
Copy link

The unresolved comments seem purely stylistic. Once rebased and corrected this will be good to merge or does it require extra architecture work? I am trying to gauge the level of codebase knowledge this requires to pick it up.

@rrousselGit
Copy link
Collaborator

@shilangyu There are some architectural comments. The ones about not throwing and not requiring a package_config.json

@shilangyu
Copy link

I rebased this branch in my fork (https://github.com/shilangyu/dart_custom_lint/commits/main), but after looking at the other comments on this PR it seems like it requires deeper understanding of the feature to finish this PR. I do not want to by accident introduce regressions and I unfortunately do not have time to dive deeper into this topic.

@rrousselGit
Copy link
Collaborator

Closing as this is quite out of sync.

@rrousselGit rrousselGit closed this Jan 9, 2024
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.

Custom lint breaks when analysis_options.yaml is not at package root
3 participants