From d7ed49f84964aebdaa180b553e83943cd85c5d20 Mon Sep 17 00:00:00 2001 From: w0rp Date: Sun, 22 Jan 2017 14:54:57 +0000 Subject: [PATCH] Add a script for custom checks to enforce using the abort flag for functions and trailing whitespace, and fix existing issues. --- Makefile | 8 +++ ale_linters/chef/foodcritic.vim | 2 +- ale_linters/coffee/coffeelint.vim | 2 +- ale_linters/d/dmd.vim | 6 +- ale_linters/elixir/credo.vim | 2 +- ale_linters/elm/make.vim | 2 +- ale_linters/fortran/gcc.vim | 2 +- ale_linters/haskell/ghc.vim | 2 +- ale_linters/haskell/hlint.vim | 2 +- ale_linters/javascript/eslint.vim | 2 +- ale_linters/javascript/flow.vim | 2 +- ale_linters/javascript/jshint.vim | 2 +- ale_linters/json/jsonlint.vim | 2 +- ale_linters/lua/luacheck.vim | 2 +- ale_linters/matlab/mlint.vim | 2 +- ale_linters/ocaml/merlin.vim | 2 +- ale_linters/perl/perl.vim | 2 +- ale_linters/perl/perlcritic.vim | 2 +- ale_linters/php/hack.vim | 2 +- ale_linters/php/php.vim | 2 +- ale_linters/php/phpcs.vim | 4 +- ale_linters/puppet/puppet.vim | 2 +- ale_linters/ruby/rubocop.vim | 2 +- ale_linters/rust/cargo.vim | 2 +- ale_linters/scala/scalac.vim | 2 +- ale_linters/scss/scsslint.vim | 2 +- ale_linters/sh/shell.vim | 6 +- ale_linters/sh/shellcheck.vim | 4 +- ale_linters/typescript/tslint.vim | 2 +- ale_linters/typescript/typecheck.vim | 2 +- ale_linters/verilog/iverilog.vim | 2 +- ale_linters/verilog/verilator.vim | 2 +- ale_linters/yaml/yamllint.vim | 2 +- autoload/ale/list.vim | 4 +- custom-checks | 83 ++++++++++++++++++++++++++++ plugin/ale.vim | 6 +- 36 files changed, 134 insertions(+), 43 deletions(-) create mode 100755 custom-checks diff --git a/Makefile b/Makefile index 438ae69..a8c1da4 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,14 @@ test: test-setup docker run -a stdout $(DOCKER_FLAGS) vint -s /testplugin | sed s:^/testplugin/:: || EXIT=$$?; \ set +o pipefail; \ echo; \ + echo '========================================'; \ + echo 'Running custom checks'; \ + echo '========================================'; \ + echo 'Custom warnings/errors follow:'; \ + echo; \ + set -o pipefail; \ + docker run -a stdout $(DOCKER_FLAGS) /testplugin/custom-checks /testplugin | sed s:^/testplugin/:: || EXIT=$$?; \ + set +o pipefail; \ echo; \ exit $$EXIT; diff --git a/ale_linters/chef/foodcritic.vim b/ale_linters/chef/foodcritic.vim index 35f5c9b..bfe73c3 100644 --- a/ale_linters/chef/foodcritic.vim +++ b/ale_linters/chef/foodcritic.vim @@ -1,7 +1,7 @@ " Author: Edward Larkey " Description: This file adds the foodcritic linter for Chef files. -function! ale_linters#chef#foodcritic#Handle(buffer, lines) +function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort " Matches patterns line the following: " " FC002: Avoid string interpolation where not required: httpd.rb:13 diff --git a/ale_linters/coffee/coffeelint.vim b/ale_linters/coffee/coffeelint.vim index e121513..96b8c59 100644 --- a/ale_linters/coffee/coffeelint.vim +++ b/ale_linters/coffee/coffeelint.vim @@ -1,7 +1,7 @@ " Author: Prashanth Chandra https://github.com/prashcr " Description: coffeelint linter for coffeescript files -function! ale_linters#coffee#coffeelint#Handle(buffer, lines) +function! ale_linters#coffee#coffeelint#Handle(buffer, lines) abort " Matches patterns like the following: " " path,lineNumber,lineNumberEnd,level,message diff --git a/ale_linters/d/dmd.vim b/ale_linters/d/dmd.vim index 8619eba..0a6e9bf 100644 --- a/ale_linters/d/dmd.vim +++ b/ale_linters/d/dmd.vim @@ -2,7 +2,7 @@ " Description: "dmd for D files" " A function for finding the dmd-wrapper script in the Vim runtime paths -function! s:FindWrapperScript() +function! s:FindWrapperScript() abort for l:parent in split(&runtimepath, ',') " Expand the path to deal with ~ issues. let l:path = expand(l:parent . '/' . 'dmd-wrapper') @@ -13,7 +13,7 @@ function! s:FindWrapperScript() endfor endfunction -function! ale_linters#d#dmd#GetCommand(buffer) +function! ale_linters#d#dmd#GetCommand(buffer) abort let l:wrapper_script = s:FindWrapperScript() let l:command = l:wrapper_script . ' -o- -vcolumns -c' @@ -21,7 +21,7 @@ function! ale_linters#d#dmd#GetCommand(buffer) return l:command endfunction -function! ale_linters#d#dmd#Handle(buffer, lines) +function! ale_linters#d#dmd#Handle(buffer, lines) abort " Matches patterns lines like the following: " /tmp/tmp.qclsa7qLP7/file.d(1): Error: function declaration without return type. (Note that constructors are always named 'this') " /tmp/tmp.G1L5xIizvB.d(8,8): Error: module weak_reference is in file 'dstruct/weak_reference.d' which cannot be read diff --git a/ale_linters/elixir/credo.vim b/ale_linters/elixir/credo.vim index fe34abc..4ebecf7 100644 --- a/ale_linters/elixir/credo.vim +++ b/ale_linters/elixir/credo.vim @@ -1,6 +1,6 @@ " Author: hauleth - https://github.com/haulethe -function! ale_linters#elixir#credo#Handle(buffer, lines) +function! ale_linters#elixir#credo#Handle(buffer, lines) abort " Matches patterns line the following: " " stdin:19: F: Pipe chain should start with a raw value. diff --git a/ale_linters/elm/make.vim b/ale_linters/elm/make.vim index abf4beb..35522f1 100644 --- a/ale_linters/elm/make.vim +++ b/ale_linters/elm/make.vim @@ -1,7 +1,7 @@ " Author: buffalocoder - https://github.com/buffalocoder " Description: Elm linting in Ale. Closely follows the Syntastic checker in https://github.com/ElmCast/elm-vim. -function! ale_linters#elm#make#Handle(buffer, lines) +function! ale_linters#elm#make#Handle(buffer, lines) abort let l:output = [] let l:is_windows = has('win32') let l:temp_dir = l:is_windows ? $TMP : $TMPDIR diff --git a/ale_linters/fortran/gcc.vim b/ale_linters/fortran/gcc.vim index 4129eca..73ec788 100644 --- a/ale_linters/fortran/gcc.vim +++ b/ale_linters/fortran/gcc.vim @@ -6,7 +6,7 @@ if !exists('g:ale_fortran_gcc_options') let g:ale_fortran_gcc_options = '-Wall' endif -function! ale_linters#fortran#gcc#Handle(buffer, lines) +function! ale_linters#fortran#gcc#Handle(buffer, lines) abort " We have to match a starting line and a later ending line together, " like so. " diff --git a/ale_linters/haskell/ghc.vim b/ale_linters/haskell/ghc.vim index def883e..5ddc15f 100644 --- a/ale_linters/haskell/ghc.vim +++ b/ale_linters/haskell/ghc.vim @@ -7,7 +7,7 @@ endif let g:loaded_ale_linters_haskell_ghc = 1 -function! ale_linters#haskell#ghc#Handle(buffer, lines) +function! ale_linters#haskell#ghc#Handle(buffer, lines) abort " Look for lines like the following. " " /dev/stdin:28:26: Not in scope: `>>>>>' diff --git a/ale_linters/haskell/hlint.vim b/ale_linters/haskell/hlint.vim index 3aa93fa..5b870e3 100644 --- a/ale_linters/haskell/hlint.vim +++ b/ale_linters/haskell/hlint.vim @@ -1,7 +1,7 @@ " Author: jparoz " Description: hlint for Haskell files -function! ale_linters#haskell#hlint#Handle(buffer, lines) +function! ale_linters#haskell#hlint#Handle(buffer, lines) abort let l:errors = json_decode(join(a:lines, '')) let l:output = [] diff --git a/ale_linters/javascript/eslint.vim b/ale_linters/javascript/eslint.vim index 95948fb..c2794ec 100644 --- a/ale_linters/javascript/eslint.vim +++ b/ale_linters/javascript/eslint.vim @@ -28,7 +28,7 @@ function! ale_linters#javascript#eslint#GetCommand(buffer) abort \ . ' -f unix --stdin --stdin-filename %s' endfunction -function! ale_linters#javascript#eslint#Handle(buffer, lines) +function! ale_linters#javascript#eslint#Handle(buffer, lines) abort " Matches patterns line the following: " " /path/to/some-filename.js:47:14: Missing trailing comma. [Warning/comma-dangle] diff --git a/ale_linters/javascript/flow.vim b/ale_linters/javascript/flow.vim index f3a1210..f0b81b1 100644 --- a/ale_linters/javascript/flow.vim +++ b/ale_linters/javascript/flow.vim @@ -24,7 +24,7 @@ function! ale_linters#javascript#flow#GetCommand(buffer) abort \ . ' check-contents --respect-pragma --json --from ale %s' endfunction -function! ale_linters#javascript#flow#Handle(buffer, lines) +function! ale_linters#javascript#flow#Handle(buffer, lines) abort let l:str = join(a:lines, '') if l:str ==# '' return [] diff --git a/ale_linters/javascript/jshint.vim b/ale_linters/javascript/jshint.vim index f82011d..f4b6651 100644 --- a/ale_linters/javascript/jshint.vim +++ b/ale_linters/javascript/jshint.vim @@ -19,7 +19,7 @@ function! ale_linters#javascript#jshint#GetExecutable(buffer) abort \) endfunction -function! ale_linters#javascript#jshint#GetCommand(buffer) +function! ale_linters#javascript#jshint#GetCommand(buffer) abort " Search for a local JShint config locaation, and default to a global one. let l:jshint_config = ale#util#ResolveLocalPath( \ a:buffer, diff --git a/ale_linters/json/jsonlint.vim b/ale_linters/json/jsonlint.vim index ca9a06c..5af8f62 100644 --- a/ale_linters/json/jsonlint.vim +++ b/ale_linters/json/jsonlint.vim @@ -1,6 +1,6 @@ " Author: KabbAmine -function! ale_linters#json#jsonlint#Handle(buffer, lines) +function! ale_linters#json#jsonlint#Handle(buffer, lines) abort " Matches patterns like the following: " line 2, col 15, found: 'STRING' - expected: 'EOF', '}', ',', ']'. diff --git a/ale_linters/lua/luacheck.vim b/ale_linters/lua/luacheck.vim index 9036c31..ace464c 100644 --- a/ale_linters/lua/luacheck.vim +++ b/ale_linters/lua/luacheck.vim @@ -4,7 +4,7 @@ let g:ale_lua_luacheck_executable = \ get(g:, 'ale_lua_luacheck_executable', 'luacheck') -function! ale_linters#lua#luacheck#Handle(buffer, lines) +function! ale_linters#lua#luacheck#Handle(buffer, lines) abort " Matches patterns line the following: " " artal.lua:159:17: (W111) shadowing definition of loop variable 'i' on line 106 diff --git a/ale_linters/matlab/mlint.vim b/ale_linters/matlab/mlint.vim index e1e6cf0..302e75c 100644 --- a/ale_linters/matlab/mlint.vim +++ b/ale_linters/matlab/mlint.vim @@ -4,7 +4,7 @@ let g:ale_matlab_mlint_executable = \ get(g:, 'ale_matlab_mlint_executable', 'mlint') -function! ale_linters#matlab#mlint#Handle(buffer, lines) +function! ale_linters#matlab#mlint#Handle(buffer, lines) abort " Matches patterns like the following: " " L 27 (C 1): FNDEF: Terminate statement with semicolon to suppress output. diff --git a/ale_linters/ocaml/merlin.vim b/ale_linters/ocaml/merlin.vim index f8e0329..75cdb12 100644 --- a/ale_linters/ocaml/merlin.vim +++ b/ale_linters/ocaml/merlin.vim @@ -5,7 +5,7 @@ if !exists('g:merlin') finish endif -function! ale_linters#ocaml#merlin#Handle(buffer, lines) +function! ale_linters#ocaml#merlin#Handle(buffer, lines) abort let l:errors = merlin#ErrorLocList() return l:errors endfunction diff --git a/ale_linters/perl/perl.vim b/ale_linters/perl/perl.vim index 28cf787..3724244 100644 --- a/ale_linters/perl/perl.vim +++ b/ale_linters/perl/perl.vim @@ -1,7 +1,7 @@ " Author: Vincent Lequertier " Description: This file adds support for checking perl syntax -function! ale_linters#perl#perl#Handle(buffer, lines) +function! ale_linters#perl#perl#Handle(buffer, lines) abort let l:pattern = '\(.\+\) at \(.\+\) line \(\d\+\)' let l:output = [] diff --git a/ale_linters/perl/perlcritic.vim b/ale_linters/perl/perlcritic.vim index d1152bb..dfad2d4 100644 --- a/ale_linters/perl/perlcritic.vim +++ b/ale_linters/perl/perlcritic.vim @@ -1,7 +1,7 @@ " Author: Vincent Lequertier " Description: This file adds support for checking perl with perl critic -function! ale_linters#perl#perlcritic#Handle(buffer, lines) +function! ale_linters#perl#perlcritic#Handle(buffer, lines) abort let l:pattern = '\(.\+\) at \(.\+\) line \(\d\+\)' let l:output = [] diff --git a/ale_linters/php/hack.vim b/ale_linters/php/hack.vim index bacd835..5c90247 100644 --- a/ale_linters/php/hack.vim +++ b/ale_linters/php/hack.vim @@ -1,7 +1,7 @@ " Author: Zefei Xuan " Description: Hack type checking (http://hacklang.org/) -function! ale_linters#php#hack#Handle(buffer, lines) +function! ale_linters#php#hack#Handle(buffer, lines) abort let l:pattern = '^\(.*\):\(\d\+\):\(\d\+\),\(\d\+\): \(.\+])\)$' let l:output = [] diff --git a/ale_linters/php/php.vim b/ale_linters/php/php.vim index 573036d..b807fee 100644 --- a/ale_linters/php/php.vim +++ b/ale_linters/php/php.vim @@ -1,7 +1,7 @@ " Author: Spencer Wood " Description: This file adds support for checking PHP with php-cli -function! ale_linters#php#php#Handle(buffer, lines) +function! ale_linters#php#php#Handle(buffer, lines) abort " Matches patterns like the following: " " Parse error: parse error in - on line 7 diff --git a/ale_linters/php/phpcs.vim b/ale_linters/php/phpcs.vim index 6e64d30..4b3cabd 100644 --- a/ale_linters/php/phpcs.vim +++ b/ale_linters/php/phpcs.vim @@ -1,7 +1,7 @@ " Author: jwilliams108 " Description: phpcs for PHP files -function! ale_linters#php#phpcs#GetCommand(buffer) +function! ale_linters#php#phpcs#GetCommand(buffer) abort let l:command = 'phpcs -s --report=emacs --stdin-path=%s' " This option can be set to change the standard used by phpcs @@ -12,7 +12,7 @@ function! ale_linters#php#phpcs#GetCommand(buffer) return l:command endfunction -function! ale_linters#php#phpcs#Handle(buffer, lines) +function! ale_linters#php#phpcs#Handle(buffer, lines) abort " Matches against lines like the following: " " /path/to/some-filename.php:18:3: error - Line indented incorrectly; expected 4 spaces, found 2 (Generic.WhiteSpace.ScopeIndent.IncorrectExact) diff --git a/ale_linters/puppet/puppet.vim b/ale_linters/puppet/puppet.vim index b00a7dd..534894c 100644 --- a/ale_linters/puppet/puppet.vim +++ b/ale_linters/puppet/puppet.vim @@ -1,6 +1,6 @@ " Author: Alexander Olofsson -function! ale_linters#puppet#puppet#Handle(buffer, lines) +function! ale_linters#puppet#puppet#Handle(buffer, lines) abort " Matches patterns like the following: " Error: Could not parse for environment production: Syntax error at ':' at /root/puppetcode/modules/nginx/manifests/init.pp:43:12 diff --git a/ale_linters/ruby/rubocop.vim b/ale_linters/ruby/rubocop.vim index 7200701..fad0212 100644 --- a/ale_linters/ruby/rubocop.vim +++ b/ale_linters/ruby/rubocop.vim @@ -1,7 +1,7 @@ " Author: ynonp - https://github.com/ynonp " Description: rubocop for Ruby files -function! ale_linters#ruby#rubocop#Handle(buffer, lines) +function! ale_linters#ruby#rubocop#Handle(buffer, lines) abort " Matches patterns line the following: " " /_:47:14: 83:29: C: Prefer single-quoted strings when you don't diff --git a/ale_linters/rust/cargo.vim b/ale_linters/rust/cargo.vim index 0f04f27..738821d 100644 --- a/ale_linters/rust/cargo.vim +++ b/ale_linters/rust/cargo.vim @@ -2,7 +2,7 @@ " Description: rustc invoked by cargo for rust files -function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) +function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort if ale#util#FindNearestFile(a:bufnr, 'Cargo.toml') !=# '' return 'cargo' else diff --git a/ale_linters/scala/scalac.vim b/ale_linters/scala/scalac.vim index ea13bbd..c2e7543 100644 --- a/ale_linters/scala/scalac.vim +++ b/ale_linters/scala/scalac.vim @@ -2,7 +2,7 @@ " Author: Zoltan Kalmar - https://github.com/kalmiz " Description: Basic scala support using scalac -function! ale_linters#scala#scalac#Handle(buffer, lines) +function! ale_linters#scala#scalac#Handle(buffer, lines) abort " Matches patterns line the following: " " /var/folders/5q/20rgxx3x1s34g3m14n5bq0x80000gn/T/vv6pSsy/0:26: error: expected class or object definition diff --git a/ale_linters/scss/scsslint.vim b/ale_linters/scss/scsslint.vim index 399082f..1ee0662 100644 --- a/ale_linters/scss/scsslint.vim +++ b/ale_linters/scss/scsslint.vim @@ -1,7 +1,7 @@ " Author: w0rp " Description: This file add scsslint support for SCSS support -function! ale_linters#scss#scsslint#Handle(buffer, lines) +function! ale_linters#scss#scsslint#Handle(buffer, lines) abort " Matches patterns like the following: " " test.scss:2:1 [W] Indentation: Line should be indented 2 spaces, but was indented 4 spaces diff --git a/ale_linters/sh/shell.vim b/ale_linters/sh/shell.vim index f996f7e..786cc0e 100644 --- a/ale_linters/sh/shell.vim +++ b/ale_linters/sh/shell.vim @@ -11,7 +11,7 @@ if !exists('g:ale_linters_sh_shell_default_shell') endif endif -function! ale_linters#sh#shell#GetExecutable(buffer) +function! ale_linters#sh#shell#GetExecutable(buffer) abort let l:banglines = getbufline(a:buffer, 1) " Take the shell executable from the hashbang, if we can. @@ -29,11 +29,11 @@ function! ale_linters#sh#shell#GetExecutable(buffer) return g:ale_linters_sh_shell_default_shell endfunction -function! ale_linters#sh#shell#GetCommand(buffer) +function! ale_linters#sh#shell#GetCommand(buffer) abort return ale_linters#sh#shell#GetExecutable(a:buffer) . ' -n' endfunction -function! ale_linters#sh#shell#Handle(buffer, lines) +function! ale_linters#sh#shell#Handle(buffer, lines) abort " Matches patterns line the following: " " bash: line 13: syntax error near unexpected token `d' diff --git a/ale_linters/sh/shellcheck.vim b/ale_linters/sh/shellcheck.vim index d0fe8b1..735a0cd 100644 --- a/ale_linters/sh/shellcheck.vim +++ b/ale_linters/sh/shellcheck.vim @@ -16,7 +16,7 @@ else let s:exclude_option = '' endif -function! s:GetDialectArgument() +function! s:GetDialectArgument() abort if exists('b:is_bash') && b:is_bash return '-s bash' elseif exists('b:is_sh') && b:is_sh @@ -28,7 +28,7 @@ function! s:GetDialectArgument() return '' endfunction -function! ale_linters#sh#shellcheck#GetCommand(buffer) +function! ale_linters#sh#shellcheck#GetCommand(buffer) abort return 'shellcheck ' . s:exclude_option . ' ' . s:GetDialectArgument() . ' -f gcc -' endfunction diff --git a/ale_linters/typescript/tslint.vim b/ale_linters/typescript/tslint.vim index d540597..eb5b1a7 100644 --- a/ale_linters/typescript/tslint.vim +++ b/ale_linters/typescript/tslint.vim @@ -1,7 +1,7 @@ " Author: Prashanth Chandra https://github.com/prashcr " Description: tslint for TypeScript files -function! ale_linters#typescript#tslint#Handle(buffer, lines) +function! ale_linters#typescript#tslint#Handle(buffer, lines) abort " Matches patterns like the following: " " hello.ts[7, 41]: trailing whitespace diff --git a/ale_linters/typescript/typecheck.vim b/ale_linters/typescript/typecheck.vim index 3a237e3..080a238 100644 --- a/ale_linters/typescript/typecheck.vim +++ b/ale_linters/typescript/typecheck.vim @@ -1,7 +1,7 @@ " Author: Prashanth Chandra https://github.com/prashcr, Aleh Kashnikau https://github.com/mkusher " Description: type checker for TypeScript files -function! ale_linters#typescript#typecheck#Handle(buffer, lines) +function! ale_linters#typescript#typecheck#Handle(buffer, lines) abort " Matches patterns like the following: " " hello.ts[7, 41]: Property 'a' does not exist on type 'A' diff --git a/ale_linters/verilog/iverilog.vim b/ale_linters/verilog/iverilog.vim index 97d4a1f..d10661d 100644 --- a/ale_linters/verilog/iverilog.vim +++ b/ale_linters/verilog/iverilog.vim @@ -1,7 +1,7 @@ " Author: Masahiro H https://github.com/mshr-h " Description: iverilog for verilog files -function! ale_linters#verilog#iverilog#Handle(buffer, lines) +function! ale_linters#verilog#iverilog#Handle(buffer, lines) abort " Look for lines like the following. " " tb_me_top.v:37: warning: Instantiating module me_top with dangling input port 1 (rst_n) floating. diff --git a/ale_linters/verilog/verilator.vim b/ale_linters/verilog/verilator.vim index d8e105a..534e1ae 100644 --- a/ale_linters/verilog/verilator.vim +++ b/ale_linters/verilog/verilator.vim @@ -1,7 +1,7 @@ " Author: Masahiro H https://github.com/mshr-h " Description: verilator for verilog files -function! ale_linters#verilog#verilator#Handle(buffer, lines) +function! ale_linters#verilog#verilator#Handle(buffer, lines) abort " Look for lines like the following. " " %Error: addr_gen.v:3: syntax error, unexpected IDENTIFIER diff --git a/ale_linters/yaml/yamllint.vim b/ale_linters/yaml/yamllint.vim index a541a83..05af709 100644 --- a/ale_linters/yaml/yamllint.vim +++ b/ale_linters/yaml/yamllint.vim @@ -1,6 +1,6 @@ " Author: KabbAmine -function! ale_linters#yaml#yamllint#Handle(buffer, lines) +function! ale_linters#yaml#yamllint#Handle(buffer, lines) abort " Matches patterns line the following: " something.yaml:1:1: [warning] missing document start "---" (document-start) " something.yml:2:1: [error] syntax error: expected the node content, but found '' diff --git a/autoload/ale/list.vim b/autoload/ale/list.vim index 480880e..a086b10 100644 --- a/autoload/ale/list.vim +++ b/autoload/ale/list.vim @@ -4,11 +4,11 @@ " Return 1 if there is a buffer with buftype == 'quickfix' in bufffer list function! ale#list#IsQuickfixOpen() abort for l:buf in range(1, bufnr('$')) - if getbufvar(l:buf, '&buftype') ==# 'quickfix' + if getbufvar(l:buf, '&buftype') ==# 'quickfix' return 1 endif endfor - return 0 + return 0 endfunction function! ale#list#SetLists(loclist) abort diff --git a/custom-checks b/custom-checks new file mode 100755 index 0000000..798049e --- /dev/null +++ b/custom-checks @@ -0,0 +1,83 @@ +#!/bin/bash -eu + +# This Bash script implements custom sanity checks for scripts beyond what +# Vint covers, which are easy to check with regex. + +# A flag for automatically fixing some errors. +FIX_ERRORS=0 +RETURN_CODE=0 + +function print_help() { + echo "Usage: ./custom-checks [--fix] [DIRECTORY]" 1>&2 + echo 1>&2 + echo " -h, --help Print this help text" 1>&2 + echo " --fix Automatically fix some errors" 1>&2 + exit 1 +} + +while [ $# -ne 0 ]; do + case $1 in + -h) ;& --help) + print_help + ;; + --fix) + FIX_ERRORS=1 + shift + ;; + --) + shift + break + ;; + -?*) + echo "Invalid argument: $1" 1>&2 + exit 1 + ;; + *) + break + ;; + esac +done + +if [ $# -eq 0 ] || [ -z "$1" ]; then + print_help +fi + +# Called to output an error. +# If called at least one, the return code for this script will be 1. +output_error() { + echo "$FILENAME:$LINE_NUMBER $1" + RETURN_CODE=1 +} + +# This function is called for each line in each file to check syntax. +check_line() { + line="$1" + + if [[ "$line" =~ ^function ]]; then + if ! [[ "$line" =~ abort$ ]]; then + if ((FIX_ERRORS)); then + # Use sed to add the 'abort' flag + sed -i "${LINE_NUMBER}s/$/ abort/" "$FILENAME" + else + output_error 'Function without abort keyword (See :help except-compat)' + fi + fi + fi + + if [[ "$line" =~ ' '+$ ]]; then + output_error 'Trailing whitespace' + fi +} + +# Loop through all of the vim files and keep track of the file line numbers. +for FILENAME in $(find "$1" -name '*.vim'); do + LINE_NUMBER=0 + + while read; do + LINE_NUMBER=$(expr $LINE_NUMBER + 1) + + check_line "$REPLY" + done < "$FILENAME" +done + +exit $RETURN_CODE diff --git a/plugin/ale.vim b/plugin/ale.vim index cb90aac..28812be 100644 --- a/plugin/ale.vim +++ b/plugin/ale.vim @@ -79,7 +79,7 @@ endif let g:ale_set_loclist = get(g:, 'ale_set_loclist', 1) let g:ale_set_quickfix = get(g:, 'ale_set_quickfix', 0) -" This flag dictates if ale open the configured loclist +" This flag dictates if ale open the configured loclist let g:ale_open_list = get(g:, 'ale_open_list', 0) " This flag dictates if ale keeps open loclist even if there is no error in loclist @@ -154,10 +154,10 @@ augroup END " Backwards Compatibility -function! ALELint(delay) +function! ALELint(delay) abort call ale#Queue(a:delay) endfunction -function! ALEGetStatusLine() +function! ALEGetStatusLine() abort return ale#statusline#Status() endfunction