diagnostics in .gluarc.json. For quick fixes from the editor, see Fix common warnings.
Options
| Option | Default | Description |
|---|---|---|
diagnostics.enable | true | Show diagnostics at all |
diagnostics.disable | [] | Codes to turn off |
diagnostics.enables | [] | Codes to turn on that are off by default |
diagnostics.severity | {} | Change how a code shows: "error", "warning", "information" or "hint" |
diagnostics.globals | [] | Global names that exist even though GLuaLS cannot find them |
diagnostics.globalsRegex | [] | Regex patterns for such global names |
.gluarc.json
{
"diagnostics": {
"disable": ["unused"],
"enables": ["return-type-mismatch"],
"severity": {
"need-check-nil": "warning"
},
"globals": ["DarkRP"],
"globalsRegex": ["^MYADDON_"]
}
}
Codes
The code name appears at the end of each warning in the editor. Codes marked Off only run when you add them todiagnostics.enables.
Garry’s Mod
| Code | Default | Reports |
|---|---|---|
gmod-realm-mismatch | Error | A client-only or server-only function used in the wrong realm |
gmod-realm-mismatch-heuristic | Error | A likely wrong-realm call where the file’s realm is less certain |
gmod-unknown-realm | Hint | A realm-specific call in code whose realm is unknown |
gmod-unknown-net-message | Warning | A net message name that is never registered with util.AddNetworkString |
gmod-net-missing-network-counterpart | Warning | A net message that is sent but never received, or received but never sent |
gmod-net-read-write-order-mismatch | Warning | net.Read* calls in a different order from the net.Write* calls |
gmod-net-read-write-type-mismatch | Warning | A net.Read* call that does not match the type written |
gmod-net-read-write-bits-mismatch | Warning | A different bit count on a matching write and read, such as WriteUInt(x, 8) and ReadUInt(16) |
gmod-invalid-hook-name | Warning | An empty hook name, or one that is not a string literal |
gmod-null-check | Warning | An entity checked with if ent then or ~= nil instead of IsValid(ent) |
gmod-duplicate-system-registration | Hint | The same net.Receive, concommand.Add, timer.Create and similar registered twice |
Globals and variables
| Code | Default | Reports |
|---|---|---|
undefined-global | Error | A global that is never defined |
undefined-global-assignment | Warning | An undefined global passed as an argument or stored in a variable |
unused | Hint | A variable or function that is never used |
unused-self | Off | A method that never uses self |
redefined-local | Hint | A local that hides another local with the same name |
redefined-label | Warning | A ::label:: defined more than once |
local-const-reassign | Error | A <const> local that is assigned again |
global-in-non-module | Off | A global defined outside module scope |
Fields and methods
| Code | Default | Reports |
|---|---|---|
undefined-field | Warning | A field that does not exist on the type |
undefined-method | Error | A method called with : that does not exist on the type |
missing-fields | Warning | A table missing fields its type requires |
inject-field | Off | A new field added to a type outside its definition |
access-invisible | Warning | A private or protected member used from outside its class |
read-only | Warning | A write to a read-only value |
duplicate-index | Warning | The same key twice in one table |
duplicate-set-field | Off | The same field set more than once |
Types and nil
| Code | Default | Reports |
|---|---|---|
param-type-mismatch | Warning | An argument of the wrong type |
missing-parameter | Warning | A required argument that is missing |
redundant-parameter | Information | More arguments than the function takes |
assign-type-mismatch | Hint | A value of the wrong type assigned to a typed variable or field |
need-check-nil | Hint | A value that may be nil used without a check |
unchecked-nil-access | Warning | A chain of field accesses or calls through a value that may be nil |
infer-unknown | Hint | A value whose type was guessed from how it is used |
infer-unguarded-child | Warning | A value whose type was guessed from a parent that may not be valid |
type-not-found | Warning | A type name that does not exist |
cast-type-mismatch | Warning | A @cast to an incompatible type |
enum-value-mismatch | Warning | A value that is not part of the expected enum |
generic-constraint-mismatch | Information | A generic type argument that breaks its constraint |
call-non-callable | Off | A call on a value that is not a function |
need-check-nil and unchecked-nil-access understand IsValid and similar checks. See @valid_guard for your own check functions.
Returns
| Code | Default | Reports |
|---|---|---|
missing-return-value | Warning | A return with fewer values than the function declares |
missing-return | Off | A function with @return that can end without returning |
return-type-mismatch | Off | A returned value of the wrong type |
redundant-return-value | Off | A return with more values than the function declares |
discard-returns | Warning | An ignored result from a @nodiscard function |
Code quality
| Code | Default | Reports |
|---|---|---|
syntax-error | Error | Invalid Lua syntax |
unreachable-code | Hint | Code after return, break or error() |
unbalanced-assignments | Warning | A different number of variables and values in one assignment |
duplicate-require | Hint | The same module required twice in a file |
require-module-not-visible | Warning | A require path that is not in the workspace |
preferred-local-alias | Hint | A global that could be cached in a local |
deprecated | Hint | Use of something marked @deprecated |
await-in-sync | Warning | An @async function called from normal code |
unnecessary-assert | Off | An assert that can never fail |
unnecessary-if | Off | An if condition that is always true or always false |
invert-if | Off | An if that reads more simply when inverted |
non-literal-expressions-in-assert | Off | Non-literal values inside assert() |
code-style-check | Off | Code that does not match the formatter style |
Annotations
| Code | Default | Reports |
|---|---|---|
doc-syntax-error | Error | An annotation with invalid syntax |
annotation-usage-error | Error | An annotation in the wrong place |
undefined-doc-param | Warning | A @param for a parameter the function does not have |
duplicate-doc-field | Warning | The same field documented twice in a class |
circle-doc-class | Warning | Classes that inherit from each other in a loop |
attribute-param-type-mismatch | Warning | An attribute argument of the wrong type |
attribute-missing-parameter | Warning | A missing attribute argument |
attribute-redundant-parameter | Warning | Too many attribute arguments |
duplicate-type | Off | A type defined more than once |
unknown-doc-tag | Off | An unknown annotation tag |
incomplete-signature-doc | Off | A documented function missing some @param or @return |
missing-global-doc | Off | A global function or class with no documentation |
Related settings
| Option | Default | Description |
|---|---|---|
codeAction.insertSpace | false | Write --- @diagnostic instead of ---@diagnostic when a quick fix adds a comment |