Skip to content

Commit

Permalink
Update changelog, docs for :if-nil-return
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdl89 committed Dec 9, 2024
1 parent 44d012d commit 29e2027
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 106 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ For a list of breaking changes, check [here](#breaking-changes).

## Unreleased

- [#2272](https://github.com/clj-kondo/clj-kondo/issues/2451): Lint for nil return from if-like forms
- [#2272](https://github.com/clj-kondo/clj-kondo/issues/2272): Report var usage in `if-let` etc condition as always truthy
- [#2272](https://github.com/clj-kondo/clj-kondo/issues/2272): Report var usage in `if-not` condition as always truthy
- [#2433](https://github.com/clj-kondo/clj-kondo/issues/2433): false positive redundant ignore with hook
Expand Down
227 changes: 121 additions & 106 deletions doc/linters.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,111 +7,112 @@ configuration. For general configurations options, go [here](config.md).
**Table of Contents**

- [Linters](#linters)
- [Aliased namespace symbol](#aliased-namespace-symbol)
- [Aliased namespace var usage](#aliased-namespace-var-usage)
- [Case](#case)
- [Case duplicate test](#case-duplicate-test)
- [Case quoted test](#case-quoted-test)
- [Case symbol test constant](#case-symbol-test-constant)
- [Clj-kondo config](#clj-kondo-config)
- [Cond-else](#cond-else)
- [Condition always true](#condition-always-true)
- [Conflicting-alias](#conflicting-alias)
- [Consistent-alias](#consistent-alias)
- [Datalog syntax](#datalog-syntax)
- [Deprecated var](#deprecated-var)
- [Deprecated namespace](#deprecated-namespace)
- [Deps.edn](#depsedn)
- [Bb.edn](#bbedn)
- [Bb.edn dependency on undefined task](#bbedn-dependency-on-undefined-task)
- [Bb.edn cyclic task dependency](#bbedn-cyclic-task-dependency)
- [Bb.edn Unexpected key](#bbedn-unexpected-key)
- [Bb.edn task docstring missing](#bbedn-task-docstring-missing)
- [Discouraged var](#discouraged-var)
- [Discouraged namespace](#discouraged-namespace)
- [Discouraged tag](#discouraged-tag)
- [Docstring blank](#docstring-blank)
- [Docstring no summary](#docstring-no-summary)
- [Docstring leading trailing whitespace](#docstring-leading-trailing-whitespace)
- [Duplicate map key](#duplicate-map-key)
- [Duplicate require](#duplicate-require)
- [Duplicate set key](#duplicate-set-key)
- [Duplicate field name](#duplicate-field-name)
- [Dynamic vars](#dynamic-vars)
- [Dynamic var not earmuffed](#dynamic-var-not-earmuffed)
- [Earmuffed var not dynamic](#earmuffed-var-not-dynamic)
- [Quoted case test constant](#quoted-case-test-constant)
- [Equals expected position](#equals-expected-position)
- [Equals false](#equals-false)
- [Equals true](#equals-true)
- [File](#file)
- [Format](#format)
- [Def + fn instead of defn](#def--fn-instead-of-defn)
- [Destructured or binding of same map](#destructured-or-binding-of-same-map)
- [Inline def](#inline-def)
- [Invalid arity](#invalid-arity)
- [Conflicting arity](#conflicting-arity)
- [Reduce without initial value](#reduce-without-initial-value)
- [Loop without recur](#loop-without-recur)
- [Line length](#line-length)
- [Keyword in binding vector](#keyword-in-binding-vector)
- [Main without gen-class](#main-without-gen-class)
- [Minus one](#minus-one)
- [Misplaced docstring](#misplaced-docstring)
- [Missing body in when](#missing-body-in-when)
- [Missing clause in try](#missing-clause-in-try)
- [Missing docstring](#missing-docstring)
- [Missing else branch](#missing-else-branch)
- [Missing map value](#missing-map-value)
- [Missing test assertion](#missing-test-assertion)
- [Namespace name mismatch](#namespace-name-mismatch)
- [Non-arg vec return type hint](#non-arg-vec-return-type-hint)
- [Not empty?](#not-empty)
- [Plus one](#plus-one)
- [Private call](#private-call)
- [Protocol method varargs](#protocol-method-varargs)
- [Redefined var](#redefined-var)
- [Var same name except case](#var-same-name-except-case)
- [Redundant do](#redundant-do)
- [Redundant call](#redundant-call)
- [Redundant fn wrapper](#redundant-fn-wrapper)
- [Redundant ignore](#redundant-ignore)
- [Redundant nested call](#redundant-nested-call)
- [Redundant let](#redundant-let)
- [Redundant str call](#redundant-str-call)
- [Refer](#refer)
- [Refer all](#refer-all)
- [Schema misplaced return](#schema-misplaced-return)
- [Self-requiring namespace](#self-requiring-namespace)
- [Single key in](#single-key-in)
- [Single logical operand](#single-logical-operand)
- [Single operand comparison](#single-operand-comparison)
- [Shadowed fn param](#shadowed-fn-param)
- [Shadowed var](#shadowed-var)
- [Static field call](#static-field-call)
- [Syntax](#syntax)
- [Type mismatch](#type-mismatch)
- [Unbound destructuring default](#unbound-destructuring-default)
- [Uninitialized var](#uninitialized-var)
- [Unused alias](#unused-alias)
- [Unused binding](#unused-binding)
- [Unused value](#unused-value)
- [Used underscored bindings](#used-underscored-bindings)
- [Unknown :require option](#unknown-require-option)
- [Unreachable code](#unreachable-code)
- [Unused import](#unused-import)
- [Unresolved namespace](#unresolved-namespace)
- [Unresolved symbol](#unresolved-symbol)
- [:exclude-patterns](#exclude-patterns)
- [Unresolved var](#unresolved-var)
- [Unsorted imports](#unsorted-imports)
- [Unsorted required namespaces](#unsorted-required-namespaces)
- [Unused namespace](#unused-namespace)
- [Unused private var](#unused-private-var)
- [Unused referred var](#unused-referred-var)
- [Use](#use)
- [Warn on reflection](#warn-on-reflection)
- [Underscore in namespace](#underscore-in-namespace)
- [Aliased namespace symbol](#aliased-namespace-symbol)
- [Aliased namespace var usage](#aliased-namespace-var-usage)
- [Case](#case)
- [Case duplicate test](#case-duplicate-test)
- [Case quoted test](#case-quoted-test)
- [Case symbol test constant](#case-symbol-test-constant)
- [Clj-kondo config](#clj-kondo-config)
- [Cond-else](#cond-else)
- [Condition always true](#condition-always-true)
- [Conflicting-alias](#conflicting-alias)
- [Consistent-alias](#consistent-alias)
- [Datalog syntax](#datalog-syntax)
- [Deprecated var](#deprecated-var)
- [Deprecated namespace](#deprecated-namespace)
- [Deps.edn](#depsedn)
- [Bb.edn](#bbedn)
- [Bb.edn dependency on undefined task](#bbedn-dependency-on-undefined-task)
- [Bb.edn cyclic task dependency](#bbedn-cyclic-task-dependency)
- [Bb.edn Unexpected key](#bbedn-unexpected-key)
- [Bb.edn task docstring missing](#bbedn-task-docstring-missing)
- [Discouraged var](#discouraged-var)
- [Discouraged namespace](#discouraged-namespace)
- [Discouraged tag](#discouraged-tag)
- [Docstring blank](#docstring-blank)
- [Docstring no summary](#docstring-no-summary)
- [Docstring leading trailing whitespace](#docstring-leading-trailing-whitespace)
- [Duplicate map key](#duplicate-map-key)
- [Duplicate require](#duplicate-require)
- [Duplicate set key](#duplicate-set-key)
- [Duplicate field name](#duplicate-field-name)
- [Dynamic vars](#dynamic-vars)
- [Dynamic var not earmuffed](#dynamic-var-not-earmuffed)
- [Earmuffed var not dynamic](#earmuffed-var-not-dynamic)
- [Quoted case test constant](#quoted-case-test-constant)
- [Equals expected position](#equals-expected-position)
- [Equals false](#equals-false)
- [Equals true](#equals-true)
- [File](#file)
- [Format](#format)
- [Def + fn instead of defn](#def--fn-instead-of-defn)
- [Destructured or binding of same map](#destructured-or-binding-of-same-map)
- [Inline def](#inline-def)
- [Invalid arity](#invalid-arity)
- [Conflicting arity](#conflicting-arity)
- [Reduce without initial value](#reduce-without-initial-value)
- [Loop without recur](#loop-without-recur)
- [Line length](#line-length)
- [Keyword in binding vector](#keyword-in-binding-vector)
- [Main without gen-class](#main-without-gen-class)
- [Minus one](#minus-one)
- [Misplaced docstring](#misplaced-docstring)
- [Missing body in when](#missing-body-in-when)
- [Missing clause in try](#missing-clause-in-try)
- [Missing docstring](#missing-docstring)
- [Missing else branch](#missing-else-branch)
- [Missing map value](#missing-map-value)
- [Missing test assertion](#missing-test-assertion)
- [Namespace name mismatch](#namespace-name-mismatch)
- [Nil return from if-like forms](#nil-return-from-if-like-forms)
- [Non-arg vec return type hint](#non-arg-vec-return-type-hint)
- [Not empty?](#not-empty)
- [Plus one](#plus-one)
- [Private call](#private-call)
- [Protocol method varargs](#protocol-method-varargs)
- [Redefined var](#redefined-var)
- [Var same name except case](#var-same-name-except-case)
- [Redundant do](#redundant-do)
- [Redundant call](#redundant-call)
- [Redundant fn wrapper](#redundant-fn-wrapper)
- [Redundant ignore](#redundant-ignore)
- [Redundant nested call](#redundant-nested-call)
- [Redundant let](#redundant-let)
- [Redundant str call](#redundant-str-call)
- [Refer](#refer)
- [Refer all](#refer-all)
- [Schema misplaced return](#schema-misplaced-return)
- [Self-requiring namespace](#self-requiring-namespace)
- [Single key in](#single-key-in)
- [Single logical operand](#single-logical-operand)
- [Single operand comparison](#single-operand-comparison)
- [Shadowed fn param](#shadowed-fn-param)
- [Shadowed var](#shadowed-var)
- [Static field call](#static-field-call)
- [Syntax](#syntax)
- [Type mismatch](#type-mismatch)
- [Unbound destructuring default](#unbound-destructuring-default)
- [Uninitialized var](#uninitialized-var)
- [Unused alias](#unused-alias)
- [Unused binding](#unused-binding)
- [Unused value](#unused-value)
- [Used underscored bindings](#used-underscored-bindings)
- [Unknown :require option](#unknown-require-option)
- [Unreachable code](#unreachable-code)
- [Unused import](#unused-import)
- [Unresolved namespace](#unresolved-namespace)
- [Unresolved symbol](#unresolved-symbol)
- [:exclude-patterns](#exclude-patterns)
- [Unresolved var](#unresolved-var)
- [Unsorted imports](#unsorted-imports)
- [Unsorted required namespaces](#unsorted-required-namespaces)
- [Unused namespace](#unused-namespace)
- [Unused private var](#unused-private-var)
- [Unused referred var](#unused-referred-var)
- [Use](#use)
- [Warn on reflection](#warn-on-reflection)
- [Underscore in namespace](#underscore-in-namespace)

<!-- markdown-toc end -->

Expand Down Expand Up @@ -1183,6 +1184,20 @@ correspond with the file name of the file.

*Example message:* `Namespace name does not match file name: example-namespace.foo`

### Nil return from if-like forms

*Keyword:* `:if-nil-return`.

*Description:* warn when if-like form explicitly returns nil from either
branch. It is idiomatic in Clojure to prefer when-like forms, which (implicitly)
return nil when the condition is not met.

*Default level:* `:off`.

*Example trigger:* `(if true 1 nil)`.

*Example message:* `For nil return, prefer when`.

### Non-arg vec return type hint

*Keyword:* `:non-arg-vec-return-type-hint`.
Expand Down Expand Up @@ -2113,7 +2128,7 @@ namespaces. Defaults to only warning when doing interop.
The value of `:warn-only-on-interop` can be set to `false` to always warn in
Clojure namespaces.

## Underscore in namespace
### Underscore in namespace

*Keyword:* `:underscore-in-namespace`

Expand Down

0 comments on commit 29e2027

Please sign in to comment.