Skip to content

Commit 908edc6

Browse files
authored
Merge pull request #535 from DannyBen/fix/shellcheck
Fix shellcheck violations
2 parents 868b2d7 + 711fd98 commit 908edc6

File tree

16 files changed

+429
-107
lines changed

16 files changed

+429
-107
lines changed

.github/workflows/static-analysis.yml

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Static Analysis
2+
on:
3+
pull_request:
4+
push: { branches: master }
5+
6+
jobs:
7+
static_analysis:
8+
name: Run shellcheck and shfmt
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
# Rush needed for easy installation of latest shfmt
17+
- name: Install rush
18+
run: curl -Ls http://get.dannyb.co/rush/setup | bash
19+
20+
- name: Connect rush repo
21+
run: rush clone dannyben --shallow --default
22+
23+
- name: Install shfmt
24+
run: rush get shfmt
25+
26+
# libyaml needed for Ruby's YAML library
27+
- name: Install OS dependencies
28+
run: sudo apt-get -y install libyaml-dev
29+
30+
- name: Setup Ruby
31+
uses: ruby/setup-ruby@v1
32+
with:
33+
ruby-version: '3.1'
34+
bundler-cache: true
35+
36+
- name: Generate all examples
37+
run: bundle exec run examples regen
38+
39+
- name: Generate all fixtures
40+
run: bundle exec run fixtures regen
41+
42+
- name: Run shellcheck tests (examples)
43+
run: bundle exec run shellcheck examples
44+
45+
- name: Run shellcheck tests (fixtures)
46+
run: bundle exec run shellcheck fixtures
47+
48+
- name: Run shfmt tests (examples)
49+
run: bundle exec run shfmt examples
50+
51+
- name: Run shfmt tests (fixtures)
52+
run: bundle exec run shfmt fixtures
53+
54+
json_schema:
55+
name: Validate JSON schemas
56+
57+
runs-on: ubuntu-latest
58+
59+
steps:
60+
- name: Checkout code
61+
uses: actions/checkout@v4
62+
63+
# Rush needed for easy installation of check-jsonschema
64+
- name: Install rush
65+
run: curl -Ls http://get.dannyb.co/rush/setup | bash
66+
67+
- name: Connect rush repo
68+
run: rush clone dannyben --shallow --default
69+
70+
- name: Install check-jsonschema
71+
run: rush get check-jsonschema
72+
73+
# libyaml needed for Ruby's YAML library
74+
- name: Install OS dependencies
75+
run: sudo apt-get -y install libyaml-dev
76+
77+
- name: Setup Ruby
78+
uses: ruby/setup-ruby@v1
79+
with:
80+
ruby-version: '3.1'
81+
bundler-cache: true
82+
83+
- name: Generate all subjects
84+
run: bundle exec run examples regen
85+
86+
- name: Run schema tests
87+
run: bundle exec run schema all
88+
89+
codespell:
90+
name: Spell check
91+
92+
runs-on: ubuntu-latest
93+
94+
steps:
95+
- name: Checkout code
96+
uses: actions/checkout@v4
97+
98+
- name: Install OS dependencies
99+
run: sudo apt-get -y install codespell
100+
101+
- name: Run codespell
102+
run: codespell

.github/workflows/test.yml

-88
Original file line numberDiff line numberDiff line change
@@ -46,94 +46,6 @@ jobs:
4646
- name: Run tests
4747
run: bundle exec rspec
4848

49-
static_analysis:
50-
name: Example files static analysis
51-
52-
runs-on: ubuntu-latest
53-
54-
steps:
55-
- name: Checkout code
56-
uses: actions/checkout@v4
57-
58-
# Rush needed for easy installation of latest shfmt
59-
- name: Install rush
60-
run: curl -Ls http://get.dannyb.co/rush/setup | bash
61-
62-
- name: Connect rush repo
63-
run: rush clone dannyben --shallow --default
64-
65-
- name: Install shfmt
66-
run: rush get shfmt
67-
68-
# libyaml needed for Ruby's YAML library
69-
- name: Install OS dependencies
70-
run: sudo apt-get -y install libyaml-dev
71-
72-
- name: Setup Ruby
73-
uses: ruby/setup-ruby@v1
74-
with:
75-
ruby-version: '3.1'
76-
bundler-cache: true
77-
78-
- name: Generate all subjects
79-
run: bundle exec run examples regen
80-
81-
- name: Run shellcheck tests
82-
run: bundle exec run shellcheck
83-
84-
- name: Run shfmt tests
85-
run: bundle exec run shfmt
86-
87-
json_schema:
88-
name: JSON schemas validation
89-
90-
runs-on: ubuntu-latest
91-
92-
steps:
93-
- name: Checkout code
94-
uses: actions/checkout@v4
95-
96-
# Rush needed for easy installation of check-jsonschema
97-
- name: Install rush
98-
run: curl -Ls http://get.dannyb.co/rush/setup | bash
99-
100-
- name: Connect rush repo
101-
run: rush clone dannyben --shallow --default
102-
103-
- name: Install check-jsonschema
104-
run: rush get check-jsonschema
105-
106-
# libyaml needed for Ruby's YAML library
107-
- name: Install OS dependencies
108-
run: sudo apt-get -y install libyaml-dev
109-
110-
- name: Setup Ruby
111-
uses: ruby/setup-ruby@v1
112-
with:
113-
ruby-version: '3.1'
114-
bundler-cache: true
115-
116-
- name: Generate all subjects
117-
run: bundle exec run examples regen
118-
119-
- name: Run schema tests
120-
run: bundle exec run schema all
121-
122-
codespell:
123-
name: Spell check
124-
125-
runs-on: ubuntu-latest
126-
127-
steps:
128-
- name: Checkout code
129-
uses: actions/checkout@v4
130-
131-
- name: Install OS dependencies
132-
run: sudo apt-get -y install codespell
133-
134-
- name: Run codespell
135-
run: codespell
136-
13749
docker:
13850
name: Docker smoke test
13951

lib/bashly/views/argument/validations.gtx

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ if validate
33

44
if repeatable
55
> if [[ -v args['{{ name }}'] ]]; then
6+
> values=''
67
> eval "values=(${args['{{ name }}']})"
78
> for value in "${values[@]}"; do
89
> if [[ -n $(validate_{{ validate }} "$value") ]]; then

lib/bashly/views/command/normalize_input_function.gtx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
= view_marker
22

33
> normalize_input() {
4-
> local arg flags passthru
4+
if Settings.compact_short_flags
5+
> local arg passthru flags
6+
else
7+
> local arg passthru
8+
end
59
> passthru=false
610
>
711
> while [[ $# -gt 0 ]]; do

lib/bashly/views/command/whitelist_filter.gtx

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ if whitelisted_args.any? or whitelisted_flags.any?
33

44
whitelisted_args.each do |arg|
55
if arg.repeatable
6+
> input_array=''
67
> eval "input_array=(${args[{{ arg.name }}]})"
78
> for i in "${input_array[@]}"; do
89
> if [[ ! $i =~ ^({{ arg.allowed.join '|' }})$ ]]; then
@@ -22,6 +23,7 @@ if whitelisted_args.any? or whitelisted_flags.any?
2223

2324
whitelisted_flags.each do |flag|
2425
if flag.repeatable
26+
> input_array=''
2527
> eval "input_array=(${args[{{ flag.name }}]})"
2628
> for i in "${input_array[@]}"; do
2729
> if [[ ! $i =~ ^({{ flag.allowed.join '|' }})$ ]]; then

lib/bashly/views/flag/validations.gtx

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ if validate
33

44
if repeatable
55
> if [[ -v args['{{ long }}'] ]]; then
6+
> values=''
67
> eval "values=(${args['{{ long }}']})"
78
> for value in "${values[@]}"; do
89
> if [[ -n $(validate_{{ validate }} "$value") ]]; then

runfile

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'debug'
22
require 'bashly/version'
33
require_relative 'support/runfile/example'
4+
require_relative 'support/runfile/workspace_fixture'
45

56
title 'Bashly Developer Toolbelt'
67
summary 'Runfile tasks for building the Bashly gem'

spec/fixtures/workspaces/heredoc/src/root_command.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SECOND_BLOCK
1818
echo also unindented
1919

2020
echo "writing to file:"
21-
cat << EOF > output.txt
21+
cat <<EOF >output.txt
2222
0 indentation
2323
1 indentation
2424
1 indentation

spec/fixtures/workspaces/lib-custom-source/.gitignore

-2
This file was deleted.

0 commit comments

Comments
 (0)