-
Notifications
You must be signed in to change notification settings - Fork 33
Vint linting policy summary
Tama McGlinn edited this page Aug 7, 2021
·
8 revisions
Vint has 3 definitions of severity as the following:
Severity | Description |
---|---|
error |
The detected code completely does not work. |
warning |
The detected code probably does not work. |
style_problem |
The detected code can work fine, but there is a style problem. |
Policy name | Description | Source |
---|---|---|
ProhibitAutocmdWithNoGroup |
:autocmd can omit [group] , but it is a bad coding and that makes your Vim heavy. If you define autocmds without a group, your Vim registers the same autocmd each :source ~/.vimrc . And your Vim executes the same autocmds each occurring a Event(e.g. FileType ). |
Anti-pattern of vimrc |
ProhibitCommandRelyOnUser | Avoid commands that rely on user settings. Always use normal! instead of normal. The latter depends upon the user's key mappings and could do anything. Avoid :s[ubstitute] , as its behavior depends upon a number of local settings. The same applies to other commands not listed here. |
Google Vimscript Style Guide |
ProhibitCommandWithUnintendedSideEffect | Avoid commands with unintended side effects. Avoid using :s[ubstitute] as it moves the cursor and prints error messages. Prefer functions (such as search() ) better suited to scripts. For many vim commands, functions exist that do the same thing with fewer side effects. See :help functions() for a list of built-in functions. |
Google Vimscript Style Guide |
ProhibitEncodingOptionAfterScriptEncoding | Vim can not recognize the character code of your vimrc when :scriptencoding is defined before :set encoding. When writing :set encoding, it should be described before :scriptencoding. | Anti-pattern of vimrc |
ProhibitEqualTildeOperator | Use the =~# or =~? operator families over the =~ family. The matching behavior depends upon the user's ignorecase and smartcase settings and on whether you compare them with the =~ , =~# , or =~? family of operators. Use the =~# and =~? operator families explicitly when comparing strings unless you explicitly need to honor the user's case sensitivity settings. |
Google Vimscript Style Guide |
ProhibitImplicitScopeBuiltinVariable | You should use a variable with a scope prefix to avoid variable name conflicts between builtins and implicit global/function local. | :help local-variable |
ProhibitMissingScriptEncoding | Vim can not recognize the character code of your vimrc when :scriptencoding is defined before :set encoding . When writing :set encoding , it should be described before :scriptencoding . |
Anti-pattern of vimrc |
ProhibitNoAbortFunction | In the autoload/ directory, defined with ! and abort . Autoloading allows functions to be loaded on demand, which makes startuptime faster and enforces function namespacing. Script-local functions are welcome, but should also live in autoload/ and be called by autoloaded functions. Non-library plugins should expose commands instead of functions. Command logic should be extracted into functions and autoloaded. ! allows developers to reload their functions without complaint. abort forces the function to halt when it encounters an error. |
Google Vimscript Style Guide |
ProhibitSetNoCompatible | You should not use set nocompatible because the command has unintended side-effects. See :help compatible . Don't worry, Vim set automatically compatible when a vimrc or gvimrc was found. |
|
ProhibitUnnecessaryDoubleQuote | Double quoted strings are semantically different in vimscript, and you probably don't want them (they break regexes). Use double quoted strings when you need an escape sequence (such as "\n" ) or if you know it doesn't matter and you need to embed single quotes. |
Google Vimscript Style Guide |
ProhibitUnusedVariable | Unused variables found. You should remove unused variables. | Nothing |
ProhibitUsingUndeclaredVariable | Undefined variable is used. You should modify the variable name or declare the variable. | Nothing |
Policy name | Description | Source |
---|---|---|
ProhibitAbbreviationOption | You should use strict options only to make codes more readable. | Anti-pattern of vimrc |
ProhibitImplicitScopeVariable | You should use a variable with a scope prefix. | Anti-pattern of vimrc |