Skip to main content

Overview

The diagnostics section controls which checks run and how severe they appear. You can enable, disable, or re-level each diagnostic code.

Top-level options

OptionTypeDefaultDescription
diagnostics.enablebooleantrueEnable diagnostics globally
diagnostics.disablestring[][]Codes to disable entirely
diagnostics.enablesstring[][]Codes to explicitly enable (for codes that are Off by default)
diagnostics.globalsstring[][]Global variable names to whitelist (suppress undefined-global)
diagnostics.globalsRegexstring[][]Regex patterns matching global names to whitelist
diagnostics.severityobject{}Map of code → severity level
diagnostics.diagnosticIntervalinteger500Delay in milliseconds between a file change and diagnostics scan

Severity levels

LevelAppearance
"error"Red error indicator, blocks type resolution display
"warning"Yellow warning indicator
"information"Blue information indicator
"hint"Subtle underline hint

Full diagnostic reference

Codes marked Off start disabled. Add them to enables to turn them on.

Syntax & annotations

CodeDefaultSeverityDescription
syntax-errorOnErrorLua syntax errors
doc-syntax-errorOnErrorAnnotation syntax errors
annotation-usage-errorOnErrorIncorrect annotation usage (e.g. @class inside a function)
unknown-doc-tagOffWarningUnrecognised annotation tag
incomplete-signature-docOffWarningFunction missing @param or @return documentation
missing-global-docOffWarningGlobal function/class with no documentation

Type checking

CodeDefaultSeverityDescription
type-not-foundOnWarningReferenced type not found in scope
param-type-mismatchOnWarningArgument type doesn’t match declared @param type
missing-parameterOnWarningRequired parameter not passed
redundant-parameterOnInformationExtra argument passed beyond declared parameters
assign-type-mismatchOnWarningAssignment value type doesn’t match declared type
return-type-mismatchOffWarningReturned type doesn’t match declared @return type
missing-returnOffWarningFunction with @return annotation missing a return statement
missing-return-valueOnWarningreturn statement missing a required value
redundant-return-valueOffWarningreturn statement has extra value(s)
cast-type-mismatchOnWarning@cast target type is incompatible
generic-constraint-mismatchOnInformationGeneric type argument violates constraint
enum-value-mismatchOnWarningValue not part of the declared enum
need-check-nilOnHintPotential nil dereference (try if x then ... end)
unchecked-nil-accessOnWarningChained access or call through an opaque table member that may be nil

Fields & access

CodeDefaultSeverityDescription
undefined-fieldOnWarningField doesn’t exist on the type
missing-fieldsOnWarningRequired fields not initialised in a table literal
inject-fieldOffWarningField assigned to a type outside its definition
duplicate-doc-fieldOnWarningSame field documented multiple times in a class
undefined-doc-paramOnWarning@param names a parameter that doesn’t exist in the function signature
access-invisibleOnWarningAccessing a private or protected member from outside its class
read-onlyOnWarningWriting to a read-only value

Variables & scoping

CodeDefaultSeverityDescription
undefined-globalOnErrorGlobal variable not defined or whitelisted
undefined-global-assignmentOnWarningUndefined global used as a function argument or assigned to a variable / table field (alias: undefined-global-argument)
unusedOnHintVariable or function is declared but never used
unused-selfOffHintself parameter is never used
redefined-localOnHintLocal variable redefined in the same scope
redefined-labelOnWarning::label:: defined multiple times
local-const-reassignOnErrorReassigning a <const>-attributed local

Control flow

CodeDefaultSeverityDescription
unreachable-codeOnHintCode after a return, break, or error() call
unnecessary-assertOffWarningassert that can never fail
unnecessary-ifOffWarningif condition that is always true or false
invert-ifOffWarningif block that could be simplified by inverting the condition

Modules & requires

CodeDefaultSeverityDescription
duplicate-requireOnHintModule required more than once in the same file
require-module-not-visibleOnWarningrequire() path target is not visible in the workspace

Documentation

CodeDefaultSeverityDescription
deprecatedOnHintUsing a function, field, or class marked @deprecated
discard-returnsOnWarningReturn value of a @nodiscard function is discarded
circle-doc-classOnWarningCircular class inheritance detected

Code style

CodeDefaultSeverityDescription
code-style-checkOffWarningCode style violations
duplicate-indexOnWarningSame table key used more than once
duplicate-set-fieldOffWarningSame field set multiple times
non-literal-expressions-in-assertOffWarningNon-literal values inside assert()
unbalanced-assignmentsOnWarningDifferent number of values and variables in a multi-assignment
preferred-local-aliasOnHintSuggest caching a global in a local variable
await-in-syncOnWarningUsing ---@async function result in a synchronous context

Type definitions

CodeDefaultSeverityDescription
duplicate-typeOffWarningType defined more than once
global-in-non-moduleOffWarningGlobal defined in a non-module file scope
attribute-param-type-mismatchOnWarningAttribute parameter type mismatch
attribute-missing-parameterOnWarningRequired attribute parameter missing
attribute-redundant-parameterOnWarningExtra attribute parameter
call-non-callableOffWarningCalling a value that is not callable

GMod-specific

CodeDefaultSeverityDescription
gmod-invalid-hook-nameOnWarningInvalid or unknown GMod hook name
gmod-realm-mismatchOnWarningDefinite realm mismatch: client API in server realm (or vice versa)
gmod-realm-mismatch-heuristicOnWarningProbable realm mismatch based on inferred evidence
gmod-unknown-realmOnHintRealm could not be determined for a realm-sensitive call
gmod-net-missing-network-counterpartOnWarningnet.Start block with no net.Receive in the opposite realm (or vice versa)
gmod-net-read-write-order-mismatchOnWarningnet.Read* order doesn’t match net.Write* order
gmod-net-read-write-type-mismatchOnWarningnet.Read* type doesn’t match corresponding net.Write* type
gmod-net-read-write-bits-mismatchOnWarningLiteral bit-width differs between a matched write/read pair (e.g. WriteUInt(8) vs ReadUInt(16))
gmod-unknown-net-messageOnWarningUnregistered net message identifier
gmod-duplicate-system-registrationOnHintDuplicate registration for net.Receive, concommand.Add, timer.Create, etc.

VSCode extension settings

You can also configure these settings in VS Code settings with the gluals.* prefix:
VSCode Setting.gluarc.json KeyTypeDefaultDescription
gluals.diagnostics.diagnosticIntervaldiagnostics.diagnosticIntervalinteger500Scan delay in milliseconds
gluals.strict.inferredTypeMismatchstrict.inferredTypeMismatchbooleanfalseStricter type checking for inferred values
gluals.strict.strictTypeCoercionstrict.strictTypeCoercionbooleanfalseRequires exact types in param-type-mismatch and disables GLua-aware coercions (e.g. number/boolean → string, numeric string literal → number/integer)
gluals.codeAction.insertSpacecodeAction.insertSpacebooleanfalseSpace after --- in diagnostic comments

Example configuration

.gluarc.json
{
  "diagnostics": {
    "enable": true,
    "diagnosticInterval": 500,
    "globals": ["GAMEMODE", "PLUGIN", "GM"],
    "globalsRegex": ["^PLUGIN_"],
    "enables": ["missing-return", "return-type-mismatch"],
    "disable": ["call-non-callable"],
    "severity": {
      "unused": "hint",
      "param-type-mismatch": "information",
      "need-check-nil": "hint",
      "undefined-field": "information"
    }
  }
}