danger-jazzy 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 35d58202f487e509470c90aab65fa9cea18e90a0
4
+ data.tar.gz: 05dfed94d0ae49d856ace9152dc9baf416239af6
5
+ SHA512:
6
+ metadata.gz: 0a10983eb00e1005984ce3ac4bf313c40d08a2c9b85404e304f79d21bc96ce892b15a0ca36af22e3fc98c94dff97fd48e92b7bb71440729f45c07d87a30e5775
7
+ data.tar.gz: 53c25744ba1dd7f8822344160fc678b4029125c2dfd00155247e26995268681320523fce11b928938f0bd39830704279d91cb46750ddae4f24d73691f6fb6218
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ .yardoc/
5
+ Gemfile.lock
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ cache:
3
+ directories:
4
+ - bundle
5
+
6
+ rvm:
7
+ - 2.0
8
+ - 2.1.3
9
+ - 2.3.1
10
+
11
+ script:
12
+ - bundle exec rake spec
@@ -0,0 +1,7 @@
1
+ ## [Unreleased][]
2
+
3
+ ## [0.1.1][] (2016-11-09)
4
+ * Bugfixes.
5
+
6
+ ## [0.1.0][] (2016-11-06)
7
+ * Initial release!
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in danger-jazzy.gemspec
4
+ gemspec
5
+
6
+ gem 'chandler', '~> 0.5.0'
@@ -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
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Frederik Wallner <frederik.wallner@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.
@@ -0,0 +1,26 @@
1
+ ### jazzy
2
+ This is a danger plugin to check for undocumented symbols via Jazzy.
3
+
4
+ <blockquote>Warn about undocumented symbols.
5
+ <pre>
6
+ jazzy.warn_of_undocumented</pre>
7
+ </blockquote>
8
+
9
+ <blockquote>Write a custom message for undocumented symbols.
10
+ <pre>
11
+ jazzy.undocumented do |file,line|
12
+ message("You forgot to document this", file:file, line:line)
13
+ end</pre>
14
+ </blockquote>
15
+
16
+
17
+ #### Attributes
18
+
19
+ `path_to_docs` - Path to the docs folder, defaults to 'docs/'.
20
+
21
+
22
+ #### Methods
23
+
24
+ `warn_of_undocumented` - Warns about undocumented symbols.
25
+
26
+ `undocumented` - Finds and yields information about undocumented symbols.
@@ -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,50 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jazzy/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'danger-jazzy'
8
+ spec.version = Jazzy::VERSION
9
+ spec.authors = ['Frederik Wallner']
10
+ spec.email = ['frederik.wallner@gmail.com']
11
+ spec.description = %q{A short description of danger-jazzy.}
12
+ spec.summary = %q{A longer description of danger-jazzy.}
13
+ spec.homepage = 'https://github.com/fwal/danger-jazzy'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
22
+ spec.add_runtime_dependency 'json', '~> 1.8'
23
+
24
+ # General ruby development
25
+ spec.add_development_dependency 'bundler', '~> 1.3'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+
28
+ # Testing support
29
+ spec.add_development_dependency 'rspec', '~> 3.4'
30
+
31
+ # Linting code and docs
32
+ spec.add_development_dependency 'rubocop', '~> 0.41'
33
+ spec.add_development_dependency 'yard', '~> 0.8'
34
+
35
+ # Makes testing easy via `bundle exec guard`
36
+ spec.add_development_dependency 'guard', '~> 2.14'
37
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
38
+
39
+ # If you want to work on older builds of ruby
40
+ spec.add_development_dependency 'listen', '3.0.7'
41
+
42
+ # This gives you the chance to run a REPL inside your tests
43
+ # via:
44
+ #
45
+ # require 'pry'
46
+ # binding.pry
47
+ #
48
+ # This will stop test execution and let you inspect the results
49
+ spec.add_development_dependency 'pry'
50
+ end
@@ -0,0 +1 @@
1
+ require 'jazzy/gem_version'
@@ -0,0 +1,3 @@
1
+ require 'jazzy/symbol'
2
+ require 'jazzy/undocumented_reader'
3
+ require 'jazzy/plugin'
@@ -0,0 +1,3 @@
1
+ module Jazzy
2
+ VERSION = '0.1.1'.freeze
3
+ end
@@ -0,0 +1,61 @@
1
+ module Danger
2
+ # This is a danger plugin to check for undocumented symbols via Jazzy.
3
+ #
4
+ # @example Warn about undocumented symbols.
5
+ #
6
+ # jazzy.warn_of_undocumented
7
+ #
8
+ # @example Write a custom message for undocumented symbols.
9
+ #
10
+ # jazzy.undocumented do |file,line|
11
+ # message("You forgot to document this", file:file, line:line)
12
+ # end
13
+ #
14
+ # @see fwal/danger-jazzy
15
+ # @tags jazzy, docs, documentation
16
+ #
17
+ class DangerJazzy < Plugin
18
+ DEFAULT_MESSAGE = 'Undocumented symbol.'.freeze
19
+
20
+ # Path to the docs folder, defaults to 'docs/'.
21
+ # @return [String]
22
+ attr_accessor :path_to_docs
23
+
24
+ # Warns about undocumented symbols.
25
+ # @return [void]
26
+ def warn_of_undocumented
27
+ undocumented.each do |item|
28
+ warn DEFAULT_MESSAGE, file: item.file, line: item.line
29
+ end
30
+ end
31
+
32
+ # Returns a list of undocumented symbols in the current diff.
33
+ # @return [Array of symbol]
34
+ def undocumented
35
+ return unless File.exist? undocumented_path
36
+ load_undocumented if @undocumented.nil?
37
+ @undocumented
38
+ end
39
+
40
+ private
41
+
42
+ def docs_path
43
+ @path_to_docs || 'docs/'
44
+ end
45
+
46
+ def undocumented_path
47
+ File.join(docs_path, 'undocumented.json')
48
+ end
49
+
50
+ def files_of_interest
51
+ git.modified_files + git.added_files
52
+ end
53
+
54
+ def load_undocumented
55
+ reader = UndocumentedReader.new(undocumented_path)
56
+ @undocumented = reader.undocumented_symbols.select do |item|
57
+ files_of_interest.include?(item.file)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,3 @@
1
+ module Danger
2
+ Symbol = Struct.new(:file, :line, :symbol, :symbol_kind, :warning)
3
+ end
@@ -0,0 +1,37 @@
1
+ module Danger
2
+ # Reads undocumented.json file created by jazzy
3
+ class UndocumentedReader
4
+ def initialize(path)
5
+ load(path)
6
+ end
7
+
8
+ def undocumented_symbols
9
+ @data['warnings'].map do |item|
10
+ next unless item_valid? item
11
+ Symbol.new(
12
+ item_file(item),
13
+ item['line'],
14
+ item['symbol'],
15
+ item['symbol_kind'],
16
+ item['warning']
17
+ )
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def load(path)
24
+ @data = JSON.parse(File.read(path))
25
+ @working_path = Pathname.new(@data['source_directory'])
26
+ end
27
+
28
+ def item_file(item)
29
+ path = Pathname.new(item['file'])
30
+ path.relative_path_from(@working_path).to_s
31
+ end
32
+
33
+ def item_valid?(item)
34
+ item['warning'] == 'undocumented'
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,19 @@
1
+ {
2
+ "warnings": [
3
+ {
4
+ "file": "/MyFile.swift",
5
+ "line": 4,
6
+ "symbol": "MyClass.doStuff()",
7
+ "symbol_kind": "source.lang.swift.decl.function.method.instance",
8
+ "warning": "undocumented"
9
+ },
10
+ {
11
+ "file": "/MyOtherFile.swift",
12
+ "line": 2,
13
+ "symbol": "MyStruct.handleThing()",
14
+ "symbol_kind": "source.lang.swift.decl.function.method.instance",
15
+ "warning": "undocumented"
16
+ }
17
+ ],
18
+ "source_directory": "/"
19
+ }
@@ -0,0 +1,53 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ module Danger
4
+ describe Danger::DangerJazzy do
5
+ it 'should be a plugin' do
6
+ expect(Danger::DangerJazzy.new(nil)).to be_a Danger::Plugin
7
+ end
8
+
9
+ #
10
+ # You should test your custom attributes and methods here
11
+ #
12
+ describe 'with Dangerfile' do
13
+ before do
14
+ @dangerfile = testing_dangerfile
15
+ @my_plugin = @dangerfile.jazzy
16
+ @default_message = 'Undocumented symbol.'
17
+ end
18
+
19
+ context 'changed files contains undocumented symbols' do
20
+ before do
21
+ modified = Git::Diff::DiffFile.new(
22
+ 'base',
23
+ path: 'OldFile.swift',
24
+ patch: '- //old'
25
+ )
26
+ added = Git::Diff::DiffFile.new(
27
+ 'base',
28
+ path: 'MyFile.swift',
29
+ patch: '+ //new'
30
+ )
31
+
32
+ allow(@dangerfile.git).to receive(:diff_for_file)
33
+ .with('OldFile.swift').and_return(modified)
34
+
35
+ allow(@dangerfile.git).to receive(:diff_for_file)
36
+ .with('MyFile.swift').and_return(added)
37
+
38
+ allow(@dangerfile.git).to receive(:modified_files)
39
+ .and_return(['OldFile.swift'])
40
+
41
+ allow(@dangerfile.git).to receive(:added_files)
42
+ .and_return(['MyFile.swift'])
43
+ end
44
+
45
+ it 'Warns on undocumented symbols' do
46
+ @my_plugin.path_to_docs = 'spec/fixtures'
47
+ @my_plugin.warn_of_undocumented
48
+ expect(@dangerfile.status_report[:warnings]).to eq([@default_message])
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,59 @@
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
+ # Use coloured output, it's the best.
13
+ RSpec.configure do |config|
14
+ config.filter_gems_from_backtrace 'bundler'
15
+ config.color = true
16
+ config.tty = true
17
+ end
18
+
19
+ require 'danger_plugin'
20
+
21
+ # These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
22
+ # If you are expanding these files, see if it's already been done ^.
23
+
24
+ # A silent version of the user interface,
25
+ # it comes with an extra function `.string` which will
26
+ # strip all ANSI colours from the string.
27
+
28
+ # rubocop:disable Lint/NestedMethodDefinition
29
+ def testing_ui
30
+ @output = StringIO.new
31
+ def @output.winsize
32
+ [20, 9999]
33
+ end
34
+
35
+ cork = Cork::Board.new(out: @output)
36
+ def cork.string
37
+ out.string.gsub(/\e\[([;\d]+)?m/, '')
38
+ end
39
+ cork
40
+ end
41
+ # rubocop:enable Lint/NestedMethodDefinition
42
+
43
+ # Example environment (ENV) that would come from
44
+ # running a PR on TravisCI
45
+ def testing_env
46
+ {
47
+ 'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
48
+ 'TRAVIS_PULL_REQUEST' => '800',
49
+ 'TRAVIS_REPO_SLUG' => 'artsy/eigen',
50
+ 'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
51
+ 'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
52
+ }
53
+ end
54
+
55
+ # A stubbed out Dangerfile for use in tests
56
+ def testing_dangerfile
57
+ env = Danger::EnvironmentManager.new(testing_env)
58
+ Danger::Dangerfile.new(env, testing_ui)
59
+ end
metadata ADDED
@@ -0,0 +1,219 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-jazzy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Frederik Wallner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-09 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: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.41'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.41'
97
+ - !ruby/object:Gem::Dependency
98
+ name: yard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.8'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.8'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.14'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.14'
125
+ - !ruby/object:Gem::Dependency
126
+ name: guard-rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '4.7'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '4.7'
139
+ - !ruby/object:Gem::Dependency
140
+ name: listen
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 3.0.7
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 3.0.7
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: A short description of danger-jazzy.
168
+ email:
169
+ - frederik.wallner@gmail.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".gitignore"
175
+ - ".travis.yml"
176
+ - CHANGELOG.md
177
+ - Gemfile
178
+ - Guardfile
179
+ - LICENSE.txt
180
+ - README.md
181
+ - Rakefile
182
+ - danger-jazzy.gemspec
183
+ - lib/danger_jazzy.rb
184
+ - lib/danger_plugin.rb
185
+ - lib/jazzy/gem_version.rb
186
+ - lib/jazzy/plugin.rb
187
+ - lib/jazzy/symbol.rb
188
+ - lib/jazzy/undocumented_reader.rb
189
+ - spec/fixtures/undocumented.json
190
+ - spec/jazzy_spec.rb
191
+ - spec/spec_helper.rb
192
+ homepage: https://github.com/fwal/danger-jazzy
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.5.1
213
+ signing_key:
214
+ specification_version: 4
215
+ summary: A longer description of danger-jazzy.
216
+ test_files:
217
+ - spec/fixtures/undocumented.json
218
+ - spec/jazzy_spec.rb
219
+ - spec/spec_helper.rb