mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-01 23:55:33 +08:00
Merge pull request #3134 from Ian2020/master
Add shellcheck as linter for bats files
This commit is contained in:
@@ -22,7 +22,7 @@ Execute(The shellcheck handler should handle basic errors or warnings):
|
||||
\ 'code': 'SC1068',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#sh#shellcheck#Handle(bufnr(''), [
|
||||
\ ale#handlers#shellcheck#Handle(bufnr(''), [
|
||||
\ '-:2:1: warning: In POSIX sh, ''let'' is not supported. [SC2039]',
|
||||
\ '-:2:3: error: Don''t put spaces around the = in assignments. [SC1068]',
|
||||
\ ])
|
||||
@@ -38,6 +38,6 @@ Execute(The shellcheck handler should handle notes):
|
||||
\ 'code': 'SC2086',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#sh#shellcheck#Handle(bufnr(''), [
|
||||
\ ale#handlers#shellcheck#Handle(bufnr(''), [
|
||||
\ '-:3:3: note: Double quote to prevent globbing and word splitting. [SC2086]',
|
||||
\ ])
|
||||
|
||||
@@ -15,7 +15,7 @@ Given(A file with a Bash hashbang):
|
||||
Execute(/bin/bash should be detected appropriately):
|
||||
AssertEqual 'bash', ale#handlers#sh#GetShellType(bufnr(''))
|
||||
AssertEqual 'bash', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
||||
AssertEqual 'bash', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
||||
AssertEqual 'bash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
|
||||
|
||||
Given(A file with /bin/sh):
|
||||
#!/usr/bin/env sh -eu --foobar
|
||||
@@ -23,7 +23,7 @@ Given(A file with /bin/sh):
|
||||
Execute(/bin/sh should be detected appropriately):
|
||||
AssertEqual 'sh', ale#handlers#sh#GetShellType(bufnr(''))
|
||||
AssertEqual 'sh', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
||||
AssertEqual 'sh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
||||
AssertEqual 'sh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
|
||||
|
||||
Given(A file with bash as an argument to env):
|
||||
#!/usr/bin/env bash
|
||||
@@ -31,7 +31,7 @@ Given(A file with bash as an argument to env):
|
||||
Execute(/usr/bin/env bash should be detected appropriately):
|
||||
AssertEqual 'bash', ale#handlers#sh#GetShellType(bufnr(''))
|
||||
AssertEqual 'bash', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
||||
AssertEqual 'bash', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
||||
AssertEqual 'bash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
|
||||
|
||||
Given(A file with a tcsh hash bang and arguments):
|
||||
#!/usr/bin/env tcsh -eu --foobar
|
||||
@@ -39,7 +39,7 @@ Given(A file with a tcsh hash bang and arguments):
|
||||
Execute(tcsh should be detected appropriately):
|
||||
AssertEqual 'tcsh', ale#handlers#sh#GetShellType(bufnr(''))
|
||||
AssertEqual 'tcsh', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
||||
AssertEqual 'tcsh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
||||
AssertEqual 'tcsh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
|
||||
|
||||
Given(A file with a zsh hash bang and arguments):
|
||||
#!/usr/bin/env zsh -eu --foobar
|
||||
@@ -47,7 +47,7 @@ Given(A file with a zsh hash bang and arguments):
|
||||
Execute(zsh should be detected appropriately):
|
||||
AssertEqual 'zsh', ale#handlers#sh#GetShellType(bufnr(''))
|
||||
AssertEqual 'zsh', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
||||
AssertEqual 'zsh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
||||
AssertEqual 'zsh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
|
||||
|
||||
Given(A file with a csh hash bang and arguments):
|
||||
#!/usr/bin/env csh -eu --foobar
|
||||
@@ -55,7 +55,7 @@ Given(A file with a csh hash bang and arguments):
|
||||
Execute(csh should be detected appropriately):
|
||||
AssertEqual 'csh', ale#handlers#sh#GetShellType(bufnr(''))
|
||||
AssertEqual 'csh', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
||||
AssertEqual 'csh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
||||
AssertEqual 'csh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
|
||||
|
||||
Given(A file with a ksh hashbang):
|
||||
#!/bin/ksh
|
||||
@@ -63,7 +63,7 @@ Given(A file with a ksh hashbang):
|
||||
Execute(/bin/ksh should be detected appropriately):
|
||||
AssertEqual 'ksh', ale#handlers#sh#GetShellType(bufnr(''))
|
||||
AssertEqual 'ksh', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
||||
AssertEqual 'ksh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
||||
AssertEqual 'ksh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
|
||||
|
||||
Given(A file with a ksh as an argument to env):
|
||||
#!/usr/bin/env ksh
|
||||
@@ -71,7 +71,7 @@ Given(A file with a ksh as an argument to env):
|
||||
Execute(ksh should be detected appropriately):
|
||||
AssertEqual 'ksh', ale#handlers#sh#GetShellType(bufnr(''))
|
||||
AssertEqual 'ksh', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
||||
AssertEqual 'ksh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
||||
AssertEqual 'ksh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
|
||||
|
||||
Given(A file with a sh hash bang and arguments):
|
||||
#!/usr/bin/env sh -eu --foobar
|
||||
@@ -79,24 +79,24 @@ Given(A file with a sh hash bang and arguments):
|
||||
Execute(sh should be detected appropriately):
|
||||
AssertEqual 'sh', ale#handlers#sh#GetShellType(bufnr(''))
|
||||
AssertEqual 'sh', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
||||
AssertEqual 'sh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
||||
AssertEqual 'sh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
|
||||
|
||||
Given(A file without a hashbang):
|
||||
|
||||
Execute(The bash dialect should be used for shellcheck if b:is_bash is 1):
|
||||
let b:is_bash = 1
|
||||
|
||||
AssertEqual 'bash', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
||||
AssertEqual 'bash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
|
||||
|
||||
Execute(The sh dialect should be used for shellcheck if b:is_sh is 1):
|
||||
let b:is_sh = 1
|
||||
|
||||
AssertEqual 'sh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
||||
AssertEqual 'sh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
|
||||
|
||||
Execute(The ksh dialect should be used for shellcheck if b:is_kornshell is 1):
|
||||
let b:is_kornshell = 1
|
||||
|
||||
AssertEqual 'ksh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
||||
AssertEqual 'ksh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
|
||||
|
||||
Given(A file with /bin/ash):
|
||||
#!/bin/ash
|
||||
@@ -106,7 +106,7 @@ Execute(The ash dialect should be used for the shell and the base function):
|
||||
AssertEqual 'ash', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
||||
|
||||
Execute(dash should be used for shellcheck, which has no ash dialect):
|
||||
AssertEqual 'dash', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
||||
AssertEqual 'dash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
|
||||
|
||||
Given(A file with /bin/dash):
|
||||
#!/bin/dash
|
||||
@@ -116,4 +116,4 @@ Execute(The dash dialect should be used for the shell and the base function):
|
||||
AssertEqual 'dash', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
||||
|
||||
Execute(dash should be used for shellcheck):
|
||||
AssertEqual 'dash', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
||||
AssertEqual 'dash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
|
||||
|
||||
Reference in New Issue
Block a user