Green.Rules.Linting.TrueInCond (green v0.2.0)

Copy Markdown

This rule warns when final, always-matching clauses in cond do not use true.

Configuration

This rule is enabled by default, but can be disabled globally in the configuration file.

The rule can also be configured to ignore specific files, or specific lines in specific files. This is useful for cases where applying the rule would be problematic.

In .formatter.exs:

  green: [
    true_in_cond: [
      enabled: *true | false,
      except: [
        "path/to/file.exs",
        {"path/to/other_file.exs", 42},
        {"path/to/yet_another_file.exs", [10, 20, 30]}
      ]
    ]
  ]

Examples

cond do
  is_list(param) ->
    :list

  :other ->
    :other
end

In the example above, the final clause should use true instead of :other.