danger-swiftlint 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45256bbc01984eff36a6cf720d67107645266af9
4
- data.tar.gz: 240ceace20e2aa1fc123af81b818843c16dcf2ed
3
+ metadata.gz: b673a12b035e24daddf4915729da974602975f99
4
+ data.tar.gz: edd6a4eb9fd5bb1a8a9dd08da756c13e8a5a58ba
5
5
  SHA512:
6
- metadata.gz: 9b0169c3e7df727a1f5b00bc6199c95342ab4ab6aabc7662af24a3235074de8154624cf753260d9c191b2d2adc11cc0e873c6551562c54976315a53431768a46
7
- data.tar.gz: 1471ed2849802043844808db74261b518dafe17cc76e82b240092751279b4ce9f5ca834526bc46020c790f24bf8ac1ba254670b93008643c833c74ff6bfa26cc
6
+ metadata.gz: 002d49f84c99347a74976ea6bdd45ab4507819db78065171446247481abed27986480af1af6280226b65a6f3f26df6ec7c4d9fb94f13274e16b73c7ee7dd755d
7
+ data.tar.gz: 533e487912bda9b981e9ac2354eba7c44a9e3f7ab6af20f3692886eb907fefe36defd49b2cc118d470b5247c85455424a0ebba77d360cb046ebb2733a0018abd
data/Changelog.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Current Master
4
4
 
5
+ ## 0.4.1
6
+
7
+ - Fixes deleted files being added to the list of files to lint. See [#34](https://github.com/ashfurrow/danger-swiftlint/pull/34).
8
+
5
9
  ## 0.4.0
6
10
 
7
11
  - Support for inline comments. See [#29](https://github.com/ashfurrow/danger-swiftlint/issues/28)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-swiftlint (0.4.0)
4
+ danger-swiftlint (0.4.1)
5
5
  danger
6
6
  rake (~> 10.0)
7
7
  thor (~> 0.19)
data/lib/danger_plugin.rb CHANGED
@@ -80,7 +80,7 @@ module Danger
80
80
  def run_swiftlint(files, options)
81
81
  files
82
82
  .map { |file| options.merge({path: file})}
83
- .map { |options| Swiftlint.lint(options)}
83
+ .map { |full_options| Swiftlint.lint(full_options)}
84
84
  .reject { |s| s == '' }
85
85
  .map { |s| JSON.parse(s).flatten }
86
86
  .flatten
@@ -92,7 +92,7 @@ module Danger
92
92
  # @return [Array] swift files
93
93
  def find_swift_files(files=nil, excluded_files=[])
94
94
  # Assign files to lint
95
- files = files ? Dir.glob(files) : git.modified_files + git.added_files
95
+ files = files ? Dir.glob(files) : (git.modified_files - git.deleted_files) + git.added_files
96
96
 
97
97
  # Filter files to lint
98
98
  return files.
@@ -102,9 +102,10 @@ module Danger
102
102
  map { |file| Shellwords.escape(file) }.
103
103
  # Remove dups
104
104
  uniq.
105
+ map { |file| File.expand_path(file) }.
105
106
  # Reject files excluded on configuration
106
107
  reject { |file|
107
- excluded_files.any? { |excluded| Find.find(excluded).include?(File.expand_path(file)) }
108
+ excluded_files.any? { |excluded| Find.find(excluded).include?(file) }
108
109
  }
109
110
  end
110
111
 
data/lib/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module DangerSwiftlint
2
- VERSION = "0.4.0".freeze
2
+ VERSION = "0.4.1".freeze
3
3
  SWIFTLINT_VERSION = "0.16.1".freeze
4
4
  end
@@ -9,6 +9,7 @@ module Danger
9
9
  describe 'with Dangerfile' do
10
10
  before do
11
11
  @swiftlint = testing_dangerfile.swiftlint
12
+ allow(@swiftlint.git).to receive(:deleted_files).and_return([])
12
13
  end
13
14
 
14
15
  it "handles swiftlint not being installed" do
@@ -32,7 +33,7 @@ module Danger
32
33
 
33
34
  it 'accept files as arguments' do
34
35
  expect(Swiftlint).to receive(:lint)
35
- .with(hash_including(:path => 'spec/fixtures/SwiftFile.swift'))
36
+ .with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')))
36
37
  .and_return(@swiftlint_response)
37
38
 
38
39
  @swiftlint.lint_files("spec/fixtures/*.swift")
@@ -46,7 +47,7 @@ module Danger
46
47
  allow(@swiftlint.git).to receive(:modified_files).and_return(['spec/fixtures/SwiftFile.swift'])
47
48
  allow(@swiftlint.git).to receive(:added_files).and_return([])
48
49
  allow(Swiftlint).to receive(:lint)
49
- .with(hash_including(:path => 'spec/fixtures/SwiftFile.swift'))
50
+ .with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')))
50
51
  .and_return(@swiftlint_response)
51
52
 
52
53
  @swiftlint.lint_files
@@ -94,7 +95,7 @@ module Danger
94
95
  ])
95
96
 
96
97
  expect(Swiftlint).to receive(:lint)
97
- .with(hash_including(:path => 'spec/fixtures/SwiftFile.swift'))
98
+ .with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')))
98
99
  .and_return(@swiftlint_response)
99
100
  .once
100
101
 
@@ -102,9 +103,31 @@ module Danger
102
103
  @swiftlint.lint_files
103
104
  end
104
105
 
106
+ it 'does not lint deleted files paths' do
107
+ # Danger (4.3.0 at the time of writing) returns deleted files in the
108
+ # modified fiels array, which kinda makes sense.
109
+ # At linting time though deleted files should not be linted because
110
+ # they'd result in file not found errors.
111
+ allow(@swiftlint.git).to receive(:added_files).and_return([])
112
+ allow(@swiftlint.git).to receive(:modified_files).and_return([
113
+ 'spec/fixtures/SwiftFile.swift',
114
+ 'spec/fixtures/DeletedFile.swift'
115
+ ])
116
+ allow(@swiftlint.git).to receive(:deleted_files).and_return([
117
+ 'spec/fixtures/DeletedFile.swift'
118
+ ])
119
+
120
+ expect(Swiftlint).to receive(:lint)
121
+ .with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')))
122
+ .and_return(@swiftlint_response)
123
+ .once
124
+
125
+ @swiftlint.lint_files
126
+ end
127
+
105
128
  it 'generates errors instead of markdown when use inline mode' do
106
129
  allow(Swiftlint).to receive(:lint)
107
- .with(hash_including(:path => 'spec/fixtures/SwiftFile.swift'))
130
+ .with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')))
108
131
  .and_return(@swiftlint_response)
109
132
 
110
133
  @swiftlint.lint_files("spec/fixtures/*.swift", inline_mode: true)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-swiftlint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ash Furrow
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2017-03-14 00:00:00.000000000 Z
15
+ date: 2017-04-11 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: danger