looker-open-source / look-at-me-sideways

A style guide and linter for Looker's LookML data modeling language
MIT License
123 stars 37 forks source link

Question about F2 #174

Closed Rkohn123 closed 3 months ago

Rkohn123 commented 3 months ago

Hello, I was currently fixing my code but I have some questions about the F2 rule:

dimension: days{ hidden: yes view_label: "Test" type: number }

In the linter, it recommends me to removing the view_label and to put it on the view-level but according to google https://cloud.google.com/looker/docs/reference/param-view-view-label?version=24.2&lookml=new

"view_label should be avoided as of Looker 4.4 on the view level".

What is your advice ? Thank you

fabio-looker commented 3 months ago

Hi @Rkohn123 - the doc is merely saying that you should use the preferred/newer synonym, label, when declaring at the view level.

https://cloud.google.com/looker/docs/reference/param-view-label

Hope this clears it up. If you still have any doubts, feel free to reply and I'll re-open the ticket.

Rkohn123 commented 3 months ago

Hello Fabio, in my case : I have both view_label and label inside a dimension/filters etc. Inside my view it looks like something that :

n_1 { extension: required filter: current_date_range { type: date view_label: "1 - Obligatoire N/N-1" label: "1 - Période Actuelle" description: "Sélectionnez la période actuelle qui vous intéresse." sql: ${period} IS NOT NULL ;; }

Capture d'écran 2024-03-08 102902

What can I do to obtain the same result without F2 failing

fabio-looker commented 3 months ago

Hi @Rkohn123 - sorry I did not see the notification for this follow up

The reason that field-level view labels are discouraged by rule F2 is because they can't be overridden by someone using your view at the explore level, and thus make your views less re-usable and your LookML project more difficult to maintain for future LookML developers.

In some cases, you may want to ignore this best practice and simply apply a LAMS exemption.

Alternately, you can take the fields that require a different view-label and organize them into their own field-only view, where the explore can choose to bring them in, but still re-label them if necessary.