Do not report misplaced-load lint in WORKSPACE files#186
Do not report misplaced-load lint in WORKSPACE files#186abhinavgautam01 wants to merge 3 commits into
Conversation
|
@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D103520777. (Because this pull request was imported automatically, there will not be any future comments.) |
|
ping @ndmitchell |
|
Baking this into the dialect-agnostic starlark doesn't really feel right. First of all, what does the spec have to say about the placement of load statements, I thought they had to be at the top? In any case, the appropriate way to do this would be to plumb it through properly and have the dialect report it among other interpreter-configuration settings in the evaluator (or somewhere similar) |
JakobDegen
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
thanks, agreed. i moved this out of the dialect-agnostic flow lint path... the misplaced-load lint now stays enabled by default via a new dialect setting, i also added tests for both sides:
|
JakobDegen
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Fixes #145.
Summary
This PR fixes a false-positive lint warning in Bazel workspace files.
misplaced-loadcurrently warns when aload(...)is not at the top of a file.That behavior is useful for normal Starlark files, but it is noisy for
WORKSPACE/WORKSPACE.bazel, where repository setup calls may legitimately appear beforeload(...).Changes
FlowIssue::MisplacedLoadfor files named:WORKSPACEWORKSPACE.bazelmisplaced-loadbehavior unchanged for all other files.starlark/src/analysis/flow.rs:test_lint_misplaced_load_workspacetest_lint_misplaced_load_workspace_bazelValidation
cargo test -p starlark test_lint_misplaced_load --libcargo clippycargo buildcargo testcargo bench