danger-warnings 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1700e0b2ada290034b7845b68d581e81c73997f235d038f46903ec00526a3074
4
+ data.tar.gz: 482a5cd7478ce44da357b53f9932d06f64eac91adfab014ba205942434319dd2
5
+ SHA512:
6
+ metadata.gz: 682d89cec48fff79bb526b88fec0e0c628db4a88b7f52dcc39a2603913d4e09b1798ffbf33beb9cf31697d56ce8a94ffd73159bdbc159ae313f44698f3f34ccb
7
+ data.tar.gz: cddb903ba7cfd7b8532360adb1c598f49eaa64d4c5a770c0c83a73088c16f89425a166bd200e4e8a153832829f8d487d2400eec64d20b47711874ce05e8ab388
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ .yardoc
5
+ Gemfile.lock
6
+ coverage
7
+ rubocop-result.json
8
+ *.gem
data/.rubocop.yml ADDED
@@ -0,0 +1,45 @@
1
+ # Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.2
5
+
6
+ # kind_of? is a good way to check a type
7
+ Style/ClassCheck:
8
+ EnforcedStyle: kind_of?
9
+
10
+ # Configuration parameters: CountComments.
11
+ Metrics/ClassLength:
12
+ Max: 350
13
+
14
+ # Configuration parameters: AllowURI, URISchemes.
15
+ Metrics/LineLength:
16
+ Max: 200
17
+ Exclude:
18
+ - "**/*_spec.rb"
19
+
20
+ Metrics/ModuleLength:
21
+ Exclude:
22
+ - "**/*_spec.rb"
23
+
24
+ Metrics/MethodLength:
25
+ Max: 60
26
+
27
+ Layout/MultilineMethodCallIndentation:
28
+ EnforcedStyle: indented
29
+
30
+ Metrics/BlockLength:
31
+ Max: 345
32
+ Exclude:
33
+ - "**/*_spec.rb"
34
+
35
+ PercentLiteralDelimiters:
36
+ PreferredDelimiters:
37
+ "%": ()
38
+ "%i": ()
39
+ "%q": ()
40
+ "%Q": ()
41
+ "%r": "{}"
42
+ "%s": ()
43
+ "%w": ()
44
+ "%W": ()
45
+ "%x": ()
data/.travis.yml ADDED
@@ -0,0 +1,27 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.2
5
+ - 2.3
6
+ - 2.4
7
+ - 2.5
8
+ - 2.6
9
+
10
+ addons:
11
+ sonarcloud:
12
+ organization: "kyaak-github"
13
+ token:
14
+ secure: "W3BNwC9uNk85qCO6MN74gYEpZ1J63iQ/1bDS7TE69QZzuvwzcyt4tRB5rH2YXXrDgxX+f+pNEKyordR3C92PKZDcUXTiLJH5eWWBJNKf37yv38dw7hrz48hoCzOXYkIuEO9nU9+SUmQUDTshy3h05cfJOKRQihvaRzucP7OJzb8vXX8UEY2V71Yf6xyxkAzvqogBxyr21yIh90WuSE7MCwFqu05bQIIXao7oILUAWRqh1zHZaIPEWSS8rdldbh9BXSWLHkCgYo6kajZHKo+fG5tol9MLkann5TiqVHoLkTjh76V6zDgWGa5EpMjnSxUKp8KkshVtF8u3QHKkFcFRV51s1t6XRYPKfDRtgOQ3+Yq2+F93L3MNtkgfmrgoKXsZ4Sdf9y2cwSGp+GH0YSjsaTcmC/K2irZuKEOtr44Ye3jfcDzMpZRiGgpvx2+cXXvGWvJoMaOWgyIjJbkjIBKAM4/Tq15uWnv7W5ajaQnxHH/gSaC3OwI3aebPjeJV5/RaBpOGK/MaYS8AohGY8HAlvM+UWRhcI2rZ9sMvMl/jQxjF3BiZwE2KpsNiyoQ8s/wDMJeC27uMFmljyiUXu77OWeWGRV3hWWeaWJLbRbWVJRzoIAsJ/PyZX0LudS5k5lJZePutHHxcf/rAHUyT/eMqbnFtIOOxyH0nR/esvPghz90="
15
+
16
+ script:
17
+ - bundle exec rake spec
18
+ - sonar-scanner
19
+
20
+ deploy:
21
+ provider: rubygems
22
+ api_key:
23
+ secure: "Ce11z+EqDjKfZWe587qw024tfsjkyAhMVvLFGMHbtmXwXLGkJyWZl65t0jLdAyuD41kl7kzImz3ZckMpdFaAR/4m3Lh4iRkeXParv5mr/lE+veMFuAT3hI4pU+ha/Z0nqfPnBOpsqie884G3VD5U2FVtG6fSJ0Ht7wjmGJBy7V8ccmnpVvZnJu4mUVDAMszBRRRc3OoEik3xM+w6cAwh1rdwqKwiOGjrih84GIJd4YCzmZ9GK2hSzXaycVLO5M5155b81IiciTMlVBMHpHJtICQ6Qafm25pW5j0d1L1/YXK5OfA03vHOVCcw9u4kWjjJuMQKhSAdCFEBEMccDBjtwEPZwzpJtjNbQPs2oWuiHiWfSaumVQLHgjnaqjUjIjEQ/r1FOtziH65393AGVwleqjWXlG/0keSvXymP5yBMcwoj5gTpRN4Bsir14WE+QzVmX0wb2tXzqMFrCY8Z6MYJscoNLtbyFbqPvNuft4qjT75M9DUv3g2djbD/0CcjQT5QQgUR+o6Lt6jtMPM4Lyq76eWpn6wDCJmirf8eYg3ocVCc4rYLIUPMr+SgSk/PE2t3s4NCMWHVkTucfIqQ/70I+39dy4m+GkVJS8l8ZF2rHzA537isY7P7UX5J2D2mWYbY2IK8/iVQm4IX6cDxAZRdGlnUvbIC4iD6AMZVn/ve+bo="
24
+ gem: danger-warnings
25
+ on:
26
+ branch: master
27
+ rvm: 2.6
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.0.1] - 2019-01-21
10
+ ### Added
11
+ - Initial release
12
+ - Add [bandit](https://github.com/PyCQA/bandit) parser support
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in danger-warnings.gemspec
4
+ gemspec
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.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2019 Kyaak <kyaak.dev@gmail.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,213 @@
1
+ <h1 align="center">danger-warnings</h1>
2
+
3
+ <div align="center">
4
+ <!-- Sonar Cloud -->
5
+ <a href="https://sonarcloud.io/dashboard?id=Kyaak_danger-warnings">
6
+ <img src="https://sonarcloud.io/images/project_badges/sonarcloud-white.svg"
7
+ alt="Sonar Cloud" />
8
+ </a>
9
+ </div>
10
+
11
+ </br>
12
+
13
+ <div align="center">
14
+ <!-- Build Status -->
15
+ <a href="https://travis-ci.org/Kyaak/danger-warnings">
16
+ <img src="https://img.shields.io/travis/choojs/choo/master.svg"
17
+ alt="Build Status" />
18
+ </a>
19
+ <!-- Quality Gate -->
20
+ <a href="https://sonarcloud.io/dashboard?id=Kyaak_danger-warnings">
21
+ <img src="https://sonarcloud.io/api/project_badges/measure?project=Kyaak_danger-warnings&metric=alert_status"
22
+ alt="Quality Gate" />
23
+ </a>
24
+ </div>
25
+
26
+ <div align="center">
27
+ <!-- Reliability Rating -->
28
+ <a href="https://sonarcloud.io/dashboard?id=Kyaak_danger-warnings">
29
+ <img src="https://sonarcloud.io/api/project_badges/measure?project=Kyaak_danger-warnings&metric=reliability_rating"
30
+ alt="Reliability Rating" />
31
+ </a>
32
+ <!-- Security Rating -->
33
+ <a href="https://sonarcloud.io/dashboard?id=Kyaak_danger-warnings">
34
+ <img src="https://sonarcloud.io/api/project_badges/measure?project=Kyaak_danger-warnings&metric=security_rating"
35
+ alt="Security Rating" />
36
+ </a>
37
+ <!-- Maintainabiltiy -->
38
+ <a href="https://sonarcloud.io/dashboard?id=Kyaak_danger-warnings">
39
+ <img src="https://sonarcloud.io/api/project_badges/measure?project=Kyaak_danger-warnings&metric=sqale_rating"
40
+ alt="Maintainabiltiy" />
41
+ </a>
42
+ </div>
43
+
44
+ <div align="center">
45
+ <!-- Code Smells -->
46
+ <a href="https://sonarcloud.io/dashboard?id=Kyaak_danger-warnings">
47
+ <img src="https://sonarcloud.io/api/project_badges/measure?project=Kyaak_danger-warnings&metric=code_smells"
48
+ alt="Code Smells" />
49
+ </a>
50
+ <!-- Bugs -->
51
+ <a href="https://sonarcloud.io/dashboard?id=Kyaak_danger-warnings">
52
+ <img src="https://sonarcloud.io/api/project_badges/measure?project=Kyaak_danger-warnings&metric=bugs"
53
+ alt="Bugs" />
54
+ </a>
55
+ <!-- Vulnerabilities -->
56
+ <a href="https://sonarcloud.io/dashboard?id=Kyaak_danger-warnings">
57
+ <img src="https://sonarcloud.io/api/project_badges/measure?project=Kyaak_danger-warnings&metric=vulnerabilities"
58
+ alt="Vulnerabilities" />
59
+ </a>
60
+ <!-- Technical Dept -->
61
+ <a href="https://sonarcloud.io/dashboard?id=Kyaak_danger-warnings">
62
+ <img src="https://sonarcloud.io/api/project_badges/measure?project=Kyaak_danger-warnings&metric=sqale_index"
63
+ alt="Technical Dept" />
64
+ </a>
65
+ </div>
66
+
67
+ <div align="center">
68
+ <!-- Coverage -->
69
+ <a href="https://sonarcloud.io/dashboard?id=Kyaak_danger-warnings">
70
+ <img src="https://sonarcloud.io/api/project_badges/measure?project=Kyaak_danger-warnings&metric=coverage"
71
+ alt="Coverage" />
72
+ </a>
73
+ <!-- Docs -->
74
+ <a href="http://inch-ci.org/github/Kyaak/danger-warnings">
75
+ <img src="http://inch-ci.org/github/Kyaak/danger-warnings.svg?branch=master"
76
+ alt="Docs" />
77
+ </a>
78
+ </div>
79
+
80
+ </br>
81
+
82
+ This [danger](https://github.com/danger/danger) plugin provides a uniform report format for various lint [tools](#parsers). <br>
83
+ The purpose is a simple to use plugin regardless of the linter tool used to create the issues.
84
+
85
+ ## Table of Contents
86
+ - [How it looks like](#how-does-it-look)
87
+ - [Installation](#installation)
88
+ - [Examples](#examples)
89
+ - [Configuration](#configuration)
90
+ - [Parsers](#parsers)
91
+
92
+ ## How it looks like
93
+
94
+ ### As markdown
95
+ **Bandit Report**
96
+
97
+ Severity|File|Message
98
+ ---|---|---
99
+ Low|example/ply/yacc_1.py:2853|[B403-blacklist] Consider possible security implications associated with pickle module.
100
+ Medium|example/ply/yacc_2.py:3255|[B102-exec_used] Use of exec detected.
101
+ High|example/ply/yacc_3.py:3255|[B102-exec_used] Use of exec detected.
102
+
103
+ ### As inline comment
104
+ ```text
105
+ Low
106
+ [B403-blacklist]
107
+ Consider possible security implications associated with pickle module.
108
+ ```
109
+
110
+ ## Installation
111
+
112
+ ```bash
113
+ $ gem install danger-warnings
114
+ ```
115
+
116
+ ## Examples
117
+ ```text
118
+ Methods and attributes from this plugin are available in
119
+ your `Dangerfile` under the `warnings` namespace.
120
+ ```
121
+
122
+ #### Minimal example:
123
+ ```ruby
124
+ # Create a bandit report with default settings.
125
+ warnings.report(
126
+ parser: :bandit,
127
+ file: 'reports/bandit.json'
128
+ )
129
+ ```
130
+
131
+ #### Simple example:
132
+ ```ruby
133
+ # Create a bandit report with a custom name, fails if any high warning exists
134
+ # and evaluates all issues (not only the changed files) .
135
+ warnings.report(
136
+ name: 'My Bandit Report',
137
+ parser: :bandit,
138
+ file: 'reports/bandit.json',
139
+ fail_error: true,
140
+ filter: false
141
+ )
142
+ ```
143
+
144
+ #### Complex example:
145
+ ```ruby
146
+ # Define base settings to be applied to all new reporter.
147
+ warnings.inline = true
148
+ warning.fail_error = true
149
+
150
+ # Use custom names to separate the table reports in the danger comment.
151
+ warnings.report(
152
+ name: 'Report 1',
153
+ parser: :bandit,
154
+ file: 'reports/bandit.json'
155
+ # Not necessary because already defined as default.
156
+ # inline: true,
157
+ # fail_error: true
158
+ )
159
+
160
+ warnings.report(
161
+ name: 'Report 2',
162
+ parser: :bandit,
163
+ file: 'reports/bandit.json'
164
+ # Not necessary because already defined as default.
165
+ # inline: true,
166
+ # fail_error: true
167
+ )
168
+
169
+ warnings.report(
170
+ name: 'Report 3',
171
+ parser: :bandit,
172
+ file: 'reports/bandit.json',
173
+ # Override the newly defined default settings only for this reporter.
174
+ inline: false,
175
+ fail_error: false
176
+ )
177
+ ```
178
+
179
+ ## Configuration
180
+
181
+ #### Override default settings
182
+ These values apply to all reports. <br>
183
+ It is possible to override the values in the `report` method.
184
+
185
+ |Field|Default|Description|
186
+ |---|---|---|
187
+ |warnings.**inline**|`False`| Whether to comment as markdown report or do an inline comment on the file.
188
+ |warnings.**filter**|`True`| Whether to filter and report only for changes (modified, created) files. If this is set to false, all issues of a report are included in the comment.
189
+ |warnings.**fail_error**|`False`| Whether to fail if any `High` issue is reported.
190
+
191
+ #### Create a report
192
+ The method `warnings.report(*args)` is the main method of this plugin. <br>
193
+ Configure the details of your report using the arguments passed by.
194
+
195
+ |Parameter|Class|Description|
196
+ |---|---|---|
197
+ |name|`String`| A custom name for this report. If none is given, the parser name is used. Useful to separate different reports using the same common style (e.g. checkstyle).
198
+ |parser|`Symbol`, `String`| Define the parser to evaluate the report file. Must be a key of the supported [parser](#parsers)
199
+ |file|`String`| Path to the file to read and parse.
200
+ |baseline|`String`| Define a baseline for your files. Useful if the report removes a path segment but is required to identify them in the repository. E.g. `/src/main/java`
201
+
202
+ All [default](#override-default-settings) fields can be passed as parameters to `report`.
203
+ - inline
204
+ - filter
205
+ - fail_error
206
+
207
+ These will override the configuration for this report **only**.
208
+
209
+ ## Parsers
210
+
211
+ |Number|Name|ID|File Format|
212
+ |:---:|---|---|---|
213
+ |1|[bandit](https://github.com/PyCQA/bandit)|bandit|json|
data/Rakefile ADDED
@@ -0,0 +1,26 @@
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 = %w(lib/**/*.rb spec/**/*.rb)
18
+ task.fail_on_error = false
19
+ task.formatters = %w(simple json)
20
+ task.options = %w(--out rubocop-result.json)
21
+ end
22
+
23
+ desc 'Ensure that the plugin passes `danger plugins lint`'
24
+ task :spec_docs do
25
+ sh 'bundle exec danger plugins lint'
26
+ end
@@ -0,0 +1,54 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'warnings/gem_version.rb'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'danger-warnings'
7
+ spec.version = Warnings::VERSION
8
+ spec.authors = ['Kyaak']
9
+ spec.email = ['kyaak.dev@gmail.com']
10
+ spec.description = 'Report lint warnings'
11
+ spec.summary = 'Report lint warnings of different tools.'
12
+ spec.homepage = 'https://github.com/Kyaak/danger-warnings'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.required_ruby_version = '>=2.2.0'
21
+
22
+ spec.add_runtime_dependency 'abstract_method', '~> 1.2'
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 'mocha', '~> 1.2'
31
+ spec.add_development_dependency 'rspec', '~> 3.4'
32
+ spec.add_development_dependency 'simplecov', '~> 0.16'
33
+ spec.add_development_dependency 'simplecov-console', '~> 0.4'
34
+
35
+ # Linting code and docs
36
+ spec.add_development_dependency 'rubocop', '~> 0.60'
37
+ spec.add_development_dependency 'yard', '~> 0.9'
38
+
39
+ # Makes testing easy via `bundle exec guard`
40
+ spec.add_development_dependency 'guard', '~> 2.14'
41
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
42
+
43
+ # If you want to work on older builds of ruby
44
+ spec.add_development_dependency 'listen', '3.0.7'
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