# Tangu Static Lint Rules (110 rules)

Run `tangu lint` or `tangu fix` across any workspace. Suppress a specific rule on the next form with `; #allow(<rule-code>)`.

## Correctness (21)

### `cond-unreachable-clauses` (warning · auto-fixable)

Detects unreachable clauses in `cond` and `when` expressions.

```tangu
; #allow(cond-unreachable-clauses)
```

### `discarded-continue-value` (warning · auto-fixable)

Warns when `(continue val)` passes a value inside a loop that discards it.

```tangu
; #allow(discarded-continue-value)
```

### `division-by-zero` (warning)

Detects division or modulo by constant zero literals.

```tangu
; #allow(division-by-zero)
```

### `duplicate-cond-predicate` (warning)

Detects duplicated predicates in `cond` branches.

```tangu
; #allow(duplicate-cond-predicate)
```

### `duplicate-def-in-block` (warning)

Detects duplicate `def` declarations and `def`/`let` collisions within the same block scope.

```tangu
; #allow(duplicate-def-in-block)
```

### `duplicate-map-keys` (warning)

Detects duplicate keys in Map literals.

```tangu
; #allow(duplicate-map-keys)
```

### `duplicate-set-entries` (warning)

Detects duplicate entries in Set literals.

```tangu
; #allow(duplicate-set-entries)
```

### `duplicate-when-patterns` (warning · auto-fixable)

Detects duplicate `when` patterns or unreachable branches.

```tangu
; #allow(duplicate-when-patterns)
```

### `for-in-value-position` (warning · auto-fixable)

Warns when `(for ...)` is used in a value-producing position where `for->seq` is required.

```tangu
; #allow(for-in-value-position)
```

### `hardcoded-secret` (warning)

Warns when credential-named variables or map keys are assigned hardcoded string literals.

```tangu
; #allow(hardcoded-secret)
```

### `i18n-bundle-parity` (warning)

Validates key, plural `:other`, and `{placeholder}` parity across locales in `Bundle`.

```tangu
; #allow(i18n-bundle-parity)
```

### `impossible-branch` (warning)

Detects conditional branches that can never execute.

```tangu
; #allow(impossible-branch)
```

### `ineffective-none-guard` (warning)

Detects None checks that fail to guard against nil dereferences.

```tangu
; #allow(ineffective-none-guard)
```

### `invalid-struct-field-constraint` (warning)

Warns about invalid, contradictory, or type-mismatched struct field constraints.

```tangu
; #allow(invalid-struct-field-constraint)
```

### `invalid-struct-literal-value` (warning)

Warns about literal struct arguments that violate field constraint annotations.

```tangu
; #allow(invalid-struct-literal-value)
```

### `missing-else-wrapper` (warning · auto-fixable)

Detects 3-argument `(if cond then else)` expressions where the 2nd branch is missing `(else ...)`.

```tangu
; #allow(missing-else-wrapper)
```

### `shell-injection` (warning)

Warns when interpolating or concatenating dynamic values into shell command strings passed to `process/exec` or `process/shell`.

```tangu
; #allow(shell-injection)
```

### `suspicious-equality` (warning)

Warns when equality checks compare incompatible types.

```tangu
; #allow(suspicious-equality)
```

### `suspicious-try` (warning)

Detects `(try ...)` on optional lookups where `()` early-returns prematurely.

```tangu
; #allow(suspicious-try)
```

### `tautological-boolean` (warning · auto-fixable)

Detects tautological or contradictory boolean expressions (e.g. `(and a a)`).

```tangu
; #allow(tautological-boolean)
```

### `test-assertions` (warning · auto-fixable)

Detects unasserted comparison expressions in `#test` functions and test functions with zero assertions.

```tangu
; #allow(test-assertions)
```

## Types (3)

### `missing-trait-bound` (warning)

Warns about missing trait bounds on generic parameters.

```tangu
; #allow(missing-trait-bound)
```

### `missing-var-annotation` (warning · auto-fixable)

Warns when variable bindings lack required type annotations.

```tangu
; #allow(missing-var-annotation)
```

### `mut-param-requires-mut` (warning · auto-fixable)

Warns when a mutable parameter does not have mutable binding.

```tangu
; #allow(mut-param-requires-mut)
```

## Imports (14)

### `deprecated-usage` (warning)

Detects usage of functions, modules, or bindings marked with `@deprecated`.

```tangu
; #allow(deprecated-usage)
```

### `duplicate-function-parameter-names` (warning)

Detects duplicate parameter names in function signatures.

```tangu
; #allow(duplicate-function-parameter-names)
```

### `duplicate-imports` (warning · auto-fixable)

Detects duplicate `use` statements importing the same module or symbol.

```tangu
; #allow(duplicate-imports)
```

### `empty-import` (warning · auto-fixable)

Disallows empty brace imports `(use {} /mod)`; use `(use _ /mod)` for side-effect-only imports.

```tangu
; #allow(empty-import)
```

### `forbidden-dot-imports` (warning · auto-fixable)

Warns against using forbidden trailing dot imports `(use ... .)`.

```tangu
; #allow(forbidden-dot-imports)
```

### `invalid-lazy-import` (warning)

Reports `#lazy` `(use ...)` forms that are unsupported at runtime.

```tangu
; #allow(invalid-lazy-import)
```

### `nonexistent-modules` (warning)

Detects `use` statements importing from non-existent modules.

```tangu
; #allow(nonexistent-modules)
```

### `redundant-prelude-imports` (warning · auto-fixable)

Warns when importing symbols that are already available in the standard prelude.

```tangu
; #allow(redundant-prelude-imports)
```

### `same-directory-use` (warning · auto-fixable)

Warns about redundant module prefixes when using sibling files.

```tangu
; #allow(same-directory-use)
```

### `shadowing-globals` (warning)

Warns when local variables shadow prelude symbols or top-level module definitions.

```tangu
; #allow(shadowing-globals)
```

### `shadowing-imports` (warning)

Warns when local definitions shadow imported symbols.

```tangu
; #allow(shadowing-imports)
```

### `undefined-imported-names` (warning)

Detects imports of symbols that are not exported by target modules.

```tangu
; #allow(undefined-imported-names)
```

### `undefined-variables` (warning)

Detects references to variables that are not defined in the current scope.

```tangu
; #allow(undefined-variables)
```

### `unsorted-imports` (warning · auto-fixable)

Enforces that top-level (use ...) imports are sorted alphabetically by module path within contiguous import blocks.

```tangu
; #allow(unsorted-imports)
```

## HTML / SHTML (17)

### `html-accessible-name` (warning)

Ensures interactive elements (<button>, <a>) have accessible text or aria-label.

```tangu
; #allow(html-accessible-name)
```

### `html-anchor-valid-href` (warning)

Flags anchor tags with missing or dummy href attributes (such as # or javascript:).

```tangu
; #allow(html-anchor-valid-href)
```

### `html-aria-validity` (warning)

Flags invalid/misspelled ARIA roles and attributes, and redundant roles on semantic HTML tags.

```tangu
; #allow(html-aria-validity)
```

### `html-boolean-attribute-strings` (warning · auto-fixable)

Flags boolean attributes assigned string values ("false" or "true") and provides autofix to boolean literals.

```tangu
; #allow(html-boolean-attribute-strings)
```

### `html-button-missing-type` (warning · auto-fixable)

Ensures <button> elements explicitly declare a :type attribute ("button", "submit", or "reset").

```tangu
; #allow(html-button-missing-type)
```

### `html-conflicting-id` (warning)

Detects conflicting element IDs when both a tag shortcut `#id` and an `:id` attribute (or multiple `#id` shortcuts) are specified on the same element.

```tangu
; #allow(html-conflicting-id)
```

### `html-deprecated-elements` (warning)

Flags obsolete and deprecated HTML tags (e.g. marquee, font, center, strike, tt).

```tangu
; #allow(html-deprecated-elements)
```

### `html-duplicate-class` (warning · auto-fixable)

Detects duplicate CSS class names in element tag shortcuts or `:class` attributes.

```tangu
; #allow(html-duplicate-class)
```

### `html-duplicate-id` (warning)

Flags duplicate static HTML element IDs in the same template tree.

```tangu
; #allow(html-duplicate-id)
```

### `html-img-missing-alt` (warning)

Requires <img> elements to have an alt attribute.

```tangu
; #allow(html-img-missing-alt)
```

### `html-input-missing-label` (warning)

Ensures form inputs (<input>, <select>, <textarea>) are associated with a label.

```tangu
; #allow(html-input-missing-label)
```

### `html-invalid-nesting` (warning)

Detects invalid parent-child element nesting forbidden by HTML5.

```tangu
; #allow(html-invalid-nesting)
```

### `html-no-inline-event-handlers` (warning)

Disallows inline DOM event handler attributes (e.g. `:onclick`, `:onsubmit`) in favor of `addEventListener` in module scripts.

```tangu
; #allow(html-no-inline-event-handlers)
```

### `html-prefer-semantic-elements` (warning · auto-fixable)

Suggests replacing generic <div> elements with native semantic landmark elements (header, nav, main, footer, aside, article).

```tangu
; #allow(html-prefer-semantic-elements)
```

### `html-target-blank-rel` (warning · auto-fixable)

Ensures <a> elements with target="_blank" specify rel="noopener noreferrer" to prevent security risks.

```tangu
; #allow(html-target-blank-rel)
```

### `html-unsafe-raw` (warning)

Warns when unescaped string interpolation or concatenation is used inside `:!raw` or `#html` strings.

```tangu
; #allow(html-unsafe-raw)
```

### `html-void-element-children` (warning)

Flags void elements containing child elements or text content.

```tangu
; #allow(html-void-element-children)
```

## CSS (4)

### `css-empty-rule` (warning)

Detects empty CSS rules with no declarations and no nested child rules.

```tangu
; #allow(css-empty-rule)
```

### `css-shorthand-override` (warning)

Detects CSS shorthand properties declared after their constituent longhand properties in the same rule.

```tangu
; #allow(css-shorthand-override)
```

### `css-unknown-custom-property` (warning)

Warns when `var(--token)` references a CSS custom property not defined locally or in workspace CSS tokens.

```tangu
; #allow(css-unknown-custom-property)
```

### `css-zero-length-unit` (warning · auto-fixable)

Suggests omitting redundant length units on zero values (e.g. `"0"` instead of `"0px"`).

```tangu
; #allow(css-zero-length-unit)
```

## Performance (2)

### `accumulating-concat-in-loop` (warning)

Detects quadratic O(N^2) string or array concatenation reassignment inside a loop body.

```tangu
; #allow(accumulating-concat-in-loop)
```

### `prefer-iter-find-or-any` (warning · auto-fixable)

Suggests lazy `(iter/find ...)` or `(iter/any? ...)` instead of materializing `(iter/filter ...)` just to inspect the first element or emptiness.

```tangu
; #allow(prefer-iter-find-or-any)
```

## Complexity (2)

### `deep-nesting` (warning)

Warns when code exceeds the recommended nesting depth threshold.

```tangu
; #allow(deep-nesting)
```

### `too-many-parameters` (warning)

Warns when functions exceed the recommended parameter count threshold.

```tangu
; #allow(too-many-parameters)
```

## Redundancy (22)

### `collapsible-if` (warning · auto-fixable)

Suggests collapsing nested `if` statements into a single `if` with `and`.

```tangu
; #allow(collapsible-if)
```

### `dead-reassignment` (warning)

Detects variables reassigned before their previous value was used.

```tangu
; #allow(dead-reassignment)
```

### `discarded-for-seq` (warning · auto-fixable)

Detects `(for->seq ...)` in statement positions where the generated Array is dropped.

```tangu
; #allow(discarded-for-seq)
```

### `needless-return` (warning · auto-fixable)

Suggests removing explicit `(return ...)` from tail expressions or redundant `()` in `(return ())`.

```tangu
; #allow(needless-return)
```

### `prefer-compact` (warning · auto-fixable)

Suggests using `(iter/compact xs)` instead of filtering with `is-some?`.

```tangu
; #allow(prefer-compact)
```

### `prefer-compound-assignment` (warning · auto-fixable)

Suggests using compound assignment operators (+<-, -<-, *<-, /<-) instead of verbose reassignment.

```tangu
; #allow(prefer-compound-assignment)
```

### `redundant-cast` (warning · auto-fixable)

Warns when an explicit `(cast Type expr)` call is redundant because `expr` already has type `Type`.

```tangu
; #allow(redundant-cast)
```

### `redundant-closure` (warning · auto-fixable)

Warns about redundant closures `(Func [x] (f x))` that can be simplified.

```tangu
; #allow(redundant-closure)
```

### `redundant-comparison-with-boolean` (warning · auto-fixable)

Warns about comparing expressions directly with boolean literals.

```tangu
; #allow(redundant-comparison-with-boolean)
```

### `redundant-do` (warning · auto-fixable)

Warns about redundant `(do ...)` expressions inside sequences.

```tangu
; #allow(redundant-do)
```

### `redundant-else` (warning · auto-fixable)

Warns about redundant `else` branches.

```tangu
; #allow(redundant-else)
```

### `redundant-if-boolean` (warning · auto-fixable)

Warns about `(if cond true false)` patterns.

```tangu
; #allow(redundant-if-boolean)
```

### `redundant-optional-field-wrap` (warning · auto-fixable)

Warns about redundant wrapping of optional struct fields.

```tangu
; #allow(redundant-optional-field-wrap)
```

### `redundant-unit` (warning · auto-fixable)

Suggests removing redundant `()` from the end of a function or block when it already returns `()`.

```tangu
; #allow(redundant-unit)
```

### `redundant-var-annotation` (warning · auto-fixable)

Warns about redundant type annotations on variable declarations.

```tangu
; #allow(redundant-var-annotation)
```

### `self-binding` (warning · auto-fixable)

Warns when a variable is bound to itself without transformation.

```tangu
; #allow(self-binding)
```

### `unreachable-code` (warning)

Detects expressions following unconditional jumps (return, throw).

```tangu
; #allow(unreachable-code)
```

### `unused-function-parameters` (warning)

Detects function parameters that are never referenced.

```tangu
; #allow(unused-function-parameters)
```

### `unused-imports` (warning · auto-fixable)

Detects imported modules or names that are never referenced.

```tangu
; #allow(unused-imports)
```

### `unused-loop-variable` (warning · auto-fixable)

Detects iteration variables in for or for->seq loops that are never referenced.

```tangu
; #allow(unused-loop-variable)
```

### `unused-values` (warning)

Detects expressions evaluated in sequence whose results are discarded.

```tangu
; #allow(unused-values)
```

### `unused-variables` (warning · auto-fixable)

Detects variables that are declared with `let` but never referenced.

```tangu
; #allow(unused-variables)
```

## Style (25)

### `def-annotation-placement` (warning · auto-fixable)

Enforces that declaration attributes (#pub, #inline, #test, #(doc ...)) are placed preceding (def ...) rather than inside it.

```tangu
; #allow(def-annotation-placement)
```

### `def-destructuring` (warning · auto-fixable)

Warns when `def` is used for pattern destructuring instead of `let`.

```tangu
; #allow(def-destructuring)
```

### `func-signature-convention` (warning · auto-fixable)

Enforces canonical Func parameter syntax: nullary functions use (), single parameters unwrap brackets, and multi-parameters use [a b ...].

```tangu
; #allow(func-signature-convention)
```

### `missing-doc` (warning)

Warns about missing documentation comments on public functions and types.

```tangu
; #allow(missing-doc)
```

### `names` (warning)

The symbol naming convention lint (kebab-case, lengths, valid identifiers).

```tangu
; #allow(names)
```

### `predicate-and-boolean-naming` (warning)

Enforces that predicate functions end with `?`, while variables, parameters, and map keys do not end with `?`.

```tangu
; #allow(predicate-and-boolean-naming)
```

### `prefer-colon-shorthand` (warning · auto-fixable)

Suggests using colon shorthand syntax for keyword args and properties.

```tangu
; #allow(prefer-colon-shorthand)
```

### `prefer-cond-over-if` (warning · auto-fixable)

Suggests using `(cond ...)` when multiple nested `if` expressions are chained.

```tangu
; #allow(prefer-cond-over-if)
```

### `prefer-is-a` (warning · auto-fixable)

Suggests using `(is-a? ...)` for type checking patterns.

```tangu
; #allow(prefer-is-a)
```

### `prefer-is-empty` (warning · auto-fixable)

Suggests using `(is-empty? ...)` over `(== (count-of ...) 0)`.

```tangu
; #allow(prefer-is-empty)
```

### `prefer-multi-remove` (warning · auto-fixable)

Suggests using multi-key (remove coll k1 k2 ...) instead of nested (remove (remove coll k1) k2) calls.

```tangu
; #allow(prefer-multi-remove)
```

### `prefer-not-equal` (warning · auto-fixable)

Suggests using `(!= a b)` instead of `(not (== a b))`.

```tangu
; #allow(prefer-not-equal)
```

### `prefer-optional-key-path` (warning · auto-fixable)

Suggests using optional key path syntax.

```tangu
; #allow(prefer-optional-key-path)
```

### `prefer-put-all` (warning · auto-fixable)

Suggests using `put-all` instead of multiple consecutive `put` calls.

```tangu
; #allow(prefer-put-all)
```

### `prefer-range-shorthand` (warning · auto-fixable)

Suggests using range shorthand syntax `0..10` over `(range 0 10)`.

```tangu
; #allow(prefer-range-shorthand)
```

### `prefer-say` (warning · auto-fixable)

Suggests using `(say ...)` instead of the legacy `(echo ...)` alias for console output.

```tangu
; #allow(prefer-say)
```

### `prefer-some-or` (warning · auto-fixable)

Suggests using `(some-or ...)` instead of verbose None checking.

```tangu
; #allow(prefer-some-or)
```

### `prefer-string-interpolation` (warning · auto-fixable)

Suggests using string template interpolation instead of `concat` / `format`.

```tangu
; #allow(prefer-string-interpolation)
```

### `prefer-unless` (warning · auto-fixable)

Suggests using `(unless ...)` over `(if (not ...) ...)`. 

```tangu
; #allow(prefer-unless)
```

### `prefer-when-over-cond` (warning · auto-fixable)

Suggests using `(when ...)` for single branch conditions.

```tangu
; #allow(prefer-when-over-cond)
```

### `sql-interpolation` (warning · auto-fixable)

Warns about improper string interpolation in SQL queries.

```tangu
; #allow(sql-interpolation)
```

### `struct-and-trait-naming` (warning · auto-fixable)

Enforces capitalized kebab-case for multi-word structs and traits.

```tangu
; #allow(struct-and-trait-naming)
```

### `struct-field-annotation-convention` (warning · auto-fixable)

Enforces canonical kebab-case naming for struct field annotation keys.

```tangu
; #allow(struct-field-annotation-convention)
```

### `top-level-let-function` (warning · auto-fixable)

Suggests top-level function definitions.

```tangu
; #allow(top-level-let-function)
```

### `triple-quotes` (warning)

Suggests using triple-quotes `"""` for multi-line strings.

```tangu
; #allow(triple-quotes)
```
