bicep icon indicating copy to clipboard operation
bicep copied to clipboard

linter rule to check for decompile fluff

Open bmoore-msft opened this issue 3 years ago • 7 comments

Decompile will create vars/params/resources with an "appendix" on the name if they are ambiguous. So you can end up with things like accountName_var or virtualNetwork_resource which are a bit inelegant in bicep. Would be nice to lint these as a reminder to clean up decompiled code to make it more bicep like.

bmoore-msft avatar Jun 16 '21 17:06 bmoore-msft

if we think we can do this programmatically, I'd love to see if we can add it to the decompiler itself. Would still be good to have it in the linter too to catch any existing fluff.

alex-frankel avatar Jun 16 '21 17:06 alex-frankel

I think it's easy to "catch" a bit harder to "autofix" - which I think is how we ended up with the design in the first place... But yeah, even better ;)

bmoore-msft avatar Jun 16 '21 21:06 bmoore-msft

I like this. When I was converting our internal templates, I had to manually look for these and probably missed some.

majastrz avatar Jun 16 '21 21:06 majastrz

I think it's easy to "catch" a bit harder to "autofix" - which I think is how we ended up with the design in the first place... But yeah, even better ;)

+1, I like the suggestion. If added as a linter, then the decompiler could also flag these immediately as warnings in the output after running.

What we have today technically is autofixing (appending fluff to add uniqueness); it's hard to see how we could do a better job generating names (well, perhaps barring some advanced AI solution) without involving some user interactivity ("these identifiers are conflicting, would you like to rename one of them?"). At the time, I felt that there was no need for this, because editor-based refactoring should be just as straightforward.

anthony-c-martin avatar Jun 17 '21 04:06 anthony-c-martin

We could decompile to hungarian notation ;)

bmoore-msft avatar Jun 17 '21 19:06 bmoore-msft

I vote for the Hungarian!

StephenWeatherford avatar Aug 12 '22 20:08 StephenWeatherford

The goal is to make this not necessary, and instead do a better job in the decompiler. But it is possible we might not completely resolve it, so I guess I need to leave this here for now.

StephenWeatherford avatar Aug 12 '22 21:08 StephenWeatherford