danger-slim_lint 0.1.0

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: b7f858e125bd94d40d4ec7717349cc1512080319cb2e301c125c9c1e771ae3d8
4
+ data.tar.gz: 7e93d9bcb66ff544a51d2a3a28571adc5be0bd7c4ceb84aba5229a08583ad2c3
5
+ SHA512:
6
+ metadata.gz: 38498529c23354042acf5819b754553132fdf7ad97466fe0c23ab8acada8e83db9c5103e920d00090f691d045c5fbf4aaead737e012ff1f007fb6f04891b34e1
7
+ data.tar.gz: 71f71c175ee6073d24f0fec3e4499c00f0581461b8d68f9f12062889d392cff556d2bbeff1a5e7da3443409d83a648a0d59a3a70ef966035026335f9f9f5867f
data/.gitignore ADDED
@@ -0,0 +1,239 @@
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
+ .sw[a-p]
198
+ .*.sw[a-p]
199
+ # session
200
+ Session.vim
201
+ # temporary
202
+ .netrwhist
203
+ # auto-generated tag files
204
+ tags
205
+
206
+ ### VisualStudioCode ###
207
+ .vscode/*
208
+ !.vscode/settings.json
209
+ !.vscode/tasks.json
210
+ !.vscode/launch.json
211
+ !.vscode/extensions.json
212
+ .history
213
+
214
+ ### Windows ###
215
+ # Windows thumbnail cache files
216
+ Thumbs.db
217
+ ehthumbs.db
218
+ ehthumbs_vista.db
219
+
220
+ # Folder config file
221
+ Desktop.ini
222
+
223
+ # Recycle Bin used on file shares
224
+ $RECYCLE.BIN/
225
+
226
+ # Windows Installer files
227
+ *.cab
228
+ *.msi
229
+ *.msm
230
+ *.msp
231
+
232
+ # Windows shortcuts
233
+ *.lnk
234
+
235
+
236
+ # End of https://www.gitignore.io/api/ruby,sublimetext,vim,visualstudiocode,jetbrains,linux,osx,windows
237
+ Gemfile.lock
238
+ .ruby-version
239
+ .ruby-gemset
data/.rubocop.yml ADDED
@@ -0,0 +1,145 @@
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
+ # kind_of? is a good way to check a type
6
+ Style/ClassCheck:
7
+ EnforcedStyle: kind_of?
8
+
9
+ # It's better to be more explicit about the type
10
+ Style/BracesAroundHashParameters:
11
+ Enabled: false
12
+
13
+ # specs sometimes have useless assignments, which is fine
14
+ Lint/UselessAssignment:
15
+ Exclude:
16
+ - '**/spec/**/*'
17
+
18
+ # We could potentially enable the 2 below:
19
+ Layout/IndentHash:
20
+ Enabled: false
21
+
22
+ Layout/AlignHash:
23
+ Enabled: false
24
+
25
+ # HoundCI doesn't like this rule
26
+ Layout/DotPosition:
27
+ Enabled: false
28
+
29
+ # We allow !! as it's an easy way to convert ot boolean
30
+ Style/DoubleNegation:
31
+ Enabled: false
32
+
33
+ # Cop supports --auto-correct.
34
+ Lint/UnusedBlockArgument:
35
+ Enabled: false
36
+
37
+ # We want to allow class Fastlane::Class
38
+ Style/ClassAndModuleChildren:
39
+ Enabled: false
40
+
41
+ Metrics/AbcSize:
42
+ Max: 60
43
+
44
+ # The %w might be confusing for new users
45
+ Style/WordArray:
46
+ MinSize: 19
47
+
48
+ # raise and fail are both okay
49
+ Style/SignalException:
50
+ Enabled: false
51
+
52
+ # Better too much 'return' than one missing
53
+ Style/RedundantReturn:
54
+ Enabled: false
55
+
56
+ # Having if in the same line might not always be good
57
+ Style/IfUnlessModifier:
58
+ Enabled: false
59
+
60
+ # and and or is okay
61
+ Style/AndOr:
62
+ Enabled: false
63
+
64
+ # Configuration parameters: CountComments.
65
+ Metrics/ClassLength:
66
+ Max: 350
67
+
68
+ Metrics/CyclomaticComplexity:
69
+ Max: 17
70
+
71
+ # Configuration parameters: AllowURI, URISchemes.
72
+ Metrics/LineLength:
73
+ Max: 370
74
+
75
+ # Configuration parameters: CountKeywordArgs.
76
+ Metrics/ParameterLists:
77
+ Max: 10
78
+
79
+ Metrics/PerceivedComplexity:
80
+ Max: 18
81
+
82
+ # Sometimes it's easier to read without guards
83
+ Style/GuardClause:
84
+ Enabled: false
85
+
86
+ # something = if something_else
87
+ # that's confusing
88
+ Style/ConditionalAssignment:
89
+ Enabled: false
90
+
91
+ # Better to have too much self than missing a self
92
+ Style/RedundantSelf:
93
+ Enabled: false
94
+
95
+ Metrics/MethodLength:
96
+ Max: 60
97
+
98
+ # We're not there yet
99
+ Style/Documentation:
100
+ Enabled: false
101
+
102
+ # Adds complexity
103
+ Style/IfInsideElse:
104
+ Enabled: false
105
+
106
+ # danger specific
107
+
108
+ Style/BlockComments:
109
+ Enabled: false
110
+
111
+ Layout/MultilineMethodCallIndentation:
112
+ EnforcedStyle: indented
113
+
114
+ # FIXME: 25
115
+ Metrics/BlockLength:
116
+ Max: 345
117
+ Exclude:
118
+ - "**/*_spec.rb"
119
+
120
+ Style/MixinGrouping:
121
+ Enabled: false
122
+
123
+ Naming/FileName:
124
+ Enabled: false
125
+
126
+ Layout/IndentHeredoc:
127
+ Enabled: false
128
+
129
+ Style/SpecialGlobalVars:
130
+ Enabled: false
131
+
132
+ PercentLiteralDelimiters:
133
+ PreferredDelimiters:
134
+ "%": ()
135
+ "%i": ()
136
+ "%q": ()
137
+ "%Q": ()
138
+ "%r": "{}"
139
+ "%s": ()
140
+ "%w": ()
141
+ "%W": ()
142
+ "%x": ()
143
+
144
+ Security/YAMLLoad:
145
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,34 @@
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.9
12
+ - 2.3.6
13
+ - 2.4.3
14
+ - 2.5.0
15
+ - ruby-head
16
+
17
+ before_install:
18
+ - gem update bundler
19
+
20
+ before_script:
21
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
22
+ - chmod +x ./cc-test-reporter
23
+ - ./cc-test-reporter before-build
24
+
25
+ script:
26
+ - bundle exec rake spec
27
+
28
+ after_script:
29
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
30
+
31
+ matrix:
32
+ allow_failures:
33
+ - rvm: ruby-head
34
+ fast_finish: true
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in danger-slim_lint.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 ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2018 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.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # danger-slim_lint
2
+
3
+ [![Build Status](https://img.shields.io/travis/blooper05/danger-slim_lint.svg?longCache=true&style=flat)](https://travis-ci.org/blooper05/danger-slim_lint)
4
+ [![Dependency Status](https://img.shields.io/gemnasium/blooper05/danger-slim_lint.svg?longCache=true&style=flat)](https://gemnasium.com/blooper05/danger-slim_lint)
5
+ [![Code Climate](https://img.shields.io/codeclimate/maintainability/blooper05/danger-slim_lint.svg?longCache=true&style=flat)](https://codeclimate.com/github/blooper05/danger-slim_lint)
6
+ [![Coverage](https://img.shields.io/codeclimate/c/blooper05/danger-slim_lint.svg?longCache=true&style=flat)](https://codeclimate.com/github/blooper05/danger-slim_lint)
7
+ [![Gem Version](https://img.shields.io/gem/v/danger-slim_lint.svg?longCache=true&style=flat)](https://rubygems.org/gems/danger-slim_lint)
8
+ [![License](https://img.shields.io/github/license/blooper05/danger-slim_lint.svg?longCache=true&style=flat)](https://github.com/blooper05/danger-slim_lint/blob/master/LICENSE)
9
+
10
+ A [Danger](https://rubygems.org/gems/danger) plugin for [slim-lint](https://rubygems.org/gems/slim_lint).
11
+
12
+ ## Installation
13
+
14
+ $ gem install danger-slim_lint
15
+
16
+ ## Usage
17
+
18
+ ### slim_lint
19
+
20
+ Lints Slim files via [slim-lint](https://rubygems.org/gems/slim_lint).
21
+ Results are sent as inline comments.
22
+
23
+ <blockquote>Running slim-lint
24
+ <pre>
25
+ # Runs slim-lint on modified and added files in the PR
26
+ slim_lint.lint</pre>
27
+ </blockquote>
28
+
29
+ #### Methods
30
+
31
+ `lint` - Runs Slim files through slim-lint.
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.
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,51 @@
1
+
2
+ lib = File.expand_path('lib', __dir__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'slim_lint/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'danger-slim_lint'
8
+ spec.version = SlimLint::VERSION
9
+ spec.authors = ['blooper05']
10
+ spec.email = ['legend.of.blooper@gmail.com']
11
+ spec.description = 'A Danger plugin to lint Ruby files through slim-lint.'
12
+ spec.summary = 'A Danger plugin to lint Ruby files through slim-lint.'
13
+ spec.homepage = 'https://github.com/blooper05/danger-slim_lint'
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 'slim_lint' # FIXME
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'
34
+ spec.add_development_dependency 'yard'
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 'slim_lint/plugin'
@@ -0,0 +1 @@
1
+ require 'slim_lint/gem_version'
@@ -0,0 +1,3 @@
1
+ module SlimLint
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,47 @@
1
+ require 'slim_lint'
2
+
3
+ module Danger
4
+ # Lints Slim files via [slim-lint](https://rubygems.org/gems/slim_lint).
5
+ # Results are sent as inline comments.
6
+ #
7
+ # @example Running slim-lint
8
+ #
9
+ # # Runs slim-lint on modified and added files in the PR
10
+ # slim_lint.lint
11
+ #
12
+ # @see blooper05/danger-slim_lint
13
+ # @tags slim, ruby, slim-lint, lint
14
+ class DangerSlimLint < Plugin
15
+ # Runs Slim files through slim-lint.
16
+ # @return [Array<SlimLint::Lint, nil>]
17
+ def lint
18
+ files_to_lint = fetch_files_to_lint
19
+ lint_errors = run_linter(files_to_lint)
20
+ warn_each_line(lint_errors)
21
+ end
22
+
23
+ private
24
+
25
+ def run_linter(files_to_lint)
26
+ runner = ::SlimLint::Runner.new
27
+ runner.run(files: files_to_lint).lints
28
+ end
29
+
30
+ def fetch_files_to_lint
31
+ files = git.modified_files + git.added_files
32
+ files.select do |file|
33
+ ::SlimLint::FileFinder::VALID_EXTENSIONS.include?(File.extname(file))
34
+ end
35
+ end
36
+
37
+ def warn_each_line(lint_errors)
38
+ current_dir = "#{Dir.pwd}/"
39
+ lint_errors.each do |error|
40
+ message = error.message
41
+ file = error.filename.sub(current_dir, '')
42
+ line = error.line
43
+ warn(message, file: file, line: line)
44
+ end
45
+ end
46
+ end
47
+ end
File without changes
File without changes
@@ -0,0 +1,78 @@
1
+ require File.expand_path('spec_helper', __dir__)
2
+
3
+ module Danger
4
+ describe Danger::DangerSlimLint do
5
+ it 'should be a plugin' do
6
+ expect(Danger::DangerSlimLint.new(nil)).to be_a Danger::Plugin
7
+ end
8
+
9
+ describe 'with Dangerfile' do
10
+ let(:dangerfile) { testing_dangerfile }
11
+ let(:slim_lint) { dangerfile.slim_lint }
12
+
13
+ describe '#lint' do
14
+ subject { slim_lint.lint }
15
+
16
+ before { stubbings }
17
+ before { subject }
18
+
19
+ let(:changed_files) do
20
+ git = slim_lint.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) { %w(spec/fixtures/modified_file.slim) }
30
+ let(:added_files) { %w(spec/fixtures/added_file.slim) }
31
+
32
+ context 'with lint errors' do
33
+ let(:stubbings) { changed_files && lint_errors }
34
+
35
+ let(:lint_errors) do
36
+ linter = ::SlimLint::Report
37
+ errors = [double('Lint Errors', message: error_message,
38
+ filename: filename,
39
+ line: line)]
40
+ expect_any_instance_of(linter).to receive(:lints)
41
+ .and_return(errors)
42
+ end
43
+
44
+ let(:error_message) { 'error message' }
45
+ let(:filename) { "#{Dir.pwd}/path/to/file" }
46
+ let(:line) { 123 }
47
+
48
+ it 'returns warning reports' do
49
+ violation = Violation.new(error_message, false, 'path/to/file', 123)
50
+ expect(status_reports).to eq([error_message])
51
+ expect(violation_reports).to eq([violation])
52
+ end
53
+ end
54
+
55
+ context 'with no lint errors' do
56
+ let(:stubbings) { changed_files }
57
+
58
+ it 'returns no warning reports' do
59
+ expect(status_reports).to be_empty
60
+ expect(violation_reports).to be_empty
61
+ end
62
+ end
63
+ end
64
+
65
+ context 'with no changed files' do
66
+ let(:stubbings) { changed_files }
67
+ let(:modified_files) { [] }
68
+ let(:added_files) { [] }
69
+
70
+ it 'returns no warning reports' do
71
+ expect(status_reports).to be_empty
72
+ expect(violation_reports).to be_empty
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,68 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('..', __dir__))
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-slim_lint
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: 2018-03-24 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: slim_lint
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
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'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
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'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
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 slim-lint.
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-slim_lint.gemspec
197
+ - lib/danger_plugin.rb
198
+ - lib/danger_slim_lint.rb
199
+ - lib/slim_lint/gem_version.rb
200
+ - lib/slim_lint/plugin.rb
201
+ - spec/fixtures/added_file.slim
202
+ - spec/fixtures/modified_file.slim
203
+ - spec/slim_lint_spec.rb
204
+ - spec/spec_helper.rb
205
+ homepage: https://github.com/blooper05/danger-slim_lint
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.7.3
226
+ signing_key:
227
+ specification_version: 4
228
+ summary: A Danger plugin to lint Ruby files through slim-lint.
229
+ test_files:
230
+ - spec/fixtures/added_file.slim
231
+ - spec/fixtures/modified_file.slim
232
+ - spec/slim_lint_spec.rb
233
+ - spec/spec_helper.rb