Replies: 3 comments
-
I think it's worth mentioning that while I think this would be a wonderful addition (provided all the technical hurdles can be overcome), this won't be useful when making packages since packages define a dependency range Should the user try to run a rule inside a package that requires information about dependency source code, what should happen? I guess elm-review should have the rule fail and say that, that rule is only for applications? |
Beta Was this translation helpful? Give feedback.
-
I think it would make sense for packages, as long as there are use-cases where packages would like to look at their dependencies. At the moment, Since in this case, we want to get those files using I am not yet convinced that this should not be available for packages. But the part where one user could have different results than another one based on what they have available on their machine does bug me. In practice, I imagine that the results will rarely be different, but it is a good point to think about... |
Beta Was this translation helpful? Give feedback.
-
True, I overstated my case against supporting dependencies for packages. There might be rules that still are useful. With https://github.com/jfmengels/elm-review-rule-ideas/issues/7 it's effectiveness is reduced but it probably can still be somewhat useful for packages (though if the user doesn't understand the implications then it might give a false sense of security). With jfmengels/elm-review-rule-ideas#8 I think it's best if the rule refuses to work with packages to avoid a pretty big footgun. |
Beta Was this translation helpful? Give feedback.
-
The problem
By only analyzing the source code,
elm-review
encounters a few knowledge gaps when we need to know implementation details from code that comes from dependenciesdocs.json
.Html.lazy
is used correctly, we sometimes need to know whether a function creates a new reference to a value or not. To know that, we need to look at the implementation of functions, including those from dependencies.What would be needed
elm-review
APIModuleContext
/ProjectContext
, since you would need to analyze a dependency, store the resulting context (WorkspaceContext
?ProjectContext
would have fit nicely here...), then kickstart the analysis of a dependency using thatWorkspaceContext
with a system likewithModuleContext
but on a higher-level.elm-review
and display an error?Performance improvements
elm/core
multiple times.Fetching dependencies
Dependencies may not be available. That should be relatively rare though, so the happy path that we should try first is to fetch the data from the file system in the ELM_HOME.
If some dependencies are not available, we could do either of two things:
elm make
ourselvesRunning
elm make
ourselvesWe can simply run
elm make
, we don't need a target file. If the project is a package, that will be sufficient to run the compiler. If the project is an application, that is not sufficient for the compiler to run, but thankfully the Elm compiler downloads the packages beforehand (If that behaviour ever changes, we should fall back to displaying an error message). We then ignore the error.If there is no input (for applications), then downloads were successful and we get an error with the title
NO INPUT
. If there is no network access, we getPROBLEM LOADING PACKAGE LIST
. If the user messed the dependencies by hand, we getINCOMPATIBLE DEPENDENCIES
.Notes
This is definitely not light work :D
I think it is a lot of work for a small benefit. That said, once we have it,
elm-review
would potentially become much more powerful. I kind of likeelm-review
becoming more "omniscient".I am worried about the performance impact this would have, as this would add a lot of additional work, especially in the initial runs and when the configuration or dependencies change.
Note that even with this, we still have a few knowledge gaps:
I don't know about the second gap, but I am interested in exploring the non-Elm files realm. Please open an issue if you want to discuss those two points, I just wanted to point out that even with this, there would still be some knowledge gaps (though a lot less!).
Beta Was this translation helpful? Give feedback.
All reactions