danger-reek 0.1.0

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: b9c3596d2fb1e6ffb6bb1938bf904b4c102db689
4
+ data.tar.gz: 0def4d62616ce6410284b1fc6749607c875af218
5
+ SHA512:
6
+ metadata.gz: ae38fa3cd07109b842f975ba052161dc8c1ed9856e07a9be03eb146720c557c884d3cb73afd06a64c798af7c697e98045041033f4d8b8664a49875fd7e877c0f
7
+ data.tar.gz: 3bca8ec1ddbcde0de63575bdd01790e105f888a96606dd7bab46f978563dfcf8d90642075e2a3e71dfa4aaa4a006a03015780479bd1ae3ddfde5c57191486d31
@@ -0,0 +1,240 @@
1
+
2
+ # Created by https://www.gitignore.io/api/ruby,sublimetext,vim,visualstudiocode,jetbrains,linux,osx,windows
3
+
4
+ ### JetBrains ###
5
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
6
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
7
+
8
+ # User-specific stuff:
9
+ .idea/**/workspace.xml
10
+ .idea/**/tasks.xml
11
+ .idea/dictionaries
12
+
13
+ # Sensitive or high-churn files:
14
+ .idea/**/dataSources/
15
+ .idea/**/dataSources.ids
16
+ .idea/**/dataSources.xml
17
+ .idea/**/dataSources.local.xml
18
+ .idea/**/sqlDataSources.xml
19
+ .idea/**/dynamic.xml
20
+ .idea/**/uiDesigner.xml
21
+
22
+ # Gradle:
23
+ .idea/**/gradle.xml
24
+ .idea/**/libraries
25
+
26
+ # CMake
27
+ cmake-build-debug/
28
+
29
+ # Mongo Explorer plugin:
30
+ .idea/**/mongoSettings.xml
31
+
32
+ ## File-based project format:
33
+ *.iws
34
+
35
+ ## Plugin-specific files:
36
+
37
+ # IntelliJ
38
+ /out/
39
+
40
+ # mpeltonen/sbt-idea plugin
41
+ .idea_modules/
42
+
43
+ # JIRA plugin
44
+ atlassian-ide-plugin.xml
45
+
46
+ # Cursive Clojure plugin
47
+ .idea/replstate.xml
48
+
49
+ # Ruby plugin and RubyMine
50
+ /.rakeTasks
51
+
52
+ # Crashlytics plugin (for Android Studio and IntelliJ)
53
+ com_crashlytics_export_strings.xml
54
+ crashlytics.properties
55
+ crashlytics-build.properties
56
+ fabric.properties
57
+
58
+ ### JetBrains Patch ###
59
+ # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
60
+
61
+ # *.iml
62
+ # modules.xml
63
+ # .idea/misc.xml
64
+ # *.ipr
65
+
66
+ # Sonarlint plugin
67
+ .idea/sonarlint
68
+
69
+ ### Linux ###
70
+ *~
71
+
72
+ # temporary files which can be created if a process still has a handle open of a deleted file
73
+ .fuse_hidden*
74
+
75
+ # KDE directory preferences
76
+ .directory
77
+
78
+ # Linux trash folder which might appear on any partition or disk
79
+ .Trash-*
80
+
81
+ # .nfs files are created when an open file is removed but is still being accessed
82
+ .nfs*
83
+
84
+ ### OSX ###
85
+ *.DS_Store
86
+ .AppleDouble
87
+ .LSOverride
88
+
89
+ # Icon must end with two \r
90
+ Icon
91
+
92
+ # Thumbnails
93
+ ._*
94
+
95
+ # Files that might appear in the root of a volume
96
+ .DocumentRevisions-V100
97
+ .fseventsd
98
+ .Spotlight-V100
99
+ .TemporaryItems
100
+ .Trashes
101
+ .VolumeIcon.icns
102
+ .com.apple.timemachine.donotpresent
103
+
104
+ # Directories potentially created on remote AFP share
105
+ .AppleDB
106
+ .AppleDesktop
107
+ Network Trash Folder
108
+ Temporary Items
109
+ .apdisk
110
+
111
+ ### Ruby ###
112
+ *.gem
113
+ *.rbc
114
+ /.config
115
+ /coverage/
116
+ /InstalledFiles
117
+ /pkg/
118
+ /spec/reports/
119
+ /spec/examples.txt
120
+ /test/tmp/
121
+ /test/version_tmp/
122
+ /tmp/
123
+
124
+ # Used by dotenv library to load environment variables.
125
+ # .env
126
+
127
+ ## Specific to RubyMotion:
128
+ .dat*
129
+ .repl_history
130
+ build/
131
+ *.bridgesupport
132
+ build-iPhoneOS/
133
+ build-iPhoneSimulator/
134
+
135
+ ## Specific to RubyMotion (use of CocoaPods):
136
+ #
137
+ # We recommend against adding the Pods directory to your .gitignore. However
138
+ # you should judge for yourself, the pros and cons are mentioned at:
139
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
140
+ #
141
+ # vendor/Pods/
142
+
143
+ ## Documentation cache and generated files:
144
+ /.yardoc/
145
+ /_yardoc/
146
+ /doc/
147
+ /rdoc/
148
+
149
+ ## Environment normalization:
150
+ /.bundle/
151
+ /vendor/bundle
152
+ /lib/bundler/man/
153
+
154
+ # for a library or gem, you might want to ignore these files since the code is
155
+ # intended to run in multiple environments; otherwise, check them in:
156
+ # Gemfile.lock
157
+ # .ruby-version
158
+ # .ruby-gemset
159
+
160
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
161
+ .rvmrc
162
+
163
+ ### SublimeText ###
164
+ # cache files for sublime text
165
+ *.tmlanguage.cache
166
+ *.tmPreferences.cache
167
+ *.stTheme.cache
168
+
169
+ # workspace files are user-specific
170
+ *.sublime-workspace
171
+
172
+ # project files should be checked into the repository, unless a significant
173
+ # proportion of contributors will probably not be using SublimeText
174
+ # *.sublime-project
175
+
176
+ # sftp configuration file
177
+ sftp-config.json
178
+
179
+ # Package control specific files
180
+ Package Control.last-run
181
+ Package Control.ca-list
182
+ Package Control.ca-bundle
183
+ Package Control.system-ca-bundle
184
+ Package Control.cache/
185
+ Package Control.ca-certs/
186
+ Package Control.merged-ca-bundle
187
+ Package Control.user-ca-bundle
188
+ oscrypto-ca-bundle.crt
189
+ bh_unicode_properties.cache
190
+
191
+ # Sublime-github package stores a github token in this file
192
+ # https://packagecontrol.io/packages/sublime-github
193
+ GitHub.sublime-settings
194
+
195
+ ### Vim ###
196
+ # swap
197
+ [._]*.s[a-v][a-z]
198
+ [._]*.sw[a-p]
199
+ [._]s[a-v][a-z]
200
+ [._]sw[a-p]
201
+ # session
202
+ Session.vim
203
+ # temporary
204
+ .netrwhist
205
+ # auto-generated tag files
206
+ tags
207
+
208
+ ### VisualStudioCode ###
209
+ .vscode/*
210
+ !.vscode/settings.json
211
+ !.vscode/tasks.json
212
+ !.vscode/launch.json
213
+ !.vscode/extensions.json
214
+ .history
215
+
216
+ ### Windows ###
217
+ # Windows thumbnail cache files
218
+ Thumbs.db
219
+ ehthumbs.db
220
+ ehthumbs_vista.db
221
+
222
+ # Folder config file
223
+ Desktop.ini
224
+
225
+ # Recycle Bin used on file shares
226
+ $RECYCLE.BIN/
227
+
228
+ # Windows Installer files
229
+ *.cab
230
+ *.msi
231
+ *.msm
232
+ *.msp
233
+
234
+ # Windows shortcuts
235
+ *.lnk
236
+
237
+ # End of https://www.gitignore.io/api/ruby,sublimetext,vim,visualstudiocode,jetbrains,linux,osx,windows
238
+ Gemfile.lock
239
+ .ruby-version
240
+ .ruby-gemset
@@ -0,0 +1,148 @@
1
+ # Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
2
+
3
+ # If you don't like these settings, just delete this file :)
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.0
7
+
8
+ # kind_of? is a good way to check a type
9
+ Style/ClassCheck:
10
+ EnforcedStyle: kind_of?
11
+
12
+ # It's better to be more explicit about the type
13
+ Style/BracesAroundHashParameters:
14
+ Enabled: false
15
+
16
+ # specs sometimes have useless assignments, which is fine
17
+ Lint/UselessAssignment:
18
+ Exclude:
19
+ - '**/spec/**/*'
20
+
21
+ # We could potentially enable the 2 below:
22
+ Layout/IndentHash:
23
+ Enabled: false
24
+
25
+ Layout/AlignHash:
26
+ Enabled: false
27
+
28
+ # HoundCI doesn't like this rule
29
+ Layout/DotPosition:
30
+ Enabled: false
31
+
32
+ # We allow !! as it's an easy way to convert ot boolean
33
+ Style/DoubleNegation:
34
+ Enabled: false
35
+
36
+ # Cop supports --auto-correct.
37
+ Lint/UnusedBlockArgument:
38
+ Enabled: false
39
+
40
+ # We want to allow class Fastlane::Class
41
+ Style/ClassAndModuleChildren:
42
+ Enabled: false
43
+
44
+ Metrics/AbcSize:
45
+ Max: 60
46
+
47
+ # The %w might be confusing for new users
48
+ Style/WordArray:
49
+ MinSize: 19
50
+
51
+ # raise and fail are both okay
52
+ Style/SignalException:
53
+ Enabled: false
54
+
55
+ # Better too much 'return' than one missing
56
+ Style/RedundantReturn:
57
+ Enabled: false
58
+
59
+ # Having if in the same line might not always be good
60
+ Style/IfUnlessModifier:
61
+ Enabled: false
62
+
63
+ # and and or is okay
64
+ Style/AndOr:
65
+ Enabled: false
66
+
67
+ # Configuration parameters: CountComments.
68
+ Metrics/ClassLength:
69
+ Max: 350
70
+
71
+ Metrics/CyclomaticComplexity:
72
+ Max: 17
73
+
74
+ # Configuration parameters: AllowURI, URISchemes.
75
+ Metrics/LineLength:
76
+ Max: 370
77
+
78
+ # Configuration parameters: CountKeywordArgs.
79
+ Metrics/ParameterLists:
80
+ Max: 10
81
+
82
+ Metrics/PerceivedComplexity:
83
+ Max: 18
84
+
85
+ # Sometimes it's easier to read without guards
86
+ Style/GuardClause:
87
+ Enabled: false
88
+
89
+ # something = if something_else
90
+ # that's confusing
91
+ Style/ConditionalAssignment:
92
+ Enabled: false
93
+
94
+ # Better to have too much self than missing a self
95
+ Style/RedundantSelf:
96
+ Enabled: false
97
+
98
+ Metrics/MethodLength:
99
+ Max: 60
100
+
101
+ # We're not there yet
102
+ Style/Documentation:
103
+ Enabled: false
104
+
105
+ # Adds complexity
106
+ Style/IfInsideElse:
107
+ Enabled: false
108
+
109
+ # danger specific
110
+
111
+ Style/BlockComments:
112
+ Enabled: false
113
+
114
+ Layout/MultilineMethodCallIndentation:
115
+ EnforcedStyle: indented
116
+
117
+ # FIXME: 25
118
+ Metrics/BlockLength:
119
+ Max: 345
120
+ Exclude:
121
+ - "**/*_spec.rb"
122
+
123
+ Style/MixinGrouping:
124
+ Enabled: false
125
+
126
+ Style/FileName:
127
+ Enabled: false
128
+
129
+ Layout/IndentHeredoc:
130
+ Enabled: false
131
+
132
+ Style/SpecialGlobalVars:
133
+ Enabled: false
134
+
135
+ PercentLiteralDelimiters:
136
+ PreferredDelimiters:
137
+ "%": ()
138
+ "%i": ()
139
+ "%q": ()
140
+ "%Q": ()
141
+ "%r": "{}"
142
+ "%s": ()
143
+ "%w": ()
144
+ "%W": ()
145
+ "%x": ()
146
+
147
+ Security/YAMLLoad:
148
+ Enabled: false
@@ -0,0 +1,27 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=$CC_TEST_REPORTER_ID
4
+
5
+ language: ruby
6
+ cache:
7
+ directories:
8
+ - bundle
9
+
10
+ rvm:
11
+ - 2.2.8
12
+ - 2.3.5
13
+ - 2.4.2
14
+
15
+ before_install:
16
+ - gem update bundler
17
+
18
+ before_script:
19
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
20
+ - chmod +x ./cc-test-reporter
21
+ - ./cc-test-reporter before-build
22
+
23
+ script:
24
+ - bundle exec rake spec
25
+
26
+ after_script:
27
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in danger-reek.gemspec
4
+ gemspec
@@ -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,22 @@
1
+ Copyright (c) 2017 blooper05 <legend.of.blooper@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,39 @@
1
+ # danger-reek
2
+
3
+ [![Build Status](https://img.shields.io/travis/blooper05/danger-reek.svg)](https://travis-ci.org/blooper05/danger-reek)
4
+ [![Code Climate](https://img.shields.io/codeclimate/github/blooper05/danger-reek.svg)](https://codeclimate.com/github/blooper05/danger-reek)
5
+ [![Coverage](https://img.shields.io/codeclimate/coverage/github/blooper05/danger-reek.svg)](https://codeclimate.com/github/blooper05/danger-reek)
6
+ [![Dependency Status](https://img.shields.io/gemnasium/blooper05/danger-reek.svg)](https://gemnasium.com/blooper05/danger-reek)
7
+ [![Gem Version](https://img.shields.io/gem/v/danger-reek.svg)](https://rubygems.org/gems/danger-reek)
8
+ [![License](https://img.shields.io/github/license/blooper05/danger-reek.svg)](https://github.com/blooper05/danger-reek/blob/master/LICENSE)
9
+
10
+ A [danger](https://rubygems.org/gems/danger) plugin for [Reek](https://rubygems.org/gems/reek).
11
+
12
+ ## Installation
13
+
14
+ $ gem install danger-reek
15
+
16
+ ## Usage
17
+
18
+ ### reek
19
+
20
+ Lints Ruby files via [Reek](https://rubygems.org/gems/reek).
21
+ Results are sent as inline comments.
22
+
23
+ <blockquote>Running Reek
24
+ <pre>
25
+ # Runs Reek on modified and added files in the PR
26
+ reek.lint</pre>
27
+ </blockquote>
28
+
29
+ #### Methods
30
+
31
+ `lint` - Runs Ruby files through Reek.
32
+
33
+ ## Development
34
+
35
+ 1. Clone this repo
36
+ 2. Run `bundle install` to setup dependencies.
37
+ 3. Run `bundle exec rake spec` to run the tests.
38
+ 4. Use `bundle exec guard` to automatically have tests run as you make changes.
39
+ 5. Make your changes.
@@ -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,51 @@
1
+
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'reek/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'danger-reek'
8
+ spec.version = Reek::VERSION
9
+ spec.authors = ['blooper05']
10
+ spec.email = ['legend.of.blooper@gmail.com']
11
+ spec.description = 'A Danger plugin to lint Ruby files through Reek.'
12
+ spec.summary = 'A Danger plugin to lint Ruby files through Reek.'
13
+ spec.homepage = 'https://github.com/blooper05/danger-reek'
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 'reek', '~> 4.2'
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
+ spec.add_development_dependency 'simplecov', '~> 0.13'
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
+ # This gives you the chance to run a REPL inside your tests
44
+ # via:
45
+ #
46
+ # require 'pry'
47
+ # binding.pry
48
+ #
49
+ # This will stop test execution and let you inspect the results
50
+ spec.add_development_dependency 'pry'
51
+ end
@@ -0,0 +1 @@
1
+ require 'reek/plugin'
@@ -0,0 +1 @@
1
+ require 'reek/gem_version'
@@ -0,0 +1,3 @@
1
+ module Reek
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,47 @@
1
+ require 'reek'
2
+
3
+ module Danger
4
+ # Lints Ruby files via [Reek](https://rubygems.org/gems/reek).
5
+ # Results are sent as inline comments.
6
+ #
7
+ # @example Running Reek
8
+ #
9
+ # # Runs Reek on modified and added files in the PR
10
+ # reek.lint
11
+ #
12
+ # @see blooper05/danger-reek
13
+ # @tags ruby, reek, lint
14
+ class DangerReek < Plugin
15
+ # Runs Ruby files through Reek.
16
+ # @return [Array<Reek::SmellWarning, nil>]
17
+ def lint
18
+ files_to_lint = fetch_files_to_lint
19
+ code_smells = run_linter(files_to_lint)
20
+ warn_each_line(code_smells)
21
+ end
22
+
23
+ private
24
+
25
+ def run_linter(files_to_lint)
26
+ files_to_lint.flat_map do |file|
27
+ examiner = ::Reek::Examiner.new(file)
28
+ examiner.smells
29
+ end
30
+ end
31
+
32
+ def fetch_files_to_lint
33
+ files = git.modified_files + git.added_files
34
+ Array(files.map { |file| Pathname(file) })
35
+ end
36
+
37
+ def warn_each_line(code_smells)
38
+ code_smells.each do |smell|
39
+ message = smell.message.capitalize
40
+ source = smell.source
41
+ smell.lines.each do |line|
42
+ warn(message, file: source, line: line)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
File without changes
File without changes
@@ -0,0 +1,79 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ module Danger
4
+ describe Danger::DangerReek do
5
+ it 'should be a plugin' do
6
+ expect(Danger::DangerReek.new(nil)).to be_a Danger::Plugin
7
+ end
8
+
9
+ describe 'with Dangerfile' do
10
+ let(:dangerfile) { testing_dangerfile }
11
+ let(:reek) { dangerfile.reek }
12
+
13
+ describe '#lint' do
14
+ subject { reek.lint }
15
+
16
+ before { stubbings }
17
+ before { subject }
18
+
19
+ let(:changed_files) do
20
+ git = reek.git
21
+ expect(git).to receive(:modified_files).and_return(modified_files)
22
+ expect(git).to receive(:added_files).and_return(added_files)
23
+ end
24
+
25
+ let(:status_reports) { dangerfile.status_report[:warnings] }
26
+ let(:violation_reports) { dangerfile.violation_report[:warnings] }
27
+
28
+ context 'with changed files' do
29
+ let(:modified_files) { [Pathname('spec/fixtures/modified_file.rb')] }
30
+ let(:added_files) { [Pathname('spec/fixtures/added_file.rb')] }
31
+
32
+ context 'with code smells' do
33
+ let(:stubbings) { changed_files && code_smells }
34
+
35
+ let(:code_smells) do
36
+ linter = ::Reek::Examiner
37
+ smells = [double('Code Smells', message: smell_message,
38
+ source: source,
39
+ lines: lines)]
40
+ allow_any_instance_of(linter).to receive(:smells)
41
+ .and_return(smells)
42
+ end
43
+
44
+ let(:smell_message) { 'smell message' }
45
+ let(:source) { 'path/to/file' }
46
+ let(:lines) { [123] }
47
+
48
+ it 'returns warning reports' do
49
+ message = 'Smell message'
50
+ violation = Violation.new(message, false, 'path/to/file', 123)
51
+ expect(status_reports).to eq([message] * 2)
52
+ expect(violation_reports).to eq([violation] * 2)
53
+ end
54
+ end
55
+
56
+ context 'with no code smells' do
57
+ let(:stubbings) { changed_files }
58
+
59
+ it 'returns no warning reports' do
60
+ expect(status_reports).to be_empty
61
+ expect(violation_reports).to be_empty
62
+ end
63
+ end
64
+ end
65
+
66
+ context 'with no changed files' do
67
+ let(:stubbings) { changed_files }
68
+ let(:modified_files) { [] }
69
+ let(:added_files) { [] }
70
+
71
+ it 'returns no warning reports' do
72
+ expect(status_reports).to be_empty
73
+ expect(violation_reports).to be_empty
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,68 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $:.unshift((ROOT + 'lib').to_s)
4
+ $:.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'simplecov'
7
+ SimpleCov.start
8
+
9
+ require 'bundler/setup'
10
+ require 'pry'
11
+
12
+ require 'rspec'
13
+ require 'danger'
14
+
15
+ if `git remote -v` == ''
16
+ puts 'You cannot run tests without setting a local git remote on this repo'
17
+ puts "It's a weird side-effect of Danger's internals."
18
+ exit(0)
19
+ end
20
+
21
+ # Use coloured output, it's the best.
22
+ RSpec.configure do |config|
23
+ config.filter_gems_from_backtrace 'bundler'
24
+ config.color = true
25
+ config.tty = true
26
+ end
27
+
28
+ require 'danger_plugin'
29
+
30
+ # These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
31
+ # If you are expanding these files, see if it's already been done ^.
32
+
33
+ # A silent version of the user interface,
34
+ # it comes with an extra function `.string` which will
35
+ # strip all ANSI colours from the string.
36
+
37
+ # rubocop:disable Lint/NestedMethodDefinition
38
+ def testing_ui
39
+ @output = StringIO.new
40
+ def @output.winsize
41
+ [20, 9999]
42
+ end
43
+
44
+ cork = Cork::Board.new(out: @output)
45
+ def cork.string
46
+ out.string.gsub(/\e\[([;\d]+)?m/, '')
47
+ end
48
+ cork
49
+ end
50
+ # rubocop:enable Lint/NestedMethodDefinition
51
+
52
+ # Example environment (ENV) that would come from
53
+ # running a PR on TravisCI
54
+ def testing_env
55
+ {
56
+ 'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
57
+ 'TRAVIS_PULL_REQUEST' => '800',
58
+ 'TRAVIS_REPO_SLUG' => 'artsy/eigen',
59
+ 'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
60
+ 'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
61
+ }
62
+ end
63
+
64
+ # A stubbed out Dangerfile for use in tests
65
+ def testing_dangerfile
66
+ env = Danger::EnvironmentManager.new(testing_env)
67
+ Danger::Dangerfile.new(env, testing_ui)
68
+ end
metadata ADDED
@@ -0,0 +1,233 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-reek
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - blooper05
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-10-10 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: reek
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.2'
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: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.13'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.13'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.41'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.41'
111
+ - !ruby/object:Gem::Dependency
112
+ name: yard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.8'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.8'
125
+ - !ruby/object:Gem::Dependency
126
+ name: guard
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.14'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '2.14'
139
+ - !ruby/object:Gem::Dependency
140
+ name: guard-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '4.7'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '4.7'
153
+ - !ruby/object:Gem::Dependency
154
+ name: listen
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 3.0.7
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 3.0.7
167
+ - !ruby/object:Gem::Dependency
168
+ name: pry
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ description: A Danger plugin to lint Ruby files through Reek.
182
+ email:
183
+ - legend.of.blooper@gmail.com
184
+ executables: []
185
+ extensions: []
186
+ extra_rdoc_files: []
187
+ files:
188
+ - ".gitignore"
189
+ - ".rubocop.yml"
190
+ - ".travis.yml"
191
+ - Gemfile
192
+ - Guardfile
193
+ - LICENSE
194
+ - README.md
195
+ - Rakefile
196
+ - danger-reek.gemspec
197
+ - lib/danger_plugin.rb
198
+ - lib/danger_reek.rb
199
+ - lib/reek/gem_version.rb
200
+ - lib/reek/plugin.rb
201
+ - spec/fixtures/added_file.rb
202
+ - spec/fixtures/modified_file.rb
203
+ - spec/reek_spec.rb
204
+ - spec/spec_helper.rb
205
+ homepage: https://github.com/blooper05/danger-reek
206
+ licenses:
207
+ - MIT
208
+ metadata: {}
209
+ post_install_message:
210
+ rdoc_options: []
211
+ require_paths:
212
+ - lib
213
+ required_ruby_version: !ruby/object:Gem::Requirement
214
+ requirements:
215
+ - - ">="
216
+ - !ruby/object:Gem::Version
217
+ version: '0'
218
+ required_rubygems_version: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ requirements: []
224
+ rubyforge_project:
225
+ rubygems_version: 2.6.13
226
+ signing_key:
227
+ specification_version: 4
228
+ summary: A Danger plugin to lint Ruby files through Reek.
229
+ test_files:
230
+ - spec/fixtures/added_file.rb
231
+ - spec/fixtures/modified_file.rb
232
+ - spec/reek_spec.rb
233
+ - spec/spec_helper.rb