has_forbidden_code

Rule: has_forbidden_code

Manifest Rule

has_forbidden_code details
This rule checks if code contains forbidden patterns. Use it to enforce coding standards by flagging undesired patterns such as `SELECT *` statements, hardcoded references, or any other string patterns that should not appear in your dbt code.

Configuration

  • type: Must be has_forbidden_code.
  • forbidden_patterns: List of string patterns that are not allowed in the code. Each pattern is matched as a substring.
  • case_sensitive: (optional) Whether pattern matching should be case-sensitive. Defaults to false (case-insensitive).
  • applies_to: (optional) List of dbt object types to check.
    • Default: ["models", "snapshots", "macros"]
    • Options: models, snapshots, macros
Common Rule Config
  • name: Human-readable name of the rule.
  • severity: "error" (fail) or "warning" (warn only).
    • (optional, defaults to "error" if not specified)
  • description: Human-readable explanation of the rule.
  • category: Override the default rule category. Included in structured output (JSON, CSV, NDJSON) but not in the CLI table. Each rule has a built-in default (e.g. documentation, naming, testing, governance, structure, performance).
    • (optional, defaults to the rule type's built-in category)
  • includes: List of patterns to explicitly include for this rule. See Includes & Excludes for pattern syntax and examples.
  • excludes: List of patterns to explicitly exclude from this rule. See Includes & Excludes for pattern syntax and examples.
  • model_materializations: Filter models by materialization type. Only applies when applies_to includes models.
    • (optional, if not specified all materializations are included)
    • Built-in types: table, view, incremental, ephemeral, materialized_view. Custom materializations are also supported.
    • Example: ["table", "incremental"]

Example Config

manifest_tests:
  # Forbid SELECT * in models (case-insensitive by default)
  - name: "no_select_star"
    type: "has_forbidden_code"
    forbidden_patterns: ["SELECT *"]
    description: "Models should not use SELECT *."
    # case_sensitive: false  (optional, default)
    # severity: "warning"  (optional)
    # applies_to: ['models', 'snapshots'] (optional)
    # includes: ["path/to/include/*"]
    # excludes: ["path/to/exclude/*"]

  # Case-sensitive match for exact patterns
  - name: "no_hardcoded_schema"
    type: "has_forbidden_code"
    forbidden_patterns: ["raw_prod.", "analytics_prod."]
    case_sensitive: true
    severity: "warning"
    description: "Use dbt selectors"
# Forbid SELECT * in models (case-insensitive by default)
[[manifest_tests]]
name = "no_select_star"
type = "has_forbidden_code"
forbidden_patterns = ["SELECT *"]
description = "Models should not use SELECT *."
# case_sensitive = false  # (optional, default)
# severity = "warning"  # (optional)
# applies_to = ["models", "snapshots"]  # (optional)
# includes = ["path/to/include/*"]
# excludes = ["path/to/exclude/*"]

# Case-sensitive match for exact patterns
[[manifest_tests]]
name = "no_hardcoded_schema"
type = "has_forbidden_code"
forbidden_patterns = ["raw_prod.", "analytics_prod."]
case_sensitive = true
severity = "warning"
description = "Use dbt selectors"
# Forbid SELECT * in models (case-insensitive by default)
[[tool.dbtective.manifest_tests]]
name = "no_select_star"
type = "has_forbidden_code"
forbidden_patterns = ["SELECT *"]
description = "Models should not use SELECT *."
# case_sensitive = false  # (optional, default)
# severity = "warning"  # (optional)
# applies_to = ["models", "snapshots"]  # (optional)
# includes = ["path/to/include/*"]
# excludes = ["path/to/exclude/*"]

# Case-sensitive match for exact patterns
[[tool.dbtective.manifest_tests]]
name = "no_hardcoded_schema"
type = "has_forbidden_code"
forbidden_patterns = ["raw_prod.", "analytics_prod."]
case_sensitive = true
severity = "warning"
description = "Use dbt selectors"
Relevant dbt code
-- models/clean_model.sql (PASS - no forbidden patterns)
SELECT
    id,
    name
FROM users
WHERE active = true

-- models/star_model.sql (FAIL - contains 'SELECT *')
SELECT * FROM users
-- Also matches: select * from users (case-insensitive by default)