danger-shellcheck 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 101ff4668cb3af350a01002ccfef299839365e5a
4
+ data.tar.gz: ba5dcaa7805a200520137008a709e79019c88ed7
5
+ SHA512:
6
+ metadata.gz: 687e898dc3c65110c85a9c5e9f4280cb755416f54a0ab79028224993701929363ba435e40c94ca20a000d50cfa8b45d8c8b35a094b81b6a9ab56d0f6686532e0
7
+ data.tar.gz: 0982463bc8e0e37d7eefbe147b59c00a79eea03a1b07a3a4cb2b0aea9df6dac61327ee66e97328571c22a9c84057a2513bfcf79cffb40c2ae858b0b4fb36b472
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/.rubocop.yml ADDED
@@ -0,0 +1,88 @@
1
+ # kind_of? is a good way to check a type
2
+ Style/ClassCheck:
3
+ EnforcedStyle: kind_of?
4
+
5
+ # It's better to be more explicit about the type
6
+ Style/BracesAroundHashParameters:
7
+ Enabled: false
8
+
9
+ # specs sometimes have useless assignments, which is fine
10
+ Lint/UselessAssignment:
11
+ Exclude:
12
+ - '**/spec/**/*'
13
+
14
+ # HoundCI doesn't like this rule
15
+ Style/DotPosition:
16
+ Enabled: false
17
+
18
+ # Cop supports --auto-correct.
19
+ Lint/UnusedBlockArgument:
20
+ Enabled: false
21
+
22
+ # We want to allow class Fastlane::Class
23
+ Style/ClassAndModuleChildren:
24
+ Enabled: false
25
+
26
+ Metrics/AbcSize:
27
+ Max: 60
28
+
29
+ # The %w might be confusing for new users
30
+ Style/WordArray:
31
+ MinSize: 19
32
+
33
+ # raise and fail are both okay
34
+ Style/SignalException:
35
+ Enabled: false
36
+
37
+ # Better too much 'return' than one missing
38
+ Style/RedundantReturn:
39
+ Enabled: false
40
+
41
+ # Having if in the same line might not always be good
42
+ Style/IfUnlessModifier:
43
+ Enabled: false
44
+
45
+ # Configuration parameters: CountComments.
46
+ Metrics/ClassLength:
47
+ Max: 320
48
+
49
+ Metrics/CyclomaticComplexity:
50
+ Max: 17
51
+
52
+ # Configuration parameters: AllowURI, URISchemes.
53
+ Metrics/LineLength:
54
+ Enabled: false
55
+
56
+ # Configuration parameters: CountKeywordArgs.
57
+ Metrics/ParameterLists:
58
+ Max: 10
59
+
60
+ Metrics/PerceivedComplexity:
61
+ Max: 18
62
+
63
+ # Sometimes it's easier to read without guards
64
+ Style/GuardClause:
65
+ Enabled: false
66
+
67
+ # something = if something_else
68
+ # that's confusing
69
+ Style/ConditionalAssignment:
70
+ Enabled: false
71
+
72
+ # Better to have too much self than missing a self
73
+ Style/RedundantSelf:
74
+ Enabled: false
75
+
76
+ Metrics/MethodLength:
77
+ Max: 60
78
+
79
+ Metrics/BlockLength:
80
+ Max: 50
81
+
82
+ # We're not there yet
83
+ Style/Documentation:
84
+ Enabled: false
85
+
86
+ # Adds complexity
87
+ Style/IfInsideElse:
88
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,20 @@
1
+ language: ruby
2
+ cache:
3
+ directories:
4
+ - bundle
5
+
6
+ before_install:
7
+ - gem update --system
8
+ - gem install bundler
9
+
10
+ sudo: false
11
+
12
+ rvm:
13
+ - 2.0.0
14
+ - 2.1.10
15
+ - 2.2.6
16
+ - 2.3.3
17
+ - 2.4.0
18
+
19
+ script:
20
+ - bundle exec rake spec
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in danger-shellcheck.gemspec
4
+ gemspec
5
+ gem 'coveralls', require: false
data/Gemfile.lock ADDED
@@ -0,0 +1,150 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ danger-shellcheck (1.0.0)
5
+ danger-plugin-api (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.5.1)
11
+ public_suffix (~> 2.0, >= 2.0.2)
12
+ ast (2.3.0)
13
+ claide (1.0.1)
14
+ claide-plugins (0.9.2)
15
+ cork
16
+ nap
17
+ open4 (~> 1.3)
18
+ coderay (1.1.1)
19
+ colored (1.2)
20
+ colored2 (3.1.2)
21
+ cork (0.2.0)
22
+ colored (~> 1.2)
23
+ coveralls (0.8.19)
24
+ json (>= 1.8, < 3)
25
+ simplecov (~> 0.12.0)
26
+ term-ansicolor (~> 1.3)
27
+ thor (~> 0.19.1)
28
+ tins (~> 1.6)
29
+ danger (4.3.2)
30
+ claide (~> 1.0)
31
+ claide-plugins (>= 0.9.2)
32
+ colored2 (~> 3.1)
33
+ cork (~> 0.1)
34
+ faraday (~> 0.9)
35
+ faraday-http-cache (~> 1.0)
36
+ git (~> 1)
37
+ kramdown (~> 1.5)
38
+ octokit (~> 4.2)
39
+ terminal-table (~> 1)
40
+ danger-plugin-api (1.0.0)
41
+ danger (> 2.0)
42
+ diff-lcs (1.3)
43
+ docile (1.1.5)
44
+ faraday (0.12.0.1)
45
+ multipart-post (>= 1.2, < 3)
46
+ faraday-http-cache (1.3.1)
47
+ faraday (~> 0.8)
48
+ ffi (1.9.18)
49
+ formatador (0.2.5)
50
+ git (1.3.0)
51
+ guard (2.14.1)
52
+ formatador (>= 0.2.4)
53
+ listen (>= 2.7, < 4.0)
54
+ lumberjack (~> 1.0)
55
+ nenv (~> 0.1)
56
+ notiffany (~> 0.0)
57
+ pry (>= 0.9.12)
58
+ shellany (~> 0.0)
59
+ thor (>= 0.18.1)
60
+ guard-compat (1.2.1)
61
+ guard-rspec (4.7.3)
62
+ guard (~> 2.1)
63
+ guard-compat (~> 1.1)
64
+ rspec (>= 2.99.0, < 4.0)
65
+ json (2.0.3)
66
+ kramdown (1.13.2)
67
+ listen (3.0.7)
68
+ rb-fsevent (>= 0.9.3)
69
+ rb-inotify (>= 0.9.7)
70
+ lumberjack (1.0.11)
71
+ method_source (0.8.2)
72
+ multipart-post (2.0.0)
73
+ nap (1.1.0)
74
+ nenv (0.3.0)
75
+ notiffany (0.1.1)
76
+ nenv (~> 0.1)
77
+ shellany (~> 0.0)
78
+ octokit (4.6.2)
79
+ sawyer (~> 0.8.0, >= 0.5.3)
80
+ open4 (1.3.4)
81
+ parser (2.4.0.0)
82
+ ast (~> 2.2)
83
+ powerpack (0.1.1)
84
+ pry (0.10.4)
85
+ coderay (~> 1.1.0)
86
+ method_source (~> 0.8.1)
87
+ slop (~> 3.4)
88
+ public_suffix (2.0.5)
89
+ rainbow (2.2.1)
90
+ rake (10.5.0)
91
+ rb-fsevent (0.9.8)
92
+ rb-inotify (0.9.8)
93
+ ffi (>= 0.5.0)
94
+ rspec (3.5.0)
95
+ rspec-core (~> 3.5.0)
96
+ rspec-expectations (~> 3.5.0)
97
+ rspec-mocks (~> 3.5.0)
98
+ rspec-core (3.5.4)
99
+ rspec-support (~> 3.5.0)
100
+ rspec-expectations (3.5.0)
101
+ diff-lcs (>= 1.2.0, < 2.0)
102
+ rspec-support (~> 3.5.0)
103
+ rspec-mocks (3.5.0)
104
+ diff-lcs (>= 1.2.0, < 2.0)
105
+ rspec-support (~> 3.5.0)
106
+ rspec-support (3.5.0)
107
+ rubocop (0.48.1)
108
+ parser (>= 2.3.3.1, < 3.0)
109
+ powerpack (~> 0.1)
110
+ rainbow (>= 1.99.1, < 3.0)
111
+ ruby-progressbar (~> 1.7)
112
+ unicode-display_width (~> 1.0, >= 1.0.1)
113
+ ruby-progressbar (1.8.1)
114
+ sawyer (0.8.1)
115
+ addressable (>= 2.3.5, < 2.6)
116
+ faraday (~> 0.8, < 1.0)
117
+ shellany (0.0.1)
118
+ simplecov (0.12.0)
119
+ docile (~> 1.1.0)
120
+ json (>= 1.8, < 3)
121
+ simplecov-html (~> 0.10.0)
122
+ simplecov-html (0.10.0)
123
+ slop (3.6.0)
124
+ term-ansicolor (1.5.0)
125
+ tins (~> 1.0)
126
+ terminal-table (1.7.3)
127
+ unicode-display_width (~> 1.1.1)
128
+ thor (0.19.4)
129
+ tins (1.13.2)
130
+ unicode-display_width (1.1.3)
131
+ yard (0.9.8)
132
+
133
+ PLATFORMS
134
+ ruby
135
+
136
+ DEPENDENCIES
137
+ bundler (~> 1.3)
138
+ coveralls
139
+ danger-shellcheck!
140
+ guard (~> 2.14)
141
+ guard-rspec (~> 4.7)
142
+ listen (= 3.0.7)
143
+ pry
144
+ rake (~> 10.0)
145
+ rspec (~> 3.4)
146
+ rubocop (~> 0.41)
147
+ yard (~> 0.8)
148
+
149
+ BUNDLED WITH
150
+ 1.13.5
data/Guardfile ADDED
@@ -0,0 +1,19 @@
1
+ # A guardfile for making Danger Plugins
2
+ # For more info see https://github.com/guard/guard#readme
3
+
4
+ # To run, use `bundle exec guard`.
5
+
6
+ guard :rspec, cmd: 'bundle exec rspec' do
7
+ require 'guard/rspec/dsl'
8
+ dsl = Guard::RSpec::Dsl.new(self)
9
+
10
+ # RSpec files
11
+ rspec = dsl.rspec
12
+ watch(rspec.spec_helper) { rspec.spec_dir }
13
+ watch(rspec.spec_support) { rspec.spec_dir }
14
+ watch(rspec.spec_files)
15
+
16
+ # Ruby files
17
+ ruby = dsl.ruby
18
+ dsl.watch_spec_files_for(ruby.lib_files)
19
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Intrepid Pursuits LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # danger-shellcheck
2
+
3
+ [![Build Status](https://travis-ci.org/IntrepidPursuits/danger-shellcheck.svg?branch=master)](https://travis-ci.org/IntrepidPursuits/danger-shellcheck)
4
+ [![Coverage Status](https://coveralls.io/repos/github/IntrepidPursuits/danger-shellcheck/badge.svg?branch=master)](https://coveralls.io/github/IntrepidPursuits/danger-shellcheck?branch=master)
5
+ ![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)
6
+
7
+ A [Danger](http://danger.systems/) plugin that shows the static analysis output generated by [ShellCheck](https://github.com/koalaman/shellcheck).
8
+
9
+ To use this plugin, you need to generate a JSON file using [ShellCheck](https://github.com/koalaman/shellcheck) for this plugin to read.
10
+
11
+ ## Installation
12
+
13
+ $ gem install danger-shellcheck
14
+
15
+ ## Usage
16
+
17
+ Somewhere in your build process, call ShellCheck using the JSON output flag.
18
+
19
+ shellcheck -f json myscript myotherscript > shellcheck.json
20
+
21
+ An easy way to have shellcheck look at all of your .sh files is:
22
+
23
+ shellcheck -f json **/*.sh > shellcheck.json
24
+
25
+ At a minimum, add this line to your `Dangerfile`:
26
+
27
+ shellcheck.report 'shellcheck.json'
28
+
29
+ You may also use optional specifiers to ignore files, or set the project root.
30
+
31
+ # Set a different project root
32
+ shellcheck.project_root = 'MyProject/NewRoot/'
33
+
34
+
35
+ ## License
36
+ danger-shellcheck is released under the MIT license. See [LICENSE](https://github.com/IntrepidPursuits/danger-shellcheck/blob/master/LICENSE) for details.
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork this repo
41
+ 2. Run `bundle install` to setup dependencies.
42
+ 3. Run `bundle exec rake spec` to run the tests.
43
+ 4. Use `bundle exec guard` to automatically have tests run as you make changes.
44
+ 5. Make your changes.
45
+ 6. Create a Pull Request for us to review
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:specs)
6
+
7
+ task default: :specs
8
+
9
+ task :spec do
10
+ Rake::Task['specs'].invoke
11
+ Rake::Task['rubocop'].invoke
12
+ Rake::Task['spec_docs'].invoke
13
+ end
14
+
15
+ desc 'Run RuboCop on the lib/specs directory'
16
+ RuboCop::RakeTask.new(:rubocop) do |task|
17
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
18
+ end
19
+
20
+ desc 'Ensure that the plugin passes `danger plugins lint`'
21
+ task :spec_docs do
22
+ sh 'bundle exec danger plugins lint'
23
+ end
@@ -0,0 +1,54 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'shellcheck/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'danger-shellcheck'
8
+ spec.version = Shellcheck::VERSION
9
+ spec.authors = ['David Brooks']
10
+ spec.email = ['dbrooks@intrepid.io']
11
+ spec.description = 'Show formatted static analysis report in your PRs for shell scripts'
12
+ spec.summary = 'A [Danger](https://danger.systems) plugin that shows ' \
13
+ 'warnings and errors generated from the ShellCheck ' \
14
+ 'static analysis tool for shell scripts.'
15
+ spec.homepage = 'https://github.com/IntrepidPursuits/danger-shellcheck'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files`.split($/)
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
24
+
25
+ # General ruby development
26
+ spec.add_development_dependency 'bundler', '~> 1.3'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+
29
+ # Testing support
30
+ spec.add_development_dependency 'rspec', '~> 3.4'
31
+
32
+ # Linting code and docs
33
+ spec.add_development_dependency "rubocop", "~> 0.41"
34
+ spec.add_development_dependency "yard", "~> 0.8"
35
+
36
+ # Makes testing easy via `bundle exec guard`
37
+ spec.add_development_dependency 'guard', '~> 2.14'
38
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
39
+
40
+ # If you want to work on older builds of ruby
41
+ spec.add_development_dependency 'listen', '3.0.7'
42
+
43
+ # Use coveralls
44
+ spec.add_development_dependency 'coveralls', '0.8.19'
45
+
46
+ # This gives you the chance to run a REPL inside your tests
47
+ # via:
48
+ #
49
+ # require 'pry'
50
+ # binding.pry
51
+ #
52
+ # This will stop test execution and let you inspect the results
53
+ spec.add_development_dependency 'pry'
54
+ end
@@ -0,0 +1 @@
1
+ require 'shellcheck/plugin'
@@ -0,0 +1 @@
1
+ require 'shellcheck/gem_version'
@@ -0,0 +1,3 @@
1
+ module Shellcheck
2
+ VERSION = '1.0.0'.freeze
3
+ end
@@ -0,0 +1,99 @@
1
+ require 'set'
2
+
3
+ module Danger
4
+ # Shows the warnings and suggestions for shell scripts generated from ShellCheck.
5
+ # You need [ShellCheck](https://github.com/koalaman/shellcheck) installed and generating a json file
6
+ # to use this plugin.
7
+ #
8
+ # @example Showing summary
9
+ #
10
+ # shellcheck -f json myscript > shellcheck.json
11
+ # shellcheck.report 'shellcheck.json'
12
+ #
13
+ # @see IntrepidPursuits/danger-shellcheck
14
+ # @tags bash, sh, lint, syntax, format, analysis
15
+ #
16
+ class DangerShellcheck < Plugin
17
+ # The project root, which will be used to make the paths relative.
18
+ # Defaults to 'pwd'.
19
+ # @return [String] project_root value
20
+ attr_accessor :project_root
21
+
22
+ # Defines if the test summary will be sticky or not
23
+ # Defaults to 'false'
24
+ # @return [Boolean] sticky
25
+ attr_accessor :sticky_summary
26
+
27
+ def project_root
28
+ root = @project_root || Dir.pwd
29
+ root += '/' unless root.end_with? '/'
30
+ root
31
+ end
32
+
33
+ def sticky_summary
34
+ @sticky_summary || false
35
+ end
36
+
37
+ # Reads a file with JSON ShellCheck summary and reports it.
38
+ #
39
+ # @param [String] file_path Path for ShellCheck summary in JSON format.
40
+ # @return [void]
41
+ def report(file_path)
42
+ raise 'ShellCheck summary file not found' unless File.file?(file_path)
43
+ shellcheck_summary = JSON.parse(File.read(file_path), symbolize_names: true)
44
+ run_summary(shellcheck_summary)
45
+ end
46
+
47
+ private
48
+
49
+ def run_summary(shellcheck_summary)
50
+ @files = Set.new
51
+ @error_count = 0
52
+ @warning_count = 0
53
+ @info_count = 0
54
+ @style_count = 0
55
+
56
+ # Parse the file violations
57
+ parse_files(shellcheck_summary)
58
+
59
+ # Output the ShellCheck summary
60
+ message(summary_message, sticky: sticky_summary)
61
+ end
62
+
63
+ def summary_message
64
+ "ShellCheck Summary: Analyzed #{@files.size} files. Found #{@error_count} errors. #{@warning_count} Warnings, #{@info_count} Info and #{@style_count} Style Violations."
65
+ end
66
+
67
+ # A method that takes the ShellCheck summary and parses any violations found
68
+ def parse_files(shellcheck_summary)
69
+ shellcheck_summary.each do |element|
70
+ file = element[:file]
71
+ @files.add(file)
72
+ level = element[:level]
73
+
74
+ message = format_violation(file, element)
75
+
76
+ if level == 'error'
77
+ @error_count += 1
78
+ fail(message, sticky: false)
79
+ else
80
+ if level == 'warning'
81
+ @warning_count += 1
82
+ elsif level == 'info'
83
+ @info_count += 1
84
+ else
85
+ @style_count += 1
86
+ end
87
+ warn(message, sticky: false)
88
+ end
89
+ end
90
+ end
91
+
92
+ # A method that returns a formatted string for a violation
93
+ # @return String
94
+ #
95
+ def format_violation(file, violation)
96
+ "#{file}: #L#{violation[:line]} -> #{violation[:code]} - #{violation[:message]}"
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,118 @@
1
+ [{
2
+ "file": "maintenance/clean_jenkins_logs.sh",
3
+ "line": 8,
4
+ "endLine": 8,
5
+ "column": 44,
6
+ "endColumn": 44,
7
+ "level": "warning",
8
+ "code": 2061,
9
+ "message": "Quote the parameter to -name so the shell won't interpret it."
10
+ }, {
11
+ "file": "maintenance/clean_jenkins_logs.sh",
12
+ "line": 8,
13
+ "endLine": 8,
14
+ "column": 44,
15
+ "endColumn": 44,
16
+ "level": "info",
17
+ "code": 2035,
18
+ "message": "Use ./*glob* or -- *glob* so names with dashes won't become options."
19
+ }, {
20
+ "file": "ios/run_pull_request_tests.sh",
21
+ "line": 7,
22
+ "endLine": 7,
23
+ "column": 6,
24
+ "endColumn": 6,
25
+ "level": "error",
26
+ "code": 2086,
27
+ "message": "Double quote to prevent globbing and word splitting."
28
+ }, {
29
+ "file": "ios/run_pull_request_tests.sh",
30
+ "line": 7,
31
+ "endLine": 7,
32
+ "column": 32,
33
+ "endColumn": 32,
34
+ "level": "info",
35
+ "code": 2086,
36
+ "message": "Double quote to prevent globbing and word splitting."
37
+ }, {
38
+ "file": "ios/run_pull_request_tests.sh",
39
+ "line": 27,
40
+ "endLine": 27,
41
+ "column": 1,
42
+ "endColumn": 1,
43
+ "level": "error",
44
+ "code": 2086,
45
+ "message": "Double quote to prevent globbing and word splitting."
46
+ }, {
47
+ "file": "iOS-Core/unittest.sh",
48
+ "line": 64,
49
+ "endLine": 64,
50
+ "column": 24,
51
+ "endColumn": 24,
52
+ "level": "info",
53
+ "code": 2059,
54
+ "message": "Don't use variables in the printf format string. Use printf \"..%s..\" \"$foo\"."
55
+ }, {
56
+ "file": "iOS-Core/unittest.sh",
57
+ "line": 73,
58
+ "endLine": 73,
59
+ "column": 24,
60
+ "endColumn": 24,
61
+ "level": "info",
62
+ "code": 2059,
63
+ "message": "Don't use variables in the printf format string. Use printf \"..%s..\" \"$foo\"."
64
+ }, {
65
+ "file": "iOS-Core/simulator.sh",
66
+ "line": 49,
67
+ "endLine": 49,
68
+ "column": 24,
69
+ "endColumn": 24,
70
+ "level": "info",
71
+ "code": 2059,
72
+ "message": "Don't use variables in the printf format string. Use printf \"..%s..\" \"$foo\"."
73
+ }, {
74
+ "file": "iOS-Core/rebundle.sh",
75
+ "line": 55,
76
+ "endLine": 55,
77
+ "column": 24,
78
+ "endColumn": 24,
79
+ "level": "info",
80
+ "code": 2059,
81
+ "message": "Don't use variables in the printf format string. Use printf \"..%s..\" \"$foo\"."
82
+ }, {
83
+ "file": "iOS-Core/rebundle.sh",
84
+ "line": 64,
85
+ "endLine": 64,
86
+ "column": 24,
87
+ "endColumn": 24,
88
+ "level": "info",
89
+ "code": 2059,
90
+ "message": "Don't use variables in the printf format string. Use printf \"..%s..\" \"$foo\"."
91
+ }, {
92
+ "file": "iOS-Core/rebundle.sh",
93
+ "line": 73,
94
+ "endLine": 73,
95
+ "column": 24,
96
+ "endColumn": 24,
97
+ "level": "style",
98
+ "code": 2059,
99
+ "message": "Don't use variables in the printf format string. Use printf \"..%s..\" \"$foo\"."
100
+ }, {
101
+ "file": "iOS-Core/rebundle.sh",
102
+ "line": 103,
103
+ "endLine": 103,
104
+ "column": 12,
105
+ "endColumn": 12,
106
+ "level": "error",
107
+ "code": 2059,
108
+ "message": "Don't use variables in the printf format string. Use printf \"..%s..\" \"$foo\"."
109
+ }, {
110
+ "file": "iOS-Core/rebundle.sh",
111
+ "line": 108,
112
+ "endLine": 108,
113
+ "column": 15,
114
+ "endColumn": 15,
115
+ "level": "warning",
116
+ "code": 2153,
117
+ "message": "Possible misspelling: WORKSPACE may not be assigned, but workspace is."
118
+ }]
@@ -0,0 +1,42 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ module Danger
4
+ describe Danger::DangerShellcheck do
5
+ it 'should be a plugin' do
6
+ expect(Danger::DangerShellcheck.new(nil)).to be_a Danger::Plugin
7
+ end
8
+
9
+ describe 'with Dangerfile' do
10
+ before do
11
+ @dangerfile = testing_dangerfile
12
+ @my_plugin = @dangerfile.shellcheck
13
+ end
14
+
15
+ it 'Parses JSON with errors, warnings, info and style violations' do
16
+ file_path = File.expand_path('../shellcheck.json', __FILE__)
17
+ @my_plugin.report(file_path)
18
+ expect(@dangerfile.status_report[:errors].length).to be == 3
19
+ expect(@dangerfile.status_report[:warnings].length).to be == 10
20
+ expect(@dangerfile.status_report[:markdowns]).to eq([])
21
+ end
22
+
23
+ it 'Displays a summary message' do
24
+ file_path = File.expand_path('../shellcheck.json', __FILE__)
25
+ @my_plugin.report(file_path)
26
+ expect(@dangerfile.status_report[:messages]).to eq(['ShellCheck Summary: Analyzed 5 files. Found 3 errors. 2 Warnings, 7 Info and 1 Style Violations.'])
27
+ end
28
+
29
+ it 'Displays a properly formatted error message' do
30
+ file_path = File.expand_path('../shellcheck.json', __FILE__)
31
+ @my_plugin.report(file_path)
32
+ expect(@dangerfile.status_report[:errors][0]).to eq('ios/run_pull_request_tests.sh: #L7 -> 2086 - Double quote to prevent globbing and word splitting.')
33
+ end
34
+
35
+ it 'Displays a properly formatted warning message' do
36
+ file_path = File.expand_path('../shellcheck.json', __FILE__)
37
+ @my_plugin.report(file_path)
38
+ expect(@dangerfile.status_report[:warnings][0]).to eq('maintenance/clean_jenkins_logs.sh: #L8 -> 2061 - Quote the parameter to -name so the shell won\'t interpret it.')
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,62 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $LOAD_PATH.unshift((ROOT + 'lib').to_s)
4
+ $LOAD_PATH.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'pry'
8
+
9
+ require 'rspec'
10
+ require 'danger'
11
+
12
+ require 'coveralls'
13
+ Coveralls.wear!
14
+
15
+ # Use coloured output, it's the best.
16
+ RSpec.configure do |config|
17
+ config.filter_gems_from_backtrace 'bundler'
18
+ config.color = true
19
+ config.tty = true
20
+ end
21
+
22
+ require 'danger_plugin'
23
+
24
+ # These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
25
+ # If you are expanding these files, see if it's already been done ^.
26
+
27
+ # A silent version of the user interface,
28
+ # it comes with an extra function `.string` which will
29
+ # strip all ANSI colours from the string.
30
+
31
+ # rubocop:disable Lint/NestedMethodDefinition
32
+ def testing_ui
33
+ @output = StringIO.new
34
+ def @output.winsize
35
+ [20, 9999]
36
+ end
37
+
38
+ cork = Cork::Board.new(out: @output)
39
+ def cork.string
40
+ out.string.gsub(/\e\[([;\d]+)?m/, '')
41
+ end
42
+ cork
43
+ end
44
+ # rubocop:enable Lint/NestedMethodDefinition
45
+
46
+ # Example environment (ENV) that would come from
47
+ # running a PR on TravisCI
48
+ def testing_env
49
+ {
50
+ 'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
51
+ 'TRAVIS_PULL_REQUEST' => '800',
52
+ 'TRAVIS_REPO_SLUG' => 'artsy/eigen',
53
+ 'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
54
+ 'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
55
+ }
56
+ end
57
+
58
+ # A stubbed out Dangerfile for use in tests
59
+ def testing_dangerfile
60
+ env = Danger::EnvironmentManager.new(testing_env)
61
+ Danger::Dangerfile.new(env, testing_ui)
62
+ end
metadata ADDED
@@ -0,0 +1,220 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-shellcheck
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - David Brooks
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: danger-plugin-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '0.41'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '0.41'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '0.8'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '0.8'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '2.14'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '2.14'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '4.7'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: '4.7'
125
+ - !ruby/object:Gem::Dependency
126
+ name: listen
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 3.0.7
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 3.0.7
139
+ - !ruby/object:Gem::Dependency
140
+ name: coveralls
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 0.8.19
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 0.8.19
153
+ - !ruby/object:Gem::Dependency
154
+ name: pry
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description: Show formatted static analysis report in your PRs for shell scripts
168
+ email:
169
+ - dbrooks@intrepid.io
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - .coveralls.yml
175
+ - .gitignore
176
+ - .rubocop.yml
177
+ - .travis.yml
178
+ - Gemfile
179
+ - Gemfile.lock
180
+ - Guardfile
181
+ - LICENSE
182
+ - README.md
183
+ - Rakefile
184
+ - danger-shellcheck.gemspec
185
+ - lib/danger_plugin.rb
186
+ - lib/danger_shellcheck.rb
187
+ - lib/shellcheck/gem_version.rb
188
+ - lib/shellcheck/plugin.rb
189
+ - spec/shellcheck.json
190
+ - spec/shellcheck_spec.rb
191
+ - spec/spec_helper.rb
192
+ homepage: https://github.com/IntrepidPursuits/danger-shellcheck
193
+ licenses:
194
+ - MIT
195
+ metadata: {}
196
+ post_install_message:
197
+ rdoc_options: []
198
+ require_paths:
199
+ - lib
200
+ required_ruby_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - '>='
203
+ - !ruby/object:Gem::Version
204
+ version: '0'
205
+ required_rubygems_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - '>='
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ requirements: []
211
+ rubyforge_project:
212
+ rubygems_version: 2.0.14.1
213
+ signing_key:
214
+ specification_version: 4
215
+ summary: A [Danger](https://danger.systems) plugin that shows warnings and errors
216
+ generated from the ShellCheck static analysis tool for shell scripts.
217
+ test_files:
218
+ - spec/shellcheck.json
219
+ - spec/shellcheck_spec.rb
220
+ - spec/spec_helper.rb