Azure / Azure/bicep

`no-loc-expr-outside-params` rule hides errors

Open
#6,958 6 comments 0 reactions 0 assignees View on GitHub
devdiv good first issue story: linter rules
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 4h
Merged PRs (30d)
81

Description

**Bicep version**
VS Code v0.6.18

**Describe the bug**
The `no-loc-expr-outside-params` analyzer will fire on expressions even if they're invalid in the current scope. (e.g. `resourceGroup().location` in a subscription scope). This expression is then highlighted as a warning rather than an error, hiding the underlying error

**To Reproduce**

In the below example, the `no-loc-expr-outside-param` reports a warning, however Iw ouldn't expect the warnign to be logged at all as the entire expression is invalid in the current (subscription) scope.

``` bicep
targetScope='subscription'

resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
location: resourceGroup().location
}
```

![image](https://user-images.githubusercontent.com/289860/170452597-60ff39b8-06bd-4bf4-bb72-ee15c5455ad6.png)

**Additional context**
Add any other context about the problem here.

Contributor guide

Open the contributing guide

Research direction

Reproduce the subscription-scope example in VS Code with Bicep v0.6.18 and inspect the no-loc-expr-outside-params analyzer. Trace how it handles the invalid resourceGroup().location expression; done means the analyzer warning is absent while the underlying scope error remains visible.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.