Skip to content

Lint rules ​

fatou lint reports problems using the rule IDs listed below. Use these IDs to select rules, set their severity, or suppress a finding with # fatou-ignore <id>.

Most rules are enabled by default. Workspace package files enable additional rules that need project context; declared script programs also enable undefined-name. Exceptions are noted in each rule's description. Use select to replace the defaults, extend-select to add rules, and ignore to disable them. See Configuration for details.

fatou lint --fix applies safe fixes. Add --unsafe-fixes to apply fixes that may change behavior. Editors also offer fixes as code actions. The examples show the result of safe fixes.

Rules that recommend Base functions generally check that the original name resolves to Base. Fixes may be withheld if a replacement name is shadowed or the edit would discard comments.

The diagnostics and fixed code below are generated from the examples.

unused-binding ​

Report a local variable that is assigned but never read. Names beginning with _ are exempt, as are parameters, loop and catch variables, struct fields, type parameters, and top-level definitions.

tmp is assigned inside f but never used:

julia
function f(x)
    tmp = x + 1
    return x
end
text
warning: unused-binding
 --> example.jl:2:5
  |
2 |     tmp = x + 1
  |     ^^^ local variable `tmp` is assigned but never used

unused-import ​

Report an explicitly imported name that is never used. Qualified references, re-exports, and uses in the same module's included files count as uses.

The rule skips whole-module using X statements and withholds findings when an incomplete include chain could hide a use.

sortperm is imported but never referenced:

julia
using Base: sortperm, sum

println(sum([1, 2, 3]))
text
warning: unused-import
 --> example.jl:1:13
  |
1 | using Base: sortperm, sum
  |             ^^^^^^^^ `sortperm` is imported but never used

duplicate-argument ​

Report a repeated parameter name in a function signature. Positional and keyword parameters share the same namespace, and Julia rejects duplicates.

x appears twice in the parameter list:

julia
function dist(x, y, x)
    hypot(x, y)
end
text
error: duplicate-argument
 --> example.jl:1:21
  |
1 | function dist(x, y, x)
  |                     ^ argument name `x` is used more than once

duplicate-keyword-argument ​

Report a keyword argument passed more than once in a call. Julia rejects duplicate keywords, including those on opposite sides of ;. The shorthand f(; x) counts as passing x. Keyword splats are not checked.

label is supplied twice in one call:

julia
plot(xs, ys, label = "before", label = "after")
text
error: duplicate-keyword-argument
 --> example.jl:1:32
  |
1 | plot(xs, ys, label = "before", label = "after")
  |                                ^^^^^ keyword argument `label` is passed more than once

unused-argument ​

Report a function parameter that is never read. Names consisting only of underscores and stub methods with a literal, nothing, error(...), or throw(...) body are exempt.

Disabled by default because methods often use a parameter's type for dispatch without reading its value. Enable it with --select unused-argument.

factor is accepted but never used:

julia
function scale(x, factor)
    2 * x
end
text
warning: unused-argument
 --> example.jl:1:19
  |
1 | function scale(x, factor)
  |                   ^^^^^^ function argument `factor` is never used

undefined-name ​

Report a name that cannot be found in local bindings, the workspace package, imports, or Base and Core.

Enabled by default for workspace package files and programs declared with [project] entry-points = ["main.jl"]. Entry points let Fatou follow static includes and resolve global assignments. Each entry point and enclosing module is checked separately; diagnostics identify the contexts where a name is missing.

Dynamic definitions, unresolved imports, or incomplete include chains suppress findings for the affected entry point. Standalone files without entry points can enable the rule with [lint] extend-select = ["undefined-name"], but files containing includes are then skipped.

A misspelled variable name:

julia
function area(radius)
    return pi * raduis^2
end
text
warning: undefined-name
 --> example.jl:2:17
  |
2 |     return pi * raduis^2
  |                 ^^^^^^ `raduis` is not defined

break-outside-loop ​

Report break or continue outside a for or while loop. Julia rejects these statements, including inside a closure, do block, or comprehension nested in a loop: they cannot jump across a function boundary.

break outside a loop:

julia
function process(x)
    if x < 0
        break
    end
    x
end
text
error: break-outside-loop
 --> example.jl:3:9
  |
3 |         break
  |         ^^^^^ `break` outside of a `for` or `while` loop

A do block cannot continue its enclosing loop:

julia
for i in 1:3
    foreach(1:2) do x
        continue
    end
end
text
error: break-outside-loop
 --> example.jl:3:9
  |
3 |         continue
  |         ^^^^^^^^ `continue` outside of a `for` or `while` loop

const-local ​

Report const in a local scope, such as a function, let, or loop body. Julia allows constant bindings only at global scope: the file's top level or a module body. A const field in a mutable struct is allowed.

const inside a function body:

julia
function scale(x)
    const factor = 2
    factor * x
end
text
error: const-local
 --> example.jl:2:5
  |
2 |     const factor = 2
  |     ^^^^^^^^^^^^^^^^ `const` declaration on a local variable

const inside a let block:

julia
let
    const limit = 10
    limit
end
text
error: const-local
 --> example.jl:2:5
  |
2 |     const limit = 10
  |     ^^^^^^^^^^^^^^^^ `const` declaration on a local variable

global-const-in-function ​

Report global const inside a function, macro, closure, do block, or comprehension. Julia rejects these declarations even inside a nested let or loop. Move the declaration outside the function.

global const inside a function body:

julia
function setup()
    global const LIMIT = 10
end
text
error: global-const-in-function
 --> example.jl:2:5
  |
2 |     global const LIMIT = 10
  |     ^^^^^^^^^^^^^^^^^^^^^^^ `global const` declaration inside a function

global const inside a loop within a function:

julia
function setup()
    for i in 1:3
        global const LIMIT = i
    end
end
text
error: global-const-in-function
 --> example.jl:3:9
  |
3 |         global const LIMIT = i
  |         ^^^^^^^^^^^^^^^^^^^^^^ `global const` declaration inside a function

local-const ​

Report local const or const local, which Julia rejects in every scope. Use local x = 1 for a local binding or const x = 1 for a global constant.

local and const cannot be combined:

julia
local const LIMIT = 10
text
error: local-const
 --> example.jl:1:1
  |
1 | local const LIMIT = 10
  | ^^^^^^^^^^^^^^^^^^^^^^ `local const` declaration is not supported

const local inside a function:

julia
function scale(x)
    const local factor = 2
    factor * x
end
text
error: local-const
 --> example.jl:2:5
  |
2 |     const local factor = 2
  |     ^^^^^^^^^^^^^^^^^^^^^^ `local const` declaration is not supported

noteq-definition ​

Report a method definition for != or ≠. Define == instead: Julia derives != by negating ==.

Overloading != directly:

julia
!=(a::Grade, b::Grade) = a.score != b.score
text
warning: noteq-definition
 --> example.jl:1:1
  |
1 | !=(a::Grade, b::Grade) = a.score != b.score
  | ^^ `!=` is defined as `!(==)` and should not be overloaded; define `==` instead

unused-type-parameter ​

Report a where type parameter that is never used in the signature or body. This often indicates a missing type annotation or a leftover parameter.

Struct type parameters and names consisting only of underscores are exempt.

T is bound but never referenced:

julia
function f(x) where {T}
    x + 1
end
text
warning: unused-type-parameter
 --> example.jl:1:22
  |
1 | function f(x) where {T}
  |                      ^ type parameter `T` is never used

missing-include-file ​

Report an include("path") whose target is missing or unreadable. Relative paths resolve from the including file's directory.

The rule checks only static paths. It skips computed or interpolated paths, qualified calls such as M.include(...), and two-argument forms.

Including a file that does not exist:

julia
include("missing.jl")
text
error: missing-include-file
 --> example.jl:1:9
  |
1 | include("missing.jl")
  |         ^^^^^^^^^^^^ included file "missing.jl" does not exist

include-cycle ​

Report an include that leads back to the current file, directly or through other files. Running it causes unbounded recursion. Each linted file in the cycle gets a diagnostic at its own include call.

A file (here example.jl) that includes itself:

julia
include("example.jl")
text
warning: include-cycle
 --> example.jl:1:9
  |
1 | include("example.jl")
  |         ^^^^^^^^^^^^ include cycle: "example.jl" transitively includes this file

duplicate-include ​

Report a file included more than once from the same file and module. Each include evaluates the target again, repeating its top-level code and redefining its methods. Paths such as "a.jl" and "./a.jl" count as the same file.

Includes in separate modules and files reached through different include chains are allowed.

Including the same file twice:

julia
include("util.jl")
include("util.jl")
text
warning: duplicate-include
 --> example.jl:2:9
  |
2 | include("util.jl")
  |         ^^^^^^^^^ duplicate include: "util.jl" is already included earlier in this file

duplicate-method ​

Report a method definition that replaces an earlier method in the same file. Julia dispatches on positional argument types and where constraints. Changing only parameter names, defaults, keyword arguments, or the return type does not create a separate method.

Definitions inside macro calls or conditional branches are not checked.

A method replacing an earlier definition:

julia
f(x::Int) = 1
f(y::Int) = 2
text
warning: duplicate-method
 --> example.jl:2:1
  |
2 | f(y::Int) = 2
  | ^ this definition of `f` replaces an earlier method with the same signature

julia-version-compat ​

Report syntax unavailable in a Julia version the project supports. public requires Julia 1.11, and import ... as requires 1.6. Julia 1.14 adds typegroup, wrapping arithmetic and assignment operators (including broadcasts), labeled break and continue, primitive types with non-byte-multiple literal widths, parenthesized multiline macro arguments, and return forms that inherit index markers or a ternary branch's closing colon. Width expressions are not evaluated.

The runtime target comes from --julia-version, [julia] version, or the project's Project.toml or Manifest.toml. The rule checks the oldest supported runtime, independently of the selected syntax edition, and does nothing when no target is known.

Targeting Julia 1.0, but public needs 1.11 and as needs 1.6:

julia
module M
public foo
import A as B
end
text
error: julia-version-compat
 --> example.jl:2:1
  |
2 | public foo
  | ^^^^^^^^^^ the `public` keyword requires Julia 1.11.0, but the project supports 1.0.0 and up
error: julia-version-compat
 --> example.jl:3:8
  |
3 | import A as B
  |        ^^^^^^ renaming with `as` in `import`/`using` requires Julia 1.6.0, but the project supports 1.0.0 and up

These constructs require a Julia 1.14 runtime:

julia
typegroup
struct A end
end
x +%= 1
@label outer for i in xs
    continue outer
end
primitive type Bits 7 end
(@info "message"
    x=1)
a[return end]
x ? return : y
text
error: julia-version-compat
 --> example.jl:1:1
  |
1 | typegroup
  | ^^^^^^^^^ `typegroup` requires Julia 1.14.0, but the project supports 1.0.0 and up
error: julia-version-compat
 --> example.jl:4:3
  |
4 | x +%= 1
  |   ^^^ wrapping arithmetic syntax requires Julia 1.14.0, but the project supports 1.0.0 and up
error: julia-version-compat
 --> example.jl:6:5
  |
6 |     continue outer
  |     ^^^^^^^^^^^^^^ labeled `continue` requires Julia 1.14.0, but the project supports 1.0.0 and up
error: julia-version-compat
 --> example.jl:8:21
  |
8 | primitive type Bits 7 end
  |                     ^ a primitive type with a non-byte-multiple width requires Julia 1.14.0, but the project supports 1.0.0 and up
error: julia-version-compat
 --> example.jl:9:2
  |
9 | (@info "message"
  |  ^^^^^ parenthesized multiline macro argument syntax requires Julia 1.14.0, but the project supports 1.0.0 and up
error: julia-version-compat
  --> example.jl:11:3
   |
11 | a[return end]
   |   ^^^^^^ `return` with inherited index or ternary context requires Julia 1.14.0, but the project supports 1.0.0 and up
error: julia-version-compat
  --> example.jl:12:5
   |
12 | x ? return : y
   |     ^^^^^^ `return` with inherited index or ternary context requires Julia 1.14.0, but the project supports 1.0.0 and up

call-arity ​

Report a call when no known method accepts its number of positional arguments or its keyword names. Such calls raise MethodError.

Fatou checks methods in the file, workspace package, and indexed libraries. It skips calls when the available methods or arguments are uncertain, including splatted calls, do blocks, constructors, and callable values.

Enabled by default for workspace package files. Other files require explicit selection because methods may be defined in sibling files.

half has no two-argument method:

julia
half(x) = x / 2

half(3, 4)
text
warning: call-arity
 --> example.jl:3:1
  |
3 | half(3, 4)
  | ^^^^^^^^^^ no method of `half` takes 2 positional arguments (methods accept 1)

function-has-no-methods ​

Report a call to a function declared with function f end but given no methods. The call raises MethodError regardless of its arguments.

Fatou checks functions defined in the file or workspace package. Exported and public declarations are exempt because other packages may implement them. The rule skips files whose definitions cannot be resolved reliably.

Enabled by default for workspace package files. Other files require explicit selection because sibling files may add methods.

normalize is declared but never given a method:

julia
function normalize end

normalize("data")
text
warning: function-has-no-methods
 --> example.jl:3:1
  |
3 | normalize("data")
  | ^^^^^^^^^ `normalize` is declared with `function normalize end` but has no methods

redefined-constant ​

Report conflicting definitions of a name: reassigning a constant, assigning to a function, type, or module name, defining a function over a value, or declaring an existing variable const.

Definitions in separate branches of the same if are allowed, as are new methods and outer constructors.

Reassigning a constant:

julia
const threshold = 1.0
threshold = 2.0
text
warning: redefined-constant
 --> example.jl:2:1
  |
2 | threshold = 2.0
  | ^^^^^^^^^ reassignment of constant `threshold`

count already holds a value, so the method definition fails:

julia
count = 0
count(xs) = length(xs)
text
warning: redefined-constant
 --> example.jl:2:1
  |
2 | count(xs) = length(xs)
  | ^^^^^ cannot define function `count`: it already has a value

type-piracy ​

Report a method that extends another module's function using only types defined elsewhere. This is type piracy: loading the method can change behavior for unrelated code that uses the same function and types. Define the function or at least one argument type in your module.

Disabled by default. Fatou reports only cases where ownership is known. Without indexed libraries, it checks ownership against the built-in Base and Core snapshot.

Extending Base.show for only Base types is piracy:

julia
Base.show(io::IO, x::Int) = print(io, x)
text
warning: type-piracy
 --> example.jl:1:6
  |
1 | Base.show(io::IO, x::Int) = print(io, x)
  |      ^^^^ type piracy: this module defines neither `Base.show` nor any of its argument types

unreachable-code ​

Report statements that can never run, such as code after an unconditional return, throw, error, or rethrow. The rule also catches code after an if whose branches all exit, or a while true loop with no break.

Check whether the unreachable statement should be removed or the preceding control flow should change.

Nothing after an unconditional return can run:

julia
function f(x)
    return x + 1
    println("never")
end
text
warning: unreachable-code
 --> example.jl:3:5
  |
3 |     println("never")
  |     ^^^^^^^^^^^^^^^^ unreachable code: no path of execution reaches this statement

An unreachable statement after two branches that return:

julia
function classify(x)
    if x > 0
        return :pos
    else
        throw(DomainError(x))
    end
    return :unknown
end
text
warning: unreachable-code
 --> example.jl:7:5
  |
7 |     return :unknown
  |     ^^^^^^^^^^^^^^^ unreachable code: no path of execution reaches this statement

unresolved-import ​

Report a using or import of a package absent from both the project's [deps] and the indexed environment. Julia may fail to load the package.

Relative imports such as using .Sub are allowed. Packages found in the environment, including standard libraries and transitive dependencies, are also accepted.

Enabled by default for workspace package files, where project dependencies are known.

The project declares LinearAlgebra in [deps], but not Frobnicate:

julia
using LinearAlgebra
using Frobnicate
text
warning: unresolved-import
 --> example.jl:2:7
  |
2 | using Frobnicate
  |       ^^^^^^^^^^ `Frobnicate` is not a dependency of this project

kwarg-default-mismatch ​

Report a keyword parameter whose default has the wrong type, such as f(; x::Int = 1.0). Julia does not convert keyword defaults to the declared type, so calling f() raises MethodError. Defaults such as x::Int8 = 1 also fail because 1 has type Int.

The rule checks concrete built-in types and literals with known types. It skips abstract or parametric types and computed defaults.

y is declared Int, so the Float64 default never matches it:

julia
function scale(xs; y::Int = 1.0)
    xs .* y
end
text
error: kwarg-default-mismatch
 --> example.jl:1:20
  |
1 | function scale(xs; y::Int = 1.0)
  |                    ^^^^^^^^^^^^ keyword argument `y` is declared `::Int`, but its default `1.0` has type `Float64`
  = help: use a default of the declared type; Julia does not convert keyword defaults

An Int default for an Int8 parameter:

julia
counter(; start::Int8 = 0) = start
text
error: kwarg-default-mismatch
 --> example.jl:1:11
  |
1 | counter(; start::Int8 = 0) = start
  |           ^^^^^^^^^^^^^^^ keyword argument `start` is declared `::Int8`, but its default `0` has type `Int`
  = help: use a default of the declared type; Julia does not convert keyword defaults

invalid-type-declaration ​

Report a function name used as a type in ::, such as f(x::g) when g is a function. Julia raises TypeError when it evaluates the declaration.

Fatou checks functions defined in the file or workspace package. It skips names that might refer to types and files whose definitions cannot be resolved reliably.

Enabled by default for workspace package files. Other files require explicit selection and a resolution context.

scale is a function, so declaring y::scale is a TypeError:

julia
scale(x) = 2x

apply(y::scale) = y
text
warning: invalid-type-declaration
 --> example.jl:3:10
  |
3 | apply(y::scale) = y
  |          ^^^^^ `scale` is a function and cannot be used as a type in `::scale`

invalid-docstring-code ​

Report syntax errors in Julia code blocks within docstrings. The rule checks julia blocks and Documenter directives. For julia-repl and jldoctest transcripts, it checks the input and skips expected output.

Other languages, dynamically constructed docstrings, and docstrings with malformed Markdown are not checked.

An incomplete Julia code block:

julia
"""
~~~julia
f(
~~~
"""
f() = 1
text
warning: invalid-docstring-code
 --> example.jl:3:2
  |
3 | f(
  |  ^ invalid Julia in documentation fence: unterminated argument list

docstring-argument-mismatch ​

Report a - `name`: ... entry under # Arguments in a docstring when the attached function or macro has no parameter with that name. This catches misspelled or outdated entries. The rule does not require every parameter to be documented.

A misspelled argument name:

julia
"""
# Arguments
- `raduis`: The radius.
"""
area(radius) = pi * radius^2
text
warning: docstring-argument-mismatch
 --> example.jl:3:3
  |
3 | - `raduis`: The radius.
  |   ^^^^^^^^ documented argument `raduis` is not in the attached signature

unresolved-docstring-reference ​

Report a Documenter link such as [`Foo.bar`](@ref Foo.bar) when the target Julia symbol cannot be found. Local Markdown anchors are accepted. Inferred references, prose labels, and targets that cannot be resolved reliably are not checked.

Enabled by default for workspace package files. Other files require explicit selection and a resolution context.

A misspelled reference target:

julia
"""
See [`Base.raduis`](@ref Base.raduis).
"""
area(radius) = pi * radius^2
text
warning: unresolved-docstring-reference
 --> example.jl:2:26
  |
2 | See [`Base.raduis`](@ref Base.raduis).
  |                          ^^^^^^^^^^^ documentation reference `Base.raduis` does not resolve

assignment-in-condition ​

Report a bare assignment used as an if, elseif, or while condition. This is usually a typo for ==. The safe fix replaces = with ==.

= where == was meant:

julia
if x = 5
    println(x)
end
text
warning: assignment-in-condition
 --> example.jl:1:4
  |
1 | if x = 5
  |    ^^^^^ assignment used as a condition; did you mean `==`?
  = help: Replace `=` with `==` (safe fix)

After applying the fix:

julia
if x == 5
    println(x)
end

nothing-comparison ​

Prefer ===, !==, or isnothing when comparing with nothing. Identity tests express the intent directly and cannot be overloaded.

The safe fix replaces == with === and != with !==. Inside Test.@test, it prefers isnothing(x) or !isnothing(x) when that name resolves to Base.

Comparing against nothing by value:

julia
if x == nothing
    1
end
text
warning: nothing-comparison
 --> example.jl:1:4
  |
1 | if x == nothing
  |    ^^^^^^^^^^^^ comparison against `nothing` by value; use `===` or `isnothing`
  = help: Replace `==` with `===` (safe fix)

After applying the fix:

julia
if x === nothing
    1
end

missing-comparison ​

Report == or != comparisons with missing. These return missing, and using the result as a condition raises TypeError. Use ismissing, ===, or !== instead.

The fix replaces the value comparison with an identity test. It requires --unsafe-fixes because it changes the result to a Bool.

Comparing against missing by value:

julia
if x == missing
    1
end
text
warning: missing-comparison
 --> example.jl:1:4
  |
1 | if x == missing
  |    ^^^^^^^^^^^^ comparison against `missing` by value is always `missing`; use `ismissing` or `===`
  = help: Replace `==` with `===` (unsafe fix, requires `--unsafe-fixes`)

constant-condition ​

Report true or false used as a condition or as an operand of && or ||. These constants often come from debugging code or a mistyped name. The rule allows while true, the usual way to write an infinite loop.

An if condition that is always true:

julia
if true
    println("always")
end
text
warning: constant-condition
 --> example.jl:1:4
  |
1 | if true
  |    ^^^^ this condition is always `true`

A constant that prevents check(x) from running:

julia
ok = false && check(x)
text
warning: constant-condition
 --> example.jl:1:6
  |
1 | ok = false && check(x)
  |      ^^^^^ `&&` has a constant `false` operand

module-shadows-parent ​

Report a nested module with the same name as its parent. The child hides the parent's reference to itself, so qualified names such as A.x may resolve against the wrong module. This often happens when a file is included inside the module it already defines.

A submodule shadowing the module that contains it:

julia
module A

module A
end

end
text
warning: module-shadows-parent
 --> example.jl:3:8
  |
3 | module A
  |        ^ module `A` has the same name as its parent module

loop-variable-shadow ​

Report an inner for loop that reuses an enclosing loop's index name. The inner loop creates a new binding and hides the outer index, often because a copied loop was not renamed.

Assignments to loop variables are allowed. Comprehensions, generators, and reuse across function boundaries are not checked.

A nested loop reusing the enclosing loop's index:

julia
for i in 1:3
    for i in 1:2
        println(i)
    end
end
text
warning: loop-variable-shadow
 --> example.jl:2:9
  |
2 |     for i in 1:2
  |         ^ loop variable `i` shadows the enclosing loop's variable

index-from-length ​

Prefer eachindex(x) to 1:length(x) when a loop variable indexes x, or axes(x, d) to 1:size(x, d). These handle collections whose indices do not start at one. The fix requires --unsafe-fixes because changing the indices can change behavior.

The rule also reports iteration over a numeric literal, such as for i in 3.5. Julia runs that loop once, which usually indicates a missing range.

1:length(x) used to index x:

julia
for i in 1:length(x)
    println(x[i])
end
text
warning: index-from-length
 --> example.jl:1:10
  |
1 | for i in 1:length(x)
  |          ^^^^^^^^^^^ iterate `eachindex(x)` instead of `1:length(x)`
  = help: Replace `1:length` with `eachindex` (unsafe fix, requires `--unsafe-fixes`)

Iterating a bare number loops once:

julia
for i in 3.5
    println(i)
end
text
warning: index-from-length
 --> example.jl:1:10
  |
1 | for i in 3.5
  |          ^^^ iterating a numeric literal runs the loop body once; did you mean a range?

discouraged-function ​

Report calls to functions with process-wide or unsafe effects. Defaults include exit, cd, stream redirection, and unsafe memory operations. Each diagnostic suggests an alternative. Callback forms of cd and stream redirection are allowed because they restore the previous state.

Configure [lint.rules.discouraged-function] with tables mapping function names to suggestions. functions replaces the defaults, extend-functions adds or overrides entries, and functions = {} clears the list. Qualified calls such as Base.exit are not checked.

cd changes the working directory, and exit ends the process:

julia
function cleanup()
    cd("/tmp")
    exit(1)
end
text
warning: discouraged-function
 --> example.jl:2:5
  |
2 |     cd("/tmp")
  |     ^^ `cd` is discouraged: use the `cd(f, dir)` do-block form so the working directory is restored
warning: discouraged-function
 --> example.jl:3:5
  |
3 |     exit(1)
  |     ^^^^ `exit` is discouraged: let the caller decide when the process ends

typeof-comparison ​

Prefer x isa T to typeof(x) == T when testing whether a value belongs to a type. Exact comparisons exclude subtypes: typeof(1) == Integer is false, but 1 isa Integer is true.

The rule skips identity comparisons, broadcast comparisons, chains, and comparisons between two typeof calls. The fix requires --unsafe-fixes because accepting subtypes changes behavior.

typeof(x) == Integer is false for every integer:

julia
if typeof(x) == Integer
    1
end
text
warning: typeof-comparison
 --> example.jl:1:4
  |
1 | if typeof(x) == Integer
  |    ^^^^^^^^^^^^^^^^^^^^ `typeof(x) == T` matches only the exact type; use `x isa T`, which includes subtypes
  = help: Rewrite as an `isa` test (unsafe fix, requires `--unsafe-fixes`)

shadowed-base-name ​

Report a call to a Base or Core function whose name has been hidden by a value binding. For example, after length = 3, a call to length(xs) tries to call the integer.

The rule requires both a binding and a call. Parameters, imports, function and type definitions, and assignments of visibly callable values are exempt.

The assignment masks Base's length, so the call fails:

julia
length = 3
n = length(xs)
text
warning: shadowed-base-name
 --> example.jl:2:5
  |
2 | n = length(xs)
  |     ^^^^^^ `length` here is this file's own binding, not Base's `length`

A catch variable hiding error:

julia
try
    risky()
catch error
    error("failed")
end
text
warning: shadowed-base-name
 --> example.jl:4:5
  |
4 |     error("failed")
  |     ^^^^^ `error` here is this file's own binding, not Base's `error`

non-public-access ​

Report access to a module member that is neither exported nor declared public. Internal names may change without notice. The rule follows these declarations even when a package documents an unexported name as part of its API.

The workspace package's own internals are allowed. Modules with no declared public API and modules using Reexport.jl are exempt.

Enabled by default for workspace package files. Other files require explicit selection and indexed libraries.

summarysize is part of Base's public API; unwrap_unionall is not:

julia
Base.summarysize(x)
Base.unwrap_unionall(T)
text
warning: non-public-access
 --> example.jl:2:1
  |
2 | Base.unwrap_unionall(T)
  | ^^^^^^^^^^^^^^^^^^^^ `Base` does not export `unwrap_unionall` or declare it `public`

Macros are checked in their own namespace:

julia
Base.@_inline_meta
text
warning: non-public-access
 --> example.jl:1:1
  |
1 | Base.@_inline_meta
  | ^^^^^^^^^^^^^^^^^^ `Base` does not export `@_inline_meta` or declare it `public`

test-bare-expression ​

Report a bare Test.@test argument with no comparison, Boolean operator, or predicate call, such as @test result. Calls and nested macros are allowed because they may return a Bool. The rule requires a visible Test import.

Disabled by default because bare Boolean values are valid assertions. No automatic fix is offered.

A test with a bare value:

julia
using Test
@test result
text
warning: test-bare-expression
 --> example.jl:2:7
  |
2 | @test result
  |       ^^^^^^ this assertion has no comparison or predicate

eager-broadcast ​

Prefer sum(f, xs) to sum(f.(xs)) to avoid building an intermediate array. The rule also checks all, any, count, maximum, minimum, and prod. It matches a single broadcast argument with no keywords or splats.

The fix requires --unsafe-fixes: scalar inputs can behave differently, and any and all may stop early, changing how often f runs.

Summing without an intermediate array:

julia
total = sum(abs.(residuals))
text
warning: eager-broadcast
 --> example.jl:1:9
  |
1 | total = sum(abs.(residuals))
  |         ^^^^^^^^^^^^^^^^^^^^ use `sum(abs, residuals)` to avoid allocating the broadcast result
  = help: Pass the function as `sum`'s first argument (unsafe fix, requires `--unsafe-fixes`)

any need not test every element:

julia
if any(isnan.(xs))
    error("bad data")
end
text
warning: eager-broadcast
 --> example.jl:1:4
  |
1 | if any(isnan.(xs))
  |    ^^^^^^^^^^^^^^^ use `any(isnan, xs)` to avoid allocating the broadcast result
  = help: Pass the function as `any`'s first argument (unsafe fix, requires `--unsafe-fixes`)

sorted-extremum ​

Prefer minimum(xs) to sort(xs)[1] or sort(xs)[begin], and maximum(xs) to sort(xs)[end]. Finding an extreme takes one pass and avoids sorting the collection. Calls with sorting options such as rev, by, or lt are not checked.

The fix requires --unsafe-fixes: sorting places NaN last, while minimum and maximum propagate it.

Sorting to read the smallest element:

julia
lowest = sort(scores)[1]
text
warning: sorted-extremum
 --> example.jl:1:10
  |
1 | lowest = sort(scores)[1]
  |          ^^^^^^^^^^^^^^^ call `minimum(scores)` instead of `sort(scores)[1]`, which sorts the whole collection
  = help: Replace the sorted indexing with `minimum` (unsafe fix, requires `--unsafe-fixes`)

Sorting to read the largest element:

julia
highest = sort(scores)[end]
text
warning: sorted-extremum
 --> example.jl:1:11
  |
1 | highest = sort(scores)[end]
  |           ^^^^^^^^^^^^^^^^^ call `maximum(scores)` instead of `sort(scores)[end]`, which sorts the whole collection
  = help: Replace the sorted indexing with `maximum` (unsafe fix, requires `--unsafe-fixes`)

length-findall ​

Prefer count(p, xs) to length(findall(p, xs)) to avoid allocating a vector of matching indices. The one-argument form, length(findall(mask)), can use count(mask).

The fix requires --unsafe-fixes: findall tests dictionary values, while count tests key-value pairs.

Counting matching elements:

julia
n = length(findall(isodd, xs))
text
warning: length-findall
 --> example.jl:1:5
  |
1 | n = length(findall(isodd, xs))
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ call `count(isodd, xs)` instead of `length(findall(isodd, xs))`, which builds an index vector just to count it
  = help: Count the matches directly with `count` (unsafe fix, requires `--unsafe-fixes`)

The one-argument form counts a mask:

julia
hits = length(findall(mask))
text
warning: length-findall
 --> example.jl:1:8
  |
1 | hits = length(findall(mask))
  |        ^^^^^^^^^^^^^^^^^^^^^ call `count(mask)` instead of `length(findall(mask))`, which builds an index vector just to count it
  = help: Count the matches directly with `count` (unsafe fix, requires `--unsafe-fixes`)

fixed-regex ​

Prefer a plain string to a regex that matches a fixed substring. For example, use occursin("abc", s) instead of occursin(r"abc", s).

The rule checks pattern arguments to occursin, contains, startswith, endswith, split, eachsplit, and replace, including curried forms. Patterns with flags, escapes, or regex metacharacters are excluded. The safe fix removes the r prefix.

Searching for a fixed substring:

julia
if occursin(r"error", line)
    push!(failures, line)
end
text
warning: fixed-regex
 --> example.jl:1:13
  |
1 | if occursin(r"error", line)
  |             ^^^^^^^^ use the string `"error"` for this literal pattern
  = help: Drop the `r` prefix and match the substring (safe fix)

After applying the fix:

julia
if occursin("error", line)
    push!(failures, line)
end

Searching with a curried contains:

julia
failures = filter(contains(r"error"), lines)
text
warning: fixed-regex
 --> example.jl:1:28
  |
1 | failures = filter(contains(r"error"), lines)
  |                            ^^^^^^^^ use the string `"error"` for this literal pattern
  = help: Drop the `r` prefix and match the substring (safe fix)

After applying the fix:

julia
failures = filter(contains("error"), lines)

Splitting on a fixed string:

julia
fields = split(line, r"::")
text
warning: fixed-regex
 --> example.jl:1:22
  |
1 | fields = split(line, r"::")
  |                      ^^^^^ use the string `"::"` for this literal pattern
  = help: Drop the `r` prefix and match the substring (safe fix)

After applying the fix:

julia
fields = split(line, "::")

comparison-negation ​

Simplify negated equality tests: !(a == b) becomes a != b, and !(a === b) becomes a !== b. The reverse and Unicode forms are also checked.

Ordering comparisons are excluded because negating < is not equivalent to >= for values such as NaN. The safe fix preserves comments between operands and is withheld if it would discard a comment or change operator precedence.

Negating an equality comparison:

julia
if !(status == :ok)
    retry()
end
text
warning: comparison-negation
 --> example.jl:1:4
  |
1 | if !(status == :ok)
  |    ^^^^^^^^^^^^^^^^ write the comparison directly: `!(a == b)` is `a != b`
  = help: Rewrite as `!=` (safe fix)

After applying the fix:

julia
if status != :ok
    retry()
end

Negating an identity comparison:

julia
found = !(lookup(key) === nothing)
text
warning: comparison-negation
 --> example.jl:1:9
  |
1 | found = !(lookup(key) === nothing)
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^ write the comparison directly: `!(a === b)` is `a !== b`
  = help: Rewrite as `!==` (safe fix)

After applying the fix:

julia
found = lookup(key) !== nothing

length-zero ​

Prefer isempty(x) or !isempty(x) when a length comparison tests whether a collection is empty. This includes length(x) == 0, length(x) < 1, and their reversed forms.

The safe fix preserves the argument and is withheld if isempty is shadowed or a comment would be lost.

Testing whether a collection is empty:

julia
if length(xs) == 0
    println("nothing to do")
end
text
warning: length-zero
 --> example.jl:1:4
  |
1 | if length(xs) == 0
  |    ^^^^^^^^^^^^^^^ test `isempty(xs)` instead of comparing `length(xs)` to `0`
  = help: Rewrite as an `isempty` test (safe fix)

After applying the fix:

julia
if isempty(xs)
    println("nothing to do")
end

Testing whether a collection is nonempty:

julia
while 0 < length(queue)
    pop!(queue)
end
text
warning: length-zero
 --> example.jl:1:7
  |
1 | while 0 < length(queue)
  |       ^^^^^^^^^^^^^^^^^ test `!isempty(queue)` instead of comparing `length(queue)` to `0`
  = help: Rewrite as an `isempty` test (safe fix)

After applying the fix:

julia
while !isempty(queue)
    pop!(queue)
end

redundant-boolean ​

Simplify comparisons to Boolean literals and conditionals that return them. For example, x == true becomes x, and c ? false : true becomes !c.

The conditional fix is safe. The comparison fix requires --unsafe-fixes because the operand may have a type other than Bool: for example, 1 == true returns true, while 1 remains an integer.

Returning the condition directly:

julia
ready = queue_started(q) ? true : false
text
warning: redundant-boolean
 --> example.jl:1:9
  |
1 | ready = queue_started(q) ? true : false
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this conditional just yields `queue_started(q)`
  = help: Replace the conditional with its test (safe fix)

After applying the fix:

julia
ready = queue_started(q)

Comparing a value to false:

julia
if x.valid == false
    reject(x)
end
text
warning: redundant-boolean
 --> example.jl:1:4
  |
1 | if x.valid == false
  |    ^^^^^^^^^^^^^^^^ comparing to `false` is redundant: write `!x.valid`
  = help: Drop the comparison to `false` (unsafe fix, requires `--unsafe-fixes`)

string-boundary ​

Prefer startswith or endswith to a regex that tests a literal prefix or suffix. For example, occursin(r"^abc", s) becomes startswith(s, "abc"). The rule also checks contains, including its curried form. Patterns with flags or additional regex syntax are excluded.

The prefix fix is safe. The suffix fix requires --unsafe-fixes because regex $ also matches before a final newline, while endswith requires the suffix at the very end.

A leading anchor is a prefix test:

julia
if occursin(r"^Test", name)
    run(name)
end
text
warning: string-boundary
 --> example.jl:1:4
  |
1 | if occursin(r"^Test", name)
  |    ^^^^^^^^^^^^^^^^^^^^^^^^ test `startswith(name, "Test")` instead of matching the anchored regex `r"^Test"`
  = help: Test the prefix with `startswith` (safe fix)

After applying the fix:

julia
if startswith(name, "Test")
    run(name)
end

A trailing anchor is a suffix test:

julia
sources = filter(f -> occursin(r"_test$", f), files)
text
warning: string-boundary
 --> example.jl:1:23
  |
1 | sources = filter(f -> occursin(r"_test$", f), files)
  |                       ^^^^^^^^^^^^^^^^^^^^^^ test `endswith(f, "_test")` instead of matching the anchored regex `r"_test$"`
  = help: Test the suffix with `endswith`, which does not match before a trailing newline (unsafe fix, requires `--unsafe-fixes`)

Using a prefix test with filter:

julia
sources = filter(contains(r"^src"), files)
text
warning: string-boundary
 --> example.jl:1:18
  |
1 | sources = filter(contains(r"^src"), files)
  |                  ^^^^^^^^^^^^^^^^^ test `startswith("src")` instead of matching the anchored regex `r"^src"`
  = help: Test the prefix with `startswith` (safe fix)

After applying the fix:

julia
sources = filter(startswith("src"), files)

unnecessary-nesting ​

Combine an if whose only statement is another if into one condition with &&. Neither if may have an elseif or else branch.

The safe fix preserves the inner body and adds parentheses where needed. It is withheld if a comment would be lost. Run the formatter afterward to adjust indentation.

Combining nested conditions:

julia
if isopen(io)
    if !eof(io)
        read(io)
    end
end
text
warning: unnecessary-nesting
 --> example.jl:1:1
  |
1 | if isopen(io)
  | ^^^^^^^^^^^^^ this `if` only guards another `if`: write `if isopen(io) && !eof(io)`
  = help: Merge the nested `if` into its parent with `&&` (safe fix)

After applying the fix:

julia
if isopen(io) && !eof(io)
        read(io)
    end

test-isa-call ​

Prefer @test value isa Type to @test isa(value, Type). The rule requires a visible Test import and offers a safe fix that preserves the operands and their precedence.

Using isa as an operator in a test:

julia
using Test
@test isa(result, AbstractVector)
text
warning: test-isa-call
 --> example.jl:2:7
  |
2 | @test isa(result, AbstractVector)
  |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^ write `result isa AbstractVector` instead of calling `isa`
  = help: Rewrite as an `isa` comparison (safe fix)

After applying the fix:

julia
using Test
@test result isa AbstractVector

misnamed-suppression ​

Report a suppression comment that names an unknown rule. Rule IDs must match exactly, so a misspelled ID suppresses nothing. When there is a single close match, the safe fix corrects the ID and keeps the reason.

A directive naming a rule that does not exist:

julia
# fatou-ignore unused-bindings: set up by the C library
function f()
    handle = open_device()
    1
end
text
warning: misnamed-suppression
 --> example.jl:1:16
  |
1 | # fatou-ignore unused-bindings: set up by the C library
  |                ^^^^^^^^^^^^^^^ `unused-bindings` is not a fatou rule; this suppresses nothing
  = help: Replace with `unused-binding` (safe fix)

After applying the fix:

julia
# fatou-ignore unused-binding: set up by the C library
function f()
    handle = open_device()
    1
end

blanket-suppression ​

Report a suppression comment with no rule ID. A bare # fatou-ignore-file disables every rule, including rules added later. A bare # fatou-ignore suppresses nothing. Name the specific rules to suppress.

A file suppression without a rule ID:

julia
# fatou-ignore-file: generated code

struct Point
    x::Float64
end
text
warning: blanket-suppression
 --> example.jl:1:1
  |
1 | # fatou-ignore-file: generated code
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ suppression names no rule; it silences every rule in this file
  = help: name the rule: `# fatou-ignore <rule>: <reason>`

unexplained-suppression ​

Require a reason in suppression comments: # fatou-ignore <rule>: <reason>.

Disabled by default because reasons are optional. Enable it to require an explanation for each suppression.

A suppression without a reason:

julia
# fatou-ignore unused-binding
function f()
    handle = open_device()
    1
end
text
warning: unexplained-suppression
 --> example.jl:1:1
  |
1 | # fatou-ignore unused-binding
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ suppression states no reason
  = help: add one: `# fatou-ignore <rule>: <reason>`

outdated-suppression ​

Report a suppression comment that no longer suppresses a finding or has no code after it. Disabled rules and files whose names cannot be resolved reliably are not checked. The safe fix deletes the comment.

A directive at the end of a file, with nothing left to suppress:

julia
function f(x)
    x + 1
end
# fatou-ignore unused-binding: the scratch value below
text
warning: outdated-suppression
 --> example.jl:4:1
  |
4 | # fatou-ignore unused-binding: the scratch value below
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ suppression has nothing after it to apply to
  = help: delete the directive
  = help: Delete the suppression (safe fix)

After applying the fix:

julia
function f(x)
    x + 1
end

Released under the MIT License.