持續整合樣式驗證工具

持續整合 (CI) 樣式驗證器會使用 LookML 樣式 Lint,在整個 LookML 專案中強制執行 LookML 編碼標準、命名慣例和結構最佳做法。Style Validator 會根據一組可設定的樣式規則檢查 LookML 檔案,協助團隊維護乾淨、一致且易於閱讀的程式碼。

如要執行 Style Validator,請在 LookML 專案存放區的根目錄中,新增名為 lkmlstyle.yaml (或 lkmlstyle.yml) 的設定檔。如要瞭解如何設定樣式檢查工具,請參閱本頁的「設定檔」一節。

如要瞭解如何在 CI 套件中設定及執行樣式驗證器,並查看驗證輸出內容,請參閱「建立持續整合套件」、「執行持續整合套件」和「查看 CI 執行結果」說明文件頁面。

事前準備

如要在持續整合中使用 Style Validator,您需要下列項目:

  • 執行 Looker 26.18 以上版本,且符合 CI 需求並啟用 CI 的 Looker 執行個體。
  • 已設定 Git 版本管控的 LookML 專案。
  • 在 CI 套件設定中啟用「Style Validator」切換按鈕 (Style Validator 預設為停用)。開啟樣式驗證器時,系統預設會啟用「僅限增量錯誤」選項。
  • LookML 專案存放區根目錄中的 lkmlstyle.yaml (或 lkmlstyle.yml) 設定檔。請參閱本頁面的「設定檔」一節。

設定檔

如要在 Looker CI 中執行 Style Validator,必須提供設定檔。Style Validator 執行時,會自動檢查 LookML 專案存放區的根目錄,並依下列優先順序尋找設定檔:

  1. lkmlstyle.yaml
  2. lkmlstyle.yml

如果這兩個檔案都存在於根目錄中,系統會優先採用 lkmlstyle.yaml,並忽略 lkmlstyle.yml。

如果專案根目錄中找不到 lkmlstyle.yaml 或 lkmlstyle.yml,且沒有透過 API 傳遞任何自訂設定,樣式驗證就會失敗,並顯示 "No style validator configuration provided" 錯誤。

如要使用預設設定執行所有 25 項標準內建規則,您可以在 lkmlstyle.yaml 檔案中使用下列最少的設定資訊:

schema_version: 1
ruleset_version: "all-v1.0"

否則,您可以自訂設定檔。設定檔可包含下列頂層參數:

參數 類型 是否必要 預設 說明
schema_version 整數 是 無 設定結構定義版本。目前僅支援版本 1,且必須明確指定。
ruleset_version 字串 是 無 要沿用的基準規則集版本。支援的值:"all-v1.0"、"none"。
ignore_files 字串清單 否 [] 要從樣式驗證中完全排除的檔案 Glob 模式。
rules 地圖 否 {} 個別規則的全域自訂設定 (severity 和 version)。您也可以啟用基準規則集未納入的內建規則,以及變更自訂規則的嚴重程度。如需範例,請參閱「規則自訂」一節。
overrides 地圖清單 否 [] 範圍規則會覆寫設定,調整或啟用特定相符檔案路徑的嚴重程度。
custom_rules 地圖清單 否 [] 宣告式使用者定義的自訂規則。

ruleset_version

ruleset_version 參數會定義樣式驗證策略的基礎:

  • "all-v1.0" (建議):啟用所有 25 項標準內建 LookML 樣式規則,嚴重程度為 error。如果團隊希望開箱即用,就能全面強制執行品質規定,這個選項就非常適合。
  • "none":一開始會啟用零個內建規則。如果團隊想逐步採用樣式驗證、逐一選擇加入特定規則,或只執行自訂機構規則,這個選項就非常適合。如要在 ruleset_version 為 "none" 時選擇加入內建規則,請在 rules 區塊或 overrides 區塊中,為規則指派 warn 或 error 嚴重程度。

ignore_files

ignore_files 參數接受檔案的 glob 模式清單,您想在樣式驗證期間完全略過這些檔案。系統不會檢查符合這些模式的檔案是否符合內建或自訂規則。

支援的萬用字元語法包括:

  • *:比對單一目錄層級中的任何非分隔符字元序列。
  • **:比對多個巢狀目錄層級中的任何字元序列。
  • ?:比對任何單一字元。
  • {a,b} 和 [abc]:比對替代項目和字元類別 (Java glob 語法)。

下列路徑比對規則適用於設定檔中的每個 glob 模式,包括頂層 ignore_files,以及 overrides 中的 files 和 ignore_files:

  • 路徑是相對於專案根目錄的路徑。系統會忽略開頭的 ./ 或 /。
  • 不含斜線 (/) 的模式會比對任何目錄深度。例如,*.ignore.lkml 可符合 x.ignore.lkml 和 views/x.ignore.lkml 兩者。
  • 如果模式結尾為 /,則會比對該目錄下的所有項目。
  • 以 .lkml 或 .lookml 結尾的模式也符合複合擴充功能。例如,*.ignore.lkml 符合 x.ignore.view.lkml。

以下範例會排除供應商檔案、舊版 LookML 檔案和 LookML 資訊主頁:

ignore_files:
  - "vendor/**"
  - "legacy/**/*.lkml"
  - "*.ignore.lkml"
  - "dashboards/*.dashboard.lookml"

rules

您可以使用 rules 區塊,調整整個專案中個別規則的診斷嚴重程度:

rules:
  boolean-dimension-name-prefix:
    severity: warn
  view-dimension-order:
    severity: disabled
  numeric-measure-value-format-presence:
    severity: error

即使 ruleset_version 設為 "none",rules (或 overrides 區塊) 中列出的任何嚴重程度為 warn 或 error 的內建規則都會處於啟用狀態。舉例來說,下列初始設定會從 ruleset_version: "none" 開始,且只啟用兩項內建規則:

schema_version: 1
ruleset_version: "none"

rules:
  join-relationship-presence:
    severity: error
  explore-label-presence:
    severity: warn

您也可以使用 rules 區塊,透過參照自訂規則的名稱來變更嚴重程度。

severity

每項規則都可以設定下列其中一個不區分大小寫的嚴重程度:

  • error:視為重大違規事項。錯誤會導致 CI 執行失敗。
  • warn:以非封鎖警告的形式發出。警告會顯示在 CI 執行報告中,但不會導致 CI 執行失敗。
  • disabled:完全停用規則,並在驗證期間略過規則。

overrides

您可以使用 overrides 參數修改特定檔案或目錄的規則嚴重程度,而不必變更其餘 LookML 專案的嚴重程度。舉例來說,您可以透過 overrides 針對暫存檢視區塊或舊版模型放寬規則、針對重要路徑收緊規則,或僅針對特定目錄啟用特定規則 (當 ruleset_version 為 "none" 時)。

overrides 清單中的每個項目都支援下列欄位:

欄位 類型 是否必要 說明
files 字串清單 是 與這個覆寫區塊適用的檔案相符的 Glob 模式。不得留空。
ignore_files 字串清單 否 要從這個特定覆寫區塊排除的 Glob 模式。
rules 地圖 是 規則名稱與嚴重程度設定的對應關係。不得留空。覆寫區塊中只能使用 severity (且必須使用)。規則名稱必須是有效的內建或自訂規則名稱。

以下範例會停用維度排序檢查,並將舊版檢視畫面和資訊主頁的缺少說明錯誤降級為警告:

overrides:
  - files:
      - "views/legacy/**"
      - "dashboards/*.dashboard.lookml"
    ignore_files:
      - "views/legacy/core_*.view.lkml"
    rules:
      view-dimension-order:
        severity: disabled
      visible-dimension-description-presence:
        severity: warn

custom_rules

您可以在設定檔的 custom_rules 區段中定義宣告式自訂規則,強制執行機構專屬的命名慣例、必要架構模式和結構式管理。

每個自訂規則定義都支援下列常見參數:

欄位 類型 是否必要 說明
name 字串 是 專屬 ID,採用慣例的連字號格式,例如 finance-measure-prefix。不得與內建規則名稱或其他自訂規則衝突。
title 字串 是 發生違規情形時回報的使用者可理解訊息,格式為 (<rule-name>) <title>。
rule_type 字串 是 規則的原型:pattern_match、property、order、first_child 或 unique。不區分大小寫;pattern 可做為 pattern_match 的別名。
severity 字串 否 診斷層級:error (預設值)、warn 或 disabled。可由 rules 和 overrides 覆寫。
rationale 字串 否 說明規則存在的原因。
select 字串或清單 否 目標的抽象語法樹狀結構 (AST) 節點路徑,例如 "view.dimension"、"explore" 或 ["dimension", "dimension_group"]。如果省略,規則會以符合 filters 的每個節點為目標。
filters 地圖 否 必須與目標節點相符的屬性篩選器,例如 primary_key: true。
parent_filters 地圖 否 屬性篩選器,必須與目標節點的直接父項相符。

每種規則類型只接受自己的類型專屬鍵。如果使用不明金鑰,或是屬於不同規則類型的金鑰 (例如 pattern_match 規則中的 order_by),就會導致設定錯誤。

select

select 參數會決定自訂規則評估的 LookML 元素:

  • 直接元素:指定特定 LookML 元素類型,例如 select: "dimension"、select: "measure"、select: "view"、select: "explore"、select: "join"、select: "model" 或 select: "include"。
  • 巢狀父項/子項路徑:指定特定直系父項中定義的元素,例如 select: "view.dimension" (在檢視畫面中定義的維度) 或 select: "explore.join" (在探索中定義的聯結)。父項必須是直接父項,且只會使用路徑的最後兩個區段 (因此 a.b.c 的行為類似於 b.c)。
  • 多個目標:使用以半形逗號分隔的字串或清單 (例如 select: "dimension, dimension_group" 或 select: ["dimension", "dimension_group"]),指定多個元素類型。

選取器、篩選器和子項名稱是區分大小寫的確切 LookML 關鍵字。如果名稱拼錯,系統不會回報為設定錯誤,而是規則永遠不會相符。

filters 和 parent_filters

您可以根據 LookML 檔案中明確宣告的 LookML 屬性,使用 filters 和 parent_filters 調整目標節點。

type: "string"
  • 布林值相等:比對明確宣告的布林值屬性,例如 primary_key: true 或 hidden: true。
  • 字串相等:比對完全相同的字串值,例如 type: "yesno" 或 type: "count"。
  • 清單中任一值:比對清單中的任何值,例如 type: ["string", "number", "date"]。
  • 檢查是否存在:傳遞空字串 (例如 derived_table: ""),檢查區塊或屬性是否存在。
  • 否定:在鍵或值前面加上 !,即可否定篩選條件。否定鍵必須以引號括住,因為未加引號的開頭 ! 是 YAML 標記語法,會導致設定檔無法剖析:
    • "!hidden": true 或 hidden: "!true" 會比對可見 (非隱藏) 項目,包括未宣告 hidden 的欄位。
    • type: ["!yesno", "!date"] 比對既不是 yesno 也不是 date 的類型。

rule_type

每項自訂規則都必須為 rule_type 參數指定下列五種規則原型之一:

pattern_match

對 LookML 實體名稱或屬性值強制執行規則運算式模式。您必須指定其中一個 match 或 should_not_match (如果兩者都設定,系統只會套用 match,並忽略 should_not_match):

  • match (字串、規則運算式):目標必須符合的模式。
  • should_not_match (字串、規則運算式):目標不得相符的模式。

模式是 Java 規則運算式,會在載入設定檔時經過驗證。比對是「未錨定」 (子字串比對),例如 match: "fin_" 會通過 my_fin_total。使用 ^ 和 $ 比對整個值。

如果 select 是以屬性而非實體為目標 (例如 select: "measure.sql" 或 select: "dimension.label"),系統會根據屬性值而非實體名稱評估規則運算式。內建的 measure-sql-table-reference 和 dimension-label-redundant-yes-no 規則就是以這種方式運作。

以下範例會強制規定貨幣指標必須以 _usd 或 _eur 結尾:

- name: currency-measure-suffix
  title: "Currency measures must end with a currency code like _usd or _eur"
  rule_type: pattern_match
  severity: error
  select: "view.measure"
  filters:
    value_format_name: ["usd", "usd_0", "eur", "eur_0"]
  match: "^.*_(usd|eur)$"

禁止使用臨時或草稿維度的範例:

- name: forbid-temporary-dimensions
  title: "Dimensions must not start with 'tmp_' or 'test_'"
  rule_type: pattern_match
  severity: error
  select: "dimension"
  should_not_match: "^(tmp|test)_.*"
property

強制 LookML 物件中必須或不得出現特定子項屬性。您必須指定其中一個 requires_child 或 forbidden_child (如果兩者都設定,系統只會套用 requires_child,並忽略 forbidden_child):

  • requires_child (字串或清單):必須存在的子屬性名稱。指定清單時,只要存在任何一個列出的子項,規則就會成立。
  • forbidden_child (字串或清單):不得出現的子屬性名稱。指定清單時,如果存在任何列出的子項,節點就會標示為違規。
  • child_filters (Map,選用):必要子項必須滿足的其他屬性篩選條件。

範例:所有可見維度都需要說明:

- name: require-visible-dimension-description
  title: "Visible dimensions must specify a description"
  rule_type: property
  severity: warn
  select: "view.dimension"
  filters:
    "!hidden": true
  requires_child: "description"

禁止在衍生資料表上使用 sql_table_name 的範例:

- name: forbid-sql-table-name-on-derived-views
  title: "Derived table views cannot specify sql_table_name"
  rule_type: property
  severity: error
  select: "view"
  filters:
    derived_table: ""
  forbidden_child: "sql_table_name"
order

強制容器內的同層元素依字母順序排列。

  • order_by (字串,必要):要排序的同層級子項目的 LookML 類型,通常為 "dimension" 或 "measure"。系統只會比較所選節點的直接子項,且 dimension_group 子項不會納入 "dimension"。

系統會根據字元代碼比較名稱 (區分大小寫):大寫字母會排在小寫字母前面,_ 則會排在兩者之間。

範例:需要在檢視畫面中依字母順序列出維度:

- name: custom-alphabetical-dimensions
  title: "Dimensions must be kept in alphabetical order within views"
  rule_type: order
  severity: error
  select: "view"
  order_by: "dimension"
first_child

強制符合特定篩選器的元素顯示為其類別的第一個子項。

  • position (字串,選用):位置限制。必須為 "first" (預設為 "first")。

如果是 first_child 規則,select 必須使用 parent.child_type 形式,例如 "view.dimension"。filters 參數會識別必須先顯示的子項,不會縮小要檢查的父項節點範圍。架構接受 parent_filters 參數,但系統會忽略這個規則類型。

範例:必須先在檢視區塊中宣告主鍵維度:

- name: custom-primary-key-first-dimension
  title: "Primary key dimension must be the first dimension in the view"
  rule_type: first_child
  severity: error
  select: "view.dimension"
  filters:
    primary_key: true
  position: first
unique

在 CI 執行期間驗證的檔案中,強制所有相符節點的屬性值必須是唯一的。

  • unique_property (字串,必要):屬性名稱,在相符節點中必須有不重複的值,例如 "sql_table_name" 或 "label"。

系統會比較確切的字串值,並回報第一次出現的值和所有重複值。如果驗證執行作業只檢查專案檔案的子集,系統就不會偵測到該子集以外檔案中的重複項目。

以下範例可確保所有檢視區塊的表格名稱都不重複:

- name: custom-sql-table-name-uniqueness
  title: "Each view must reference a unique sql_table_name"
  rule_type: unique
  severity: error
  select: "view"
  unique_property: "sql_table_name"

自訂規則限制

建立自訂規則時,請遵守下列限制:

  1. 不得與內建規則名稱衝突:自訂規則不得重複使用內建規則目錄中的任何名稱,例如 boolean-dimension-name-prefix 或 sql-table-name-uniqueness。
  2. 自訂名稱不得重複:每個自訂規則在 custom_rules 清單中都必須有專屬名稱。
  3. 連字號格式:規則名稱應使用連字號格式 (lowercase-words-with-hyphens)。

設定評估順序

Style Validator 評估 LookML 檔案時,會依下列順序套用設定規則:

  1. 排除檔案:如果檔案符合 ignore_files 中的任何模式,系統會完全略過該檔案。
  2. 有效規則:檔案的有效規則包括 ruleset_version (all-v1.0 或 none) 中的規則,加上在 rules 或相符的 overrides 區塊中,獲派 warn 或 error 嚴重程度的所有內建規則,以及 custom_rules 中定義的所有規則。
  3. 嚴重性解析:針對每個有效規則,系統會依序檢查下列設定,並採用第一個指定嚴重性的設定:最後一個相符的 overrides 區塊、全域 rules 區塊、自訂規則本身的 severity,最後是預設嚴重性 (error)。
  4. 已停用的規則:如果規則的已解決嚴重程度為 disabled,系統就會略過該檔案。

設定檔範例

以下範例顯示完整的 lkmlstyle.yaml 檔案,說明基準規則集選取、檔案排除、全域規則自訂、範圍覆寫和自訂規則:

# Schema version
schema_version: 1

# Baseline ruleset edition (all-v1.0 or none)
ruleset_version: "all-v1.0"

# Files completely ignored by the style validator
ignore_files:
  - "vendor/**"
  - "*.ignore.lkml"
  - "legacy_dashboards/*.dashboard.lookml"

# Built-in rule customizations
rules:
  view-dimension-order:
    severity: warn
  numeric-measure-value-format-presence:
    severity: warn
  sql-table-name-uniqueness:
    severity: error
  # Replaced by the custom first_child rule below
  primary-key-first-dimension:
    severity: disabled

# Directory/file scoped overrides
overrides:
  - files:
      - "views/staging/**"
    rules:
      visible-dimension-description-presence:
        severity: disabled
      primary-key-visibility:
        severity: warn

# Custom rules catalog
custom_rules:
  # 1. Pattern Match: Finance dimensions must start with fin_
  - name: finance-dimension-prefix
    title: "Finance dimensions must be prefixed with fin_"
    rule_type: pattern_match
    severity: error
    rationale: "Ensures clarity in the field picker for finance metrics."
    select: "view.dimension"
    filters:
      view_label: "Finance"
    match: "^fin_[a-z0-9_]+$"

  # 2. Pattern Match: Forbid draft or test views
  - name: forbid-draft-views
    title: "Views cannot be named with draft_ or test_ prefixes"
    rule_type: pattern_match
    severity: error
    select: "view"
    should_not_match: "^(draft|test)_.*"

  # 3. Property: Require explicit relationship on joins
  - name: require-join-relationship
    title: "All joins must declare an explicit relationship"
    rule_type: property
    severity: error
    select: "explore.join"
    requires_child: "relationship"

  # 4. Property: Explores must not use sql_always_where
  - name: forbid-sql-always-where
    title: "Explores should use always_filter instead of sql_always_where"
    rule_type: property
    severity: warn
    select: "explore"
    forbidden_child: "sql_always_where"

  # 5. Order: Dimension groups inside views must be alphabetical
  - name: view-dimension-groups-alphabetical
    title: "Dimension groups must appear in alphabetical order within views"
    rule_type: order
    severity: warn
    select: "view"
    order_by: "dimension_group"

  # 6. First Child: Primary key must be the first dimension
  - name: custom-primary-key-first-dimension
    title: "The primary key must be defined as the first dimension in the view"
    rule_type: first_child
    severity: error
    select: "view.dimension"
    filters:
      primary_key: true
    position: first

  # 7. Unique: Views must not share the same label
  - name: unique-view-labels
    title: "Views must have unique labels"
    rule_type: unique
    severity: warn
    select: "view"
    unique_property: "label"

驗證範圍和結果

以下各節說明樣式驗證器會檢查哪些檔案,以及如何回報驗證結果:

已驗證的檔案

  • 系統只會驗證根專案中的 .lkml 和 .lookml 檔案。系統不會驗證匯入的 (本機或遠端) 依附元件專案。
  • 系統會根據每個檔案的內容進行驗證。系統不會遵循 include: 陳述式,也不會驗證透過 include: 陳述式擷取的物件是否屬於包含檔案。
  • 由 dbt Cloud CI 工作觸發的 CI 執行作業會驗證正式版 LookML 分支版本,而非開發分支版本。

通過或失敗行為和輸出內容

  • 只有在至少有一項診斷結果的嚴重程度為 error 時,樣式驗證工具才會執行失敗。單獨的警告不會導致執行失敗。
  • 在 CI 執行結果頁面中,每項診斷結果都會顯示規則名稱、路徑、行號、內容程式碼片段,以及規則說明文件連結。如要進一步瞭解如何執行套件及查看結果,請參閱「執行持續整合套件」和「查看 CI 執行結果」。
  • 如果設定檔無效,設定檔第 1 行會產生單一 invalid-config 錯誤,且驗證作業會失敗。

增量驗證

如要啟用 Style Validator 的增量驗證,請在建立或編輯持續整合套件時,選取「Style Validator」部分中的「Only incremental errors」(僅增量錯誤) 核取方塊 (預設為啟用)。

啟用增量驗證後,樣式驗證器只會回報開發分支中新發生的違規事項:

  1. 驗證開發分支版本。
  2. 系統會使用開發分支的設定檔驗證目標分支。
  3. 系統只會回報目標分支版本中沒有的違規事項。

啟用增量驗證時,請注意下列行為:

  • 目標分支中先前存在的違規事項不會導致執行失敗。
  • 由於開發分支的設定檔會用於驗證兩個分支,因此開發分支的設定變更無法隱藏先前存在的違規事項,或讓先前存在的 LookML 顯示為新的違規事項。
  • 開發分支必須包含 lkmlstyle.yaml (或 lkmlstyle.yml) 設定檔,否則執行作業會失敗,並顯示缺少設定的錯誤訊息。

如果停用「僅限增量錯誤」,系統會回報驗證分支中發現的所有違規事項。

內建規則目錄

下表列出 all-v1.0 規則集中的所有 25 項標準內建規則:

規則名稱 目標實體 規則摘要
average-measure-name-prefix 度量 含有 type: average 或 average_distinct 的指標必須以 avg_ 或 average_ 開頭。
boolean-dimension-name-prefix 維度 Yesno 維度必須以 is_、has_ 或 does_ 開頭。
count-measure-name-prefix 度量 含有 type: count 或 count_distinct 的度量必須以 count_ 開頭。
dimension-group-name-suffix 維度群組 維度群組不得以 _at、_date 或 _time 結尾。
dimension-label-redundant-yes-no 維度 「是/否」維度標籤不得包含「是/否」標記,例如 (Yes / No) 或 (yes/no) (任何大小寫或間距)。
dimension-name-snake-case 維度 維度和維度群組名稱必須使用小寫 snake_case。
explore-fields-presence 探索 探索應定義 fields: 屬性。
explore-label-presence 探索 探索必須定義明確的 label: 屬性。
includes-wildcard-usage 包含 include: 陳述式不應使用檢視區塊檔案的萬用字元 (例如 *.view.lkml 或 /views/*.view)。系統不會標記其他萬用字元。
join-relationship-presence 加入 探索聲明必須指定join:relationship:。
measure-name-snake-case 度量 指標名稱必須使用小寫 snake_case。
measure-sql-table-reference 度量 測量指標必須使用 ${dimension_name} 參照維度,而非 ${TABLE}.column。
numeric-measure-value-format-presence 度量 使用 type: count、sum、average 或 number 的指標必須指定 value_format: 或 value_format_name:。
pdt-view-name-prefix 查看 永久衍生資料表 (PDT) 應以 pdt_ 開頭。如果檢視區塊設定 derived_table、datagroup_trigger、sql_trigger_value、interval_trigger 或 persist_for,或設定 materialized_view: yes,則該檢視區塊會計為 PDT。
primary-key-first-dimension 維度 主鍵維度必須是檢視區塊中定義的第一個維度。
primary-key-visibility 維度 主鍵維度應隱藏 (hidden: yes)。
sql-table-name-uniqueness 查看 多個檢視區塊不應指向完全相同的 sql_table_name。
sum-measure-name-prefix 度量 含有 type: sum 或 sum_distinct 的指標必須以 sum_ 或 total_ 開頭。
view-dimension-order 查看 檢視區塊中的維度必須依字母順序排列。
view-label-presence 查看 檢視區塊必須定義明確的 label:。
view-measure-order 查看 資料檢視中的指標必須依字母順序排列。
view-name-snake-case 查看 檢視區塊名稱必須為小寫 snake_case (可使用開頭 + 進行精細調整)。
view-primary-key-presence 查看 含有 sql_table_name 或 derived_table (且沒有 extends) 的檢視區塊必須定義主鍵。
visible-dimension-description-presence 維度 可見維度必須有 description:。
visible-measure-description-presence 度量 可見的度量必須有 description:。

疑難排解

以下各節說明排解樣式驗證器問題時,常見的設定問題和支援的語法變化:

設定錯誤

載入設定檔時,系統會拒絕下列問題,並回報 invalid-config 錯誤:

  • 不明頂層鍵,或規則設定中的不明鍵。
  • 缺少 schema_version 或 ruleset_version,或任一參數的值不受支援。
  • 簡寫純量嚴重程度,例如 rule-name: warn。
  • 缺少或空白的覆寫區塊 files 或 rules,或覆寫區塊內的規則設定沒有 severity。
  • 覆寫區塊中的不明規則名稱。
  • 自訂規則的名稱與其他自訂規則或內建規則重複。
  • 在錯誤的 rule_type 上使用特定類型的鍵 (例如 pattern_match 規則上的 order_by)。
  • 無效的規則運算式。
  • 缺少 order_by 參數 (適用於 order 規則) 或 unique_property 參數 (適用於 unique 規則)。
  • position 值 (first_child 規則除外)。first
  • 篩選器鍵中未加引號的開頭 !,例如 !hidden: true,這是無效的 YAML 標記語法,會導致設定檔無法剖析。

無聲設定問題

  • 系統會直接忽略全域 rules 區塊中拼錯的規則名稱。
  • 在 select、filters、parent_filters、requires_child、forbidden_child 或 order_by 中,如果 LookML 型別名稱拼字錯誤,系統不會引發錯誤。規則永遠不會相符 (或對於 requires_child 而言,永遠會失敗)。
  • 同時指定 match 和 should_not_match,或同時指定 requires_child 和 forbidden_child:系統只會套用每組的第一個參數,並忽略第二個參數。
  • 在 first_child 規則中指定 parent_filters 不會產生任何影響,系統會忽略這項設定。
  • 篩選器只會比對在 LookML 檔案中明確宣告的屬性,不會比對 LookML 預設值 (請參閱篩選器語法)。
  • 除非使用 ^ 和 $ 固定規則運算式模式,否則 pattern_match 規則中的模式會比對子字串 (請參閱pattern_match)。

可接受的語法變體

  • severity 和 rule_type 的值不區分大小寫。
  • rule_type: pattern 已接受做為 pattern_match 的別名。
  • 系統會忽略 ruleset_version 中開頭和結尾的空白字元。