Commit Graph

162 Commits

Author SHA1 Message Date
Ben Walker
03a3a5c02d scripts: Add check_format test for JSON-RPC documentation
All JSON-RPCs must be documented in jsonrpc.md

Change-Id: Iec9119a01433fd0cbe4df4477ce94cc2feeb0d54
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4074
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: <dongx.yi@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Monica Kenguva <monica.kenguva@intel.com>
Community-CI: Mellanox Build Bot
2021-04-26 06:55:03 +00:00
Michal Berger
ec632be24f check_format: Make use of shellcheck's -x conditional
-x is supported since 0.4.0 release, make a note of that.

Signed-off-by: Michal Berger <michalx.berger@intel.com>
Change-Id: Icc64132536c18108029f6c5fa2cbdd5b27018d8b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7417
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
2021-04-19 12:47:51 +00:00
Michal Berger
0968ee2fcf scripts/check_format: Run shfmt against all bash files
Currently, reference repos which are used to clone the SPDK repo in
the CI pool's systems don't provide master head refs, hence there's
no easy way to diff against it.

Instead, simply run shfmt against all the bash files in the repo.
Impact on the performance should be minimal.

Also, cleanup some related code which is not used anymore.

Signed-off-by: Michal Berger <michalx.berger@intel.com>
Change-Id: Ie0d4e35b8ad214ceed1b4ea29b01a7423b8ff73b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6824
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2021-03-23 11:03:21 +00:00
Michal Berger
e7ab45baf7 check_format: Include all potential bash scripts from the repo
Checking only the .sh suffix was omitting ./configure and potentially
other bash scripts which don't necessarily have to include said suffix
in their name.

Signed-off-by: Michal Berger <michalx.berger@intel.com>
Change-Id: I6196559e8875de46f80d9c8426577a1a79b5996d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6026
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2021-02-04 16:11:20 +00:00
Tomasz Zawadzki
de016f2756 scripts/check_format: match exact string when moving symbols
Original code removed $symbol prefix from every entry in
$defined_symbols. This was incorrect shown by example
patch next in series.

Original function spdk_json_decode_object() was moved
and spdk_json_decode_object_relaxed() was added.
This resulted in $defined_symbols containing entry "_relaxed".

Now each entry in $defined_symbols is checked separatly to
match exactly to the removed $symbol.

Reported-by: Jacek Kalwas <jacek.kalwas@intel.com>
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I1d9931d2e93dc85465ce47a838a176c6ab5f1587
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4357
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Michal Berger <michalx.berger@intel.com>
2020-10-05 08:23:58 +00:00
Ben Walker
d61da0ccda scripts: Break check_format up into functions
Change-Id: I3e3bd44826453e0ff5cc5b01769e81b5fdd660ff
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4073
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-09-18 07:25:15 +00:00
Ben Walker
9f6f02f22e scripts: Detect shellcheck errors by looking at the length of
shellcheck.log

shellcheck does not seem to reliably return error codes, at least
on the 0.7.0 version packaged on Fedora. Instead, look at
whether shellcheck.log contains any output.

Change-Id: Iec3c4f416844eed6a6c75b9204e24c2bc7243f7a
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4072
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Michal Berger <michalx.berger@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-09-18 07:25:15 +00:00
Ben Walker
0ee7697e4d scripts: Always use tty mode for shellcheck
Even on version 0.7.0, the diff mode throws up a bunch of errors
that don't appear in the tty mode. We'll have to deal with those
at a later date.

Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Change-Id: Ic7001b9cf793e696bbf4bab0b0630e8d705a6905
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4071
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-09-18 07:25:15 +00:00
Seth Howell
5faea08e71 scripts/check_format.sh: fix naming convention check.
I had previously implemented a portion of the naming convention
check that looked for symbols that had been moved by performing
two checks:

git diff commit1 commit2 -- libname | grep for added function
git diff commit2 commit1 --libname | grep for added functions

and then subtracting the values returned by the second check from
the values returned by the first check. That works as long as the two
diffs are reciprocal (i.e. the first diff is a mirror image of the
second). However, this has proven to not be the case.

This change fixes that check by performing the smae diff twice and
grepping for removed functions the same time.

Change-Id: I09c81921d68436baeee706f2d9a6d30db1d23976
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3229
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-07-08 07:56:06 +00:00
Michal Berger
131e6b0208 check_format: Mitigate #1455
Make sure that git diff ignores all submodules while looking for
changes made by astyle. This should prevent the following issues
from occurring:

object directory /var/ci_repos/dpdk-submodule.git/objects does not exist; check .git/objects/info/alternates
object directory /var/ci_repos/intel-ipsec-mb.git/objects does not exist; check .git/objects/info/alternates
error: bad tree object HEAD
fatal: 'git status --porcelain=2' failed in submodule intel-ipsec-mb

Change-Id: Ie9a39e324674337fdbd6bf627da6e80775ceaeec
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3223
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-07-07 07:30:14 +00:00
Dayu Liu
415abe87fc check_format: fix pattern error of regular expression
In a few tools or languages, slash(/) is maybe a delimiter by default in regex.
An unescaped delimiter must be escaped with a backslash (\).
Otherwise the pattern of regular expression will be error
when delimiter is slash(/) in a few special environment, i.e. in MinGW32 git bash.

Signed-off-by: Dayu Liu <liu.dayu@zte.com.cn>
Change-Id: I73b556416b98e135eb240078dcc68f80e08c5e74
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2488
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Seth Howell <seth.howell@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-06-08 09:34:35 +00:00
Seth Howell
c2312f6cb3 test/check_format.sh: remove moved symbols in naming check
There was an edge case in this check where a public symbol
definition was just moved and that movement triggered this
check. Going forward, check the diff for symbols that were
both added and removed in the same patch. This indicates a
symbol that was just moved instead of newly added.

Signed-off-by: Seth Howell <seth.howell@intel.com>
Change-Id: I71bbcd6d6b3e0a2133e77c29f4ec7a4f2b09e3c2
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2765
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Community-CI: Mellanox Build Bot
2020-06-05 09:02:44 +00:00
Darek Stojaczyk
59ff57b93c scripts/check_format: use version_lt to compare shfmt version
It turns out we have a function to compare version numbers.
It additionally handles cases like "3.0.10 > 3.0.9". The
previous code returned false, the new one returns true.

version_lt() actually tests for less or equal, so compare
against 3.1.0 - the real minimum shfmt version we need.

Change-Id: Ibd18c4505e5b81c0073a907f23c3fc034cfbafbe
Suggested-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2574
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-06-02 09:51:14 +00:00
Seth Howell
a354903737 check_format: compare commits against previous commit.
Previously when doing the naming conventions check, we were
checking against master which was causing some weird issues on
patches which weren't rebased. The much simpler check is to just
compare each patch against the previous one.

This method still works to prevent any bad changes from getting
merged, but handles naming issues on a patch by patch basis.

Signed-off-by: Seth Howell <seth.howell@intel.com>
Change-Id: Ic031ce07ca1c67819b792dc292dcf6c50df5b1a2
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2733
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
2020-06-02 09:48:43 +00:00
Michal Berger
c988348361 check_format: Use $output_dir to store shfmt patch in
If $output_dir is set, putting the shfmt diff there will make it
easier to extract it and/or look it up from the side of the per
patch build.

Change-Id: Iefb601a29f165e59b7670a8878e95bb6b16c9650
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2277
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2020-05-29 14:59:53 +00:00
Seth Howell
0506fd21ff scripts/check_format: add a check for proper naming conventions.
This test prevents anyone from adding a function that begins with
spdk to the lib or module directories without also adding that file
to the corresponding map file and a header in spdk/include or
spdk_internal/include.

Signed-off-by: Seth Howell <seth.howell@intel.com>
Change-Id: Ife7db13d4bb8fec7570c8492ac3326222a850c36
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2423
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2020-05-27 07:35:02 +00:00
Seth Howell
4bd48a3d97 scripts/check_format: remove extra output from shfmt check.
All of the other checks simply print OK if the test passes
this check prints out a lot of text (especially when run at the
tip of long patch series) that can make it difficult to tell if
anything is actually wrong.

Signed-off-by: Seth Howell <seth.howell@intel.com>
Change-Id: Ie681d200aa13f208e4afa1ab419cbad63ef6606c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2403
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-05-21 09:19:42 +00:00
Michal Berger
3425fc1fb8 check_format: Don't attempt to review perms of the symlinks
Change-Id: I3cd20ad9f1cadb5ca5e6de78d9b44d5df95f51d8
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2502
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: John Kariuki <John.K.Kariuki@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-05-19 09:43:37 +00:00
Darek Stojaczyk
e5f021c10e scripts/check_format: auto-detect shfmt binary
A newer version of shfmt was released, but the script still
looked explicitly for the older one.

Make it execute the first binary '^shfmt.*' in PATH whose --version
returns at least v3.1.0.

Change-Id: If621abfa4d995a9dc985e6bab8c33aa36c327fae
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2428
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-05-18 10:14:52 +00:00
Michal Berger
d596ba87b2 check_format: Introduce shfmt tooling for .sh style enforcement
Add new dev tool for enforcing proper formatting of the Bash code
across the entire repo. This is done in order of defining a common
set of good practices to follow when writing .sh|Bash code.

As powerful as shfmt may be, it allows only for some specific rules
to be enforced, hence it still needs to work side by side with
shellcheck syntax-wise. If it comes to style, following rules are
being enforced:

  * indent_style = tab - Lines must be indented with tabs. The exception
			 from this rule is the use of heredocs with
			 <<BASH redirect operator. Spaces can be used to
			 format the line only if it's already preceded
			 with a tab.

  * binary_next_line = true - Lines can start with logical operators. E.g:

			      if [[ -v foo ]] \
			      	&& [[ -v bar ]]; then
				 ...
			      fi
  * switch_case_indent = true - case|esac patterns are indented with tabs.

  * space_redirects = true - redirect operators are followed with a space.
			     E.g: > foo over >foo.

In addition, shfmt will enforce its own Bash-style for different parts
of the code as well. Examples and more details can be found here:

  https://github.com/mvdan/sh

Change-Id: I6e5c8d79e6dba9c6471010f3d0f563dd34e62fd6
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1418
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-05-07 20:52:21 +00:00
Michal Berger
844c8ec383 check_format: Reformat the Bash code in compliance with shfmt
Change-Id: I93e7b9d355870b0528a0ac3382fba1a10a558d45
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1718
Community-CI: Mellanox Build Bot
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-05-07 20:52:21 +00:00
Pawel Kaminski
50e5d88317 test: shellcheck - ignore SC2010
SC2010: Don't use ls | grep. Use a glob or a for loop
        with a condition to allow non-alphanumeric filenames.

Replacing e.g. "ls /dev/nbd* | grep -v p" would be complex
and problematic as flag -I for ls is not working when
looking for pattern.

Change-Id: I9e88359d247fe5dcf952a3388b0e7f35164768c1
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/481602
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
2020-01-17 14:07:39 +00:00
Pawel Kaminski
13c6c8db6e test: shellcheck - apply rule SC2002
SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.

Minor fix in test_converter: don't use python3 as
    config_converter.py is executable.

Change-Id: I250e893b48fa95e94778dcc31deb91e6ac0b39c0
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/481600
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
2020-01-17 14:07:39 +00:00
Maciej Wawryk
6c2747491d Shellcheck - ignore SC2034 warnings
Add to pernamently excluded in shellcheck:
    SC2034: foo appears unused. Verify it or export it.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: Ib63edb8cdf8ec718981d28d5acec75772b825a48
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478102
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-01-15 14:30:06 +00:00
Maciej Wawryk
19e48a66a4 test: Shellcheck - correct rule: Iterating over ls
Correct shellcheck rule SC2045: Iterating over ls output is fragile. Use globs.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: I436878774d6f86c23b1c5cf5220da297053f03e2
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477397
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-01-15 14:30:06 +00:00
Pawel Kaminski
91dc22bae6 test: shellcheck - move rule SC1083 to permanent exclude list
SC1083: This {/} is literal. Check expression (missing ;/\n?) or quote it.
This rule points to places that are part of command
and cannot be fixed:
1. git archive HEAD^{tree}
2. vpp (e.g. dpdk { no-pci })

Change-Id: I30117913f964415cdaed94d29b1209d119e4d5a4
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/479986
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-01-14 07:48:03 +00:00
Pawel Kaminski
7200ad8199 test: shellcheck - move rule SC2046 to permanent exclude list
SC2046: Quote this to prevent word splitting.

Change-Id: Iaafcf823c72a7dcf1b6eab893e14ea85e2c67ccf
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477321
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-01-14 07:48:03 +00:00
Pawel Kaminski
9c47dd8e09 test: shellcheck - move rule SC2086 to permanent exclude list
SC2086: Double quote to prevent globbing and word splitting.

Change-Id: Ia427dbb3b5d5ad20bcc09a3a455b80d0f69fb583
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477266
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-01-14 07:48:03 +00:00
Pawel Kaminski
6df3f23f22 test: Shellcheck - apply rule SC2097 and SC2098
SC2097: This assignment is only seen by the forked process.
SC2098: This expansion will not see the mentioned assignment.

Apply these two rules together as they point to the same code.

Change-Id: I61020e8fd4b6db2b06ae8134d1004290a9bef9e7
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476777
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-01-13 12:45:04 +00:00
Seth Howell
fd73cb78d8 check_format: add SC2015 to SHCK_EXCLUDE list.
This shellcheck case warns users when they use the pattern A && B || C
so that they don't accidentally try to use it as an if-then-else
statement. However, there is a valid way of using this pattern to
denote, do A, if it succeeds, do B, if either A or B fails, do C.

Change-Id: I283b433c15d07873befd182e8327f2e0602490aa
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476960
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
2020-01-08 15:46:18 +00:00
Maciej Wawryk
1f08daeb81 test: Shellcheck - move rule SC2120 to permanent exception list.
SC2120: foo references arguments, but none are ever passed.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: Ic8d515ca5d0b81b77e22e1e726e403dc6678af5f
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476469
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-12-04 15:22:07 +00:00
Maciej Wawryk
4aa03903c7 test: Shellcheck - move rule SC2119 to permanent exception list.
SC2119: Use foo "$@" if function's $1 should mean script's $1.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: I8366debbf83dfc8f3c1033e1e9fe3df17e45ab49
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476468
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-12-04 15:22:07 +00:00
Maciej Wawryk
d55a5efffb test: Shellcheck - include check SC2090
Remove from shellcheck excluded SC2090: Quotes/backslashes
in this variable will not be respected.
After fix SC2089 this warning is not actually present in
any of spdk/spdk scripts.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: Ibe0015b569202eb7d3f3197f5c5630a67e701332
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476467
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-12-04 15:22:07 +00:00
Maciej Wawryk
855dba2d97 test: Shellcheck - correct rule: Quotes/backslashes...
Correct shellcheck rule SC2089: Quotes/backslashes will be treated literally. Use an array.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: I40d4eef334cd030294669f8e8494f9e7a563d495
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476466
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-12-04 15:22:07 +00:00
Maciej Wawryk
0951fc4fea test: Shellcheck - move rule SC2016 to permanent exception list.
SC2016: Expressions don't expand in single quotes, use double quotes for that.
We need to exclude this shellcheck because in some cases, for example in
test/vhost/common.sh we echo line to new script file.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: I98d322d917cbda034787cb29a267b86a8ad7e7ec
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/475713
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2019-11-27 07:08:57 +00:00
Maciej Wawryk
a69df7ea94 test: Shellcheck - correct rule: Use find...
Correct shellcheck rule SC2012: Use find instead of ls to better handle non-alphanumeric filenames

Change-Id: Ibfc54ac06ae4cecadd22954159d259295f99912f
Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/475712
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-11-27 07:08:57 +00:00
Maciej Wawryk
fdc82d3bc8 test: Shellcheck - correct rule: Double quote array
Correct shellcheck rule SC2068: Double quote array expansions to avoid re-splitting elements.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: Iefc4f0104249f4d437a66c3d9c7a195f4f6f6da3
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/475690
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-11-27 07:08:57 +00:00
Maciej Wawryk
25f601cfb8 test: Shellcheck - correct rule: Expanding an array
Correct shellcheck rule SC2128: Expanding an array without an index only gives the first element.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: I0e7c335af678114dc78dfb12a02369a69158e435
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/474989
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Seth Howell <seth.howell@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
2019-11-27 07:08:57 +00:00
Maciej Wawryk
029251878d test: Shellcheck - correct rule: Consider using { cmd1; cmd2; }
Correct shellcheck rule SC2129: Consider using { cmd1; cmd2; } >> file instead of individual redirects.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: Ic692e9f78f2d3d8a3b27d702884cbe97c880727c
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/474959
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
2019-11-22 13:51:15 +00:00
Maciej Wawryk
f924c94b4c test: Shellcheck - correct rule: Use grep -q...
Correct shellcheck rule SC2143: Use grep -q instead
of comparing output with [ -n .. ].

Change-Id: Ibfce9633eda332c64b27914b2fde51c9a26ff7f3
Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/474957
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-11-20 10:03:15 +00:00
Maciej Wawryk
623203b373 test: Shellcheck - include check SC2142
Remove from shellcheck excluded SC2142: Aliases can't use
positional parameters. Use a function.
This warning is not actually present in any of spdk/spdk scripts.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: I0af375c062724dc8fcee5a6cd4b8ac99bda260ac
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/473292
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-11-13 15:03:11 +00:00
Maciej Wawryk
17b26b7690 test: Shellcheck - correct rule: Word is on the form...
Correct shellcheck rule SC2140: Word is on the form "A"B"C"
(B indicated). Did you mean "ABC" or "A\"B\"C"?

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: I1655b2e76be7a5e3d615c5b34c5af9e4012ac49f
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/473291
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-11-13 15:03:11 +00:00
Pawel Kaminski
4d0c5091a9 test: Shellcheck - add rule SC2154 to exclude list
Corrected code in some files.
Most of cases cannot be corrected as we use global variables
defined in other files.

SC2154: var is referenced but not assigned.

Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Change-Id: Id333587f81b0bc2456b0c97bac5343a8e5a22774
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472342
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-11-12 18:14:59 +00:00
Pawel Kaminski
074df1d896 test: Shellcheck - apply rule SC2155
Declare and assign separately to avoid masking return values.

Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Change-Id: Ib90598e4268911a3056e8a0baa7d541edaa29b91
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472287
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-11-12 18:14:59 +00:00
Pawel Kaminski
c9c576912d test: Shellcheck - move rule SC2162 to exception list
read without -r will mangle backslashes

Change-Id: I9eb59dce40c0bfb59d865319992b419d512dc41b
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471885
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-11-12 18:14:59 +00:00
Maciej Wawryk
d352c44ad0 test: Shellcheck - correct rule: Consider using grep -c
Correct shellcheck rule SC2126: Consider using
grep -c instead of grep|wc.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: Iceeef8b4fae984a95543d8d4b9fcbf90e9c073aa
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/473289
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-11-07 23:04:10 +00:00
Maciej Wawryk
e764b4ca5d test: Shellcheck - correct rule: Assigning an array to a string
Correct shellcheck rule SC2124: Assigning an array to a string!
Assign as array, or use * instead of @ to concatenate.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: Id74c55b7e1c41b6469e84ac388cf8a5bd8e562a6
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/473276
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-11-07 23:04:10 +00:00
Maciej Wawryk
98c63be88f test: Shellcheck - include check SC2121
Remove from shellcheck excluded SC2121: To assign a variable,
use just 'var=value', no 'set ..'.
This warning is not actually present in any of spdk/spdk scripts.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: I7dae1d73f0e276ef9e5a0cfa78a56227264c0a4d
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/473272
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2019-11-07 23:04:10 +00:00
Maciej Wawryk
9a4a87b573 test: Shellcheck - correct rule: $/${} is unnecessary on arithmetic variables.
Correct shellcheck rule SC2004: $/${} is unnecessary on arithmetic variables.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: Ibf2879360bc50cc058b0f4434a5777c53c0eeffb
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/473265
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-11-07 23:04:10 +00:00
Pawel Kaminski
e3d18b5052 test: Shellcheck - move rule SC2148 to permanent exception list
We don't use shebang for bash's scripts that are not executable.
SC2148: Add shebang to the top of your script.

Change-Id: I4bd6868a55ec88ae1edaf0883c8600b65fcdcce2
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472609
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2019-11-06 14:48:14 +00:00