Commit Graph

34 Commits

Author SHA1 Message Date
Vidar Holen 3e3e4fd0cd Avoid defining flags for non-literal parameters 2019-07-01 23:22:09 -07:00
Benjamin Gordon f6ba500d6b Add support for basic shflags semantics
The shflags command-line flags library creates variables at runtime
with a few well-defined functions.  This causes shellcheck to spit out
lots of warnings about unassigned variables, as well as miss warnings
about unused flag variables.

We can address this with two parts:

1. Pretend that the shflags global variables are predefined like other
   shell variables so that shellcheck doesn't expect users to set them.
2. Treat DEFINE_string, DEFINE_int, etc. as new commands that create
   variables, similar to the existing read, local, mapfile, etc.

Part 1 can theoretically be addresssed without this by following sourced
files, but that doesn't help if people are otherwise not following
external sources.

The new behavior is on by default, similar to automatic bats test
behavior.

Addresses #1597
2019-06-25 12:14:54 -06:00
Vidar Holen 5242e384a1 Fix error spans for shebang warnings (fixes #1620) 2019-06-23 13:49:08 -07:00
Vidar Holen 52a9d90e1a
Merge pull request #1580 from virgilwashere/copyright
Update Copyright to year 2019; README linting
2019-05-19 12:03:15 -07:00
Benjamin Gordon aa3b709b5d Track whether braces were present in T_DollarBraced
References of the form $var and ${var} both map to the same structure in
the AST, which prevents any later analysis functions from distinguishing
them.  In preparation for adding checks that need this info, add a Bool
to T_DollarBraced that tracks whether the braces were seen at parsing
time and update all references so that this change is a no-op.
2019-05-14 11:01:38 -06:00
Virgil ea05271fa3 📝 Update Copyright to year 2019 and Markdown linting
- [x] 📝 Update Copyright to year 2019

- [x] 📝 MD009/no-trailing-spaces: Trailing spaces [Expected: 0 or 2; Actual: 1]
- [x] 📝 MD034/no-bare-urls: Bare URL used

- [ ] 📝 ~MD004/ul-style: Unordered list style [Expected: dash; Actual: asterisk]~
- [ ] ~add missing TOC entries~
2019-05-14 20:12:34 +10:00
Vidar Holen 50116e8aee Don't suggest [[..]] for sh in SC2081 (fixes #1562) 2019-05-13 20:45:53 -07:00
Vidar Holen 5fb1da6814 Replace verbose checks with optional checks 2019-05-12 19:14:04 -07:00
Vidar Holen 9470b9dc31 Don't mention arrays in SC2089 in sh/dash (fixes #1014) 2019-04-27 16:22:01 -07:00
Vidar Holen bf1003eae3 Auto-disable SC2119 when disabling SC2120 (fixes #703) 2019-04-27 15:20:07 -07:00
Vidar Holen 5b7354918f SC2249: When verbose, warn about missing default case (fixes #997) 2019-04-14 16:58:17 -07:00
Vidar Holen c860b74505 Set SC2243/SC2244 level to "verbose" 2019-04-13 13:40:18 -07:00
Tito Sacchi bd19ab4fa9 Fix issues #896 and #433: printf -v and arrays 2019-02-24 09:45:31 +01:00
Vidar Holen c97cb8cf54 Merge branch 'bats-support' of https://github.com/damienrg/shellcheck 2019-01-20 13:35:12 -08:00
Vidar Holen f187382a0c Add bats support
This is motivated by the fact that the popularity of bats is increasing
since the creation of bats-core/bats-core.

The code is a cherry-pick of koalaman/shellcheck/bats branch.

Fix koalaman/shellcheck#417.
2019-01-20 14:59:37 +01:00
Tito Sacchi 1e6a30905a Make ShellCheck not emit warnings about the shebang if the shell
type is determined from the extension
2019-01-14 14:32:25 +01:00
Tito Sacchi a4b9cec9f0 Fix #1369 (Use file extension to detect shell)
The precedence order that is used to determine the shell
is the following:
1. ShellCheck directive
2. Shebang
3. File extension
A new field `asFallbackShell` has been
added to the record type `AnalysisSpec`.
2019-01-14 14:32:25 +01:00
Vidar Holen df7f00eaed Remove duplicate `pathTo` and unused `replaceMultiLines` 2019-01-09 17:51:43 -08:00
Vidar Holen 73822c3588 Allow SC2243 and SC2244 to trigger with quotes, add fix 2018-12-28 19:02:06 -08:00
Vidar Holen 5b3f17c29d Allow tests to access token positions for fixes 2018-12-16 13:17:59 -08:00
Vidar Holen bcd13614eb Improve Fix memory usage 2018-12-09 15:01:08 -08:00
Ng Zhi An 4a87d2a3de Expose token positions in params, use that to construct fixes 2018-12-09 15:01:08 -08:00
Ng Zhi An 41613babd9 Prototype fix 2018-12-09 15:01:08 -08:00
Peter Simons 5f1c969546 getParentTree: avoid pattern matching in do notation
Pattern matching in "do" requires a MonadFail context, which we don't have in
pure code. Instead, we'll use "case-of" to bind the part of the state that
we're interested in.
2018-09-27 17:30:41 +02:00
Ng Zhi An 07f04e13ce Understand array variable declaration in read (fixes #679 fixes #1272)
It used to only treat all trailing variables in read as varaible
declarings, but an array variable can be declared in other positions:

    read -a foo -r

foo is a declared variable, and multiple such variables can be declared.
2018-09-08 09:19:02 -07:00
Ng Zhi An c8e0797350 Make data in Interface more opaque 2018-08-17 22:10:18 -07:00
Vidar Holen 5005dc0fa1 Allow directive/-s to override shebang blacklist (fixes #974) 2018-07-22 12:43:51 -07:00
Ng Zhi An 4dceecb1ed Handle offset references of the form [foo]:bar (fixes #1124) 2018-05-13 22:48:02 -07:00
Vidar Holen bca2ad4e18 Don't think declare -x -F var is used (fixes #1209). 2018-05-12 17:34:23 -07:00
Vidar Holen ef6a5b97b9 Refactor sudo checks into CommandChecks 2018-04-30 22:59:23 -07:00
Vidar Holen a1d8947297 Fix broken test stripping 2018-04-22 14:57:43 -07:00
Vanessa McHale 08aab3c161 hlints 2018-04-02 11:48:21 -05:00
Vanessa McHale cf39adff75 bump to latest ghc 2018-04-02 11:44:18 -05:00
Oleg Grenrus cd7c077ecc Move library into src/ 2018-03-08 19:57:40 +02:00