q Linter

QStudio includes a built-in linter for kdb+/q code that checks for errors, warnings and code quality issues. The linter runs automatically when you save a file and reports issues in the Problems Panel.

The linter catches common mistakes including:

  • Assigning to reserved words like count or sum
  • Unused variables and parameters
  • Undeclared variables that will become unintended globals
  • Deprecated internal functions that have q replacements
  • Wrong number of arguments to namespace functions
  • Code after a return statement (unreachable code)

Problems Panel

Lint results appear in the Problems Panel at the bottom of the screen. Each row shows the severity, file, line number, rule ID and message. Click any row to jump directly to the problem in the editor.

Problems Panel showing lint errors and warnings

The Problems Panel updates automatically when you save a file. Only .q and .k files are linted.

Editor Highlighting

When filtering is enabled, lint issues are highlighted directly in the editor with:

  • Squiggly underlines beneath the affected code — red for errors, orange for warnings, blue for info
  • Colored circles in the gutter next to line numbers

Highlights clear automatically if you add or remove lines (since positions may shift) and reappear when you save.

The highlighting colors adjust for dark and light editor themes.

Filtering by Severity

The filter button in the Problems Panel toolbar cycles through severity levels:

FilterShows
ALLErrors + Warnings + Info
ERRORErrors only
WARNINGWarnings + Errors
INFOInfo + Warnings + Errors (everything)
NONENothing — hides all lint results and editor highlights

The default is NONE so existing users are not surprised by new highlighting. Click the filter button to enable error display.

Changing the filter also updates the editor highlighting in real-time.

Configuring Rules

Click the gear icon in the Problems Panel toolbar to open the Configure Lint Rules dialog. Each rule can be individually enabled or disabled. Use the Select All / Select None buttons for quick toggling.

Rule configuration is per-session. Disabled rules are not persisted between restarts.

Suppressing Rules Per File

Add a comment at the top of your q file to suppress a specific rule for that file:

/ @qlintsuppress UNUSED_VAR

This prevents the UNUSED_VAR rule from firing anywhere in that file. Multiple rules can be suppressed with separate comments.

Cross-File Analysis

When you have a folder open, the linter performs cross-file analysis. It builds an index of all namespace functions defined across your project files and can detect:

  • Undefined references — calling .trade.getPrice when no file defines it (and the .trade namespace is known)
  • Wrong argument count — calling a function with more arguments than it accepts
  • Parameter type mismatches — passing a string literal where a parameter named sym expects a symbol

Built-in namespaces (.Q, .q, .z, .h, .j, .o, .m, .log) are never flagged since their contents cannot be verified statically.

All Lint Rules

The linter includes 38 rules across four categories.

Error Detection

RuleSeverityDescription
ASSIGN_RESERVED_WORDERRORAssignment to a reserved word (e.g. count:42)
COND_EVENARGSERRORConditional $ has even number of arguments (should be odd)
INVALID_ESCAPEERRORInvalid escape sequence in string (e.g. "\q")
INVALID_ASSIGNERRORAttempt to assign to a string, symbol, or number
DECLARED_AFTER_USEERRORVariable was used before being declared
TOO_MANY_LOCALSERRORToo many local variables in function (max 110)
TOO_MANY_GLOBALSERRORToo many global assignments in function (max 20)
TOO_MANY_CONSTANTSERRORToo many constants in function (max 110)
GLOBAL_PEACHERRORModifying globals inside peach is not allowed
RESERVED_NAMEERRORFile has a name that conflicts with a q reserved word
UNDEFINED_REFERENCEERRORReference to undefined symbol in a known namespace (cross-file)
WRONG_ARG_COUNTERRORFunction called with wrong number of arguments (cross-file)
PARAM_TYPE_MISMATCHERRORLiteral argument type conflicts with parameter name hint (cross-file)
DEPRECATED_INTERNALERRORInternal function -N! has a q replacement (e.g. use parse instead of -5!)
UNARY_FORMERRORUnary operator form (e.g. #:) should use q keyword (e.g. count)

Code Quality Warnings

RuleSeverityDescription
DEPRECATED_DATETIMEWARNINGDatetime type has been deprecated in favour of timestamp
EMPTY_IFWARNINGIf statement lacks code to execute
CAST_TYPE_NUMERICALWARNINGCasting using short type indicator (e.g. "i"$) is unnecessarily unclear
UNUSED_PARAMWARNINGParameter declared but never used in the function body
UNUSED_VARWARNINGVariable assigned but never referenced
UNDECLARED_VARWARNINGUndeclared variable will be treated as global
UNREACHABLE_CODEWARNINGCode after a return statement is never executed
NEED_EXPLICIT_RETURNWARNINGFunction ends with assignment — returns generic null instead of a value
DEBUG_FUNCTIONWARNINGDebug function call (e.g. show) should not be in release code
CONDITIONALLY_DECLAREDWARNINGVariable may be undefined — declared only in one branch of a conditional
NAME_COLLISIONWARNINGAssignment could overwrite a built-in function
BACKWARD_COMPATIBILITYWARNINGFeature may not be available in older kdb versions

Style Warnings

RuleSeverityDescription
LINE_TOO_LONGWARNINGLine exceeds maximum length (default 120 characters)
FUNCTION_TOO_LONGWARNINGFunction exceeds maximum line count (default 40 lines)
TOO_MANY_PARAMSWARNINGFunction has too many parameters (default max 8)
UNDERSCORE_IN_NAMEWARNINGUnderscore in name conflicts with the drop operator _
XYZ_AS_LOCALWARNINGx/y/z used as local variable — reserved for implicit parameters
TRAILING_SEMICOLONWARNINGTrailing semicolon before } causes function to return generic null
UNINDENTED_CODEWARNINGMultiline expression must be indented after first line

Informational

RuleSeverityDescription
IMPLICIT_PARAMSINFOFunction uses implicit parameters (x/y/z) — consider naming them
MULTIPLE_STATEMENTS_PER_LINEINFOMultiple statements on one line
TODO_MARKERINFOTODO, FIXME, HACK or XXX marker found in comment