danger-swiftlint 0.8.0 → 0.9.0

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: f3b820ec6ebe7d24aa08c97887544ab8616e1bd0
4
- data.tar.gz: 114dd0c769d754f3d93be4bcc0f30785d018694d
3
+ metadata.gz: 6dbb13219873521a9e81041978b5800a85229b02
4
+ data.tar.gz: 6386a741dfb3e982e21374514e019b5b13fee35b
5
5
  SHA512:
6
- metadata.gz: 774bbbdbed22fe7159db897f198df1eed4b381369b837108260d6dfa2838168e6fc1f216c8ad4d858803f0b312d620b782a116ca9f6cfd460fda62edb8aea2aa
7
- data.tar.gz: 4e85ea6784227a0e1a714b6aa3373b8dc197fee3f62e4ec042160815b3676026bd327116f7159270962ef166ffef9fafe6cf9140ee0ed407170dd62091f3d34d
6
+ metadata.gz: 426c76446fd6ca7f595dfd4f99e97e3f33897e281b0dc983c1f0dc704be1a67950621071bacf643a84eb1907506d59872a0d1117a12a30921c43cf6dfeae3a63
7
+ data.tar.gz: 68fda7d7df9f604994f0451534fb96d9c686b4e9503bf4ca58c8a97cb68af049a69566be52cbb1940433c3db7b1eb3c8a89d8d709794ba5ec75ea20cf107f400
@@ -4,6 +4,10 @@
4
4
 
5
5
  - Nothing yet!
6
6
 
7
+ ## 0.9.0
8
+
9
+ - Fixes linting of superfluous files in subdirectories. See [#53](https://github.com/ashfurrow/danger-swiftlint/pull/53).
10
+
7
11
  ## 0.8.0
8
12
 
9
13
  - Fixes Directory not found error. See [#51](https://github.com/ashfurrow/danger-swiftlint/pull/51).
@@ -47,19 +47,21 @@ module Danger
47
47
  else
48
48
  nil
49
49
  end
50
+
51
+ dir_selected = directory ? File.expand_path(directory) : Dir.pwd
50
52
 
51
53
  # Extract excluded paths
52
54
  excluded_paths = excluded_files_from_config(config)
53
55
 
54
56
  # Extract swift files (ignoring excluded ones)
55
- files = find_swift_files(files, excluded_paths)
57
+ files = find_swift_files(files, excluded_paths, dir_selected)
56
58
 
57
59
  # Prepare swiftlint options
58
60
  options = {
59
61
  config: config,
60
62
  reporter: 'json',
61
63
  quiet: true,
62
- pwd: directory ? File.expand_path(directory) : Dir.pwd
64
+ pwd: dir_selected
63
65
  }
64
66
 
65
67
  # Lint each file and collect the results
@@ -105,7 +107,7 @@ module Danger
105
107
  # If files are not provided it will use git modifield and added files
106
108
  #
107
109
  # @return [Array] swift files
108
- def find_swift_files(files=nil, excluded_paths=[])
110
+ def find_swift_files(files=nil, excluded_paths=[], dir_selected)
109
111
  # Assign files to lint
110
112
  files = files ? Dir.glob(files) : (git.modified_files - git.deleted_files) + git.added_files
111
113
 
@@ -118,6 +120,8 @@ module Danger
118
120
  # Remove dups
119
121
  uniq.
120
122
  map { |file| File.expand_path(file) }.
123
+ # Ensure only files in the selected directory
124
+ select { |file| file.start_with?(dir_selected) }.
121
125
  # Reject files excluded on configuration
122
126
  reject { |file|
123
127
  excluded_paths.any? { |excluded_path|
@@ -1,4 +1,4 @@
1
1
  module DangerSwiftlint
2
- VERSION = "0.8.0".freeze
2
+ VERSION = "0.9.0".freeze
3
3
  SWIFTLINT_VERSION = "0.20.1".freeze
4
4
  end
@@ -68,16 +68,34 @@ module Danger
68
68
  end
69
69
 
70
70
  it 'uses a custom directory' do
71
- @swiftlint.directory = 'some_dir'
71
+ @swiftlint.directory = 'spec/fixtures/some_dir'
72
72
 
73
73
  allow_any_instance_of(Swiftlint).to receive(:lint)
74
74
  .with(hash_including(:pwd => File.expand_path(@swiftlint.directory)))
75
75
  .and_return(@swiftlint_response)
76
76
 
77
- @swiftlint.lint_files("spec/fixtures/*.swift")
77
+ @swiftlint.lint_files(["spec/fixtures/some_dir/SwiftFile.swift"])
78
78
 
79
79
  output = @swiftlint.status_report[:markdowns].first.to_s
80
80
  expect(output).to_not be_empty
81
+
82
+ end
83
+
84
+ it 'only lint files specified in custom dir' do
85
+ @swiftlint.directory = 'spec/fixtures/some_dir'
86
+
87
+ allow(@swiftlint.git).to receive(:added_files).and_return([])
88
+ allow(@swiftlint.git).to receive(:modified_files).and_return([
89
+ 'spec/fixtures/some_dir/SwiftFile.swift',
90
+ 'spec/fixtures/SwiftFile.swift'
91
+ ])
92
+
93
+ expect_any_instance_of(Swiftlint).to receive(:lint)
94
+ .with(hash_including(:path => File.expand_path('spec/fixtures/some_dir/SwiftFile.swift')))
95
+ .once
96
+ .and_return(@swiftlint_response)
97
+
98
+ @swiftlint.lint_files
81
99
  end
82
100
 
83
101
  it 'does not crash if JSON reporter returns an empty string rather than an object' do
@@ -0,0 +1 @@
1
+ // This file intentional left blank-ish.
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.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ash Furrow
@@ -174,6 +174,7 @@ files:
174
174
  - spec/fixtures/excluded_dir/SwiftFile WithEscaped+CharactersThatShouldNotBeIncluded.swift
175
175
  - spec/fixtures/excluded_dir/SwiftFileThatShouldNotBeIncluded.swift
176
176
  - spec/fixtures/some_config.yml
177
+ - spec/fixtures/some_dir/SwiftFile.swift
177
178
  - spec/spec_helper.rb
178
179
  - spec/swiftlint_spec.rb
179
180
  homepage: https://github.com/ashfurrow/danger-swiftlint
@@ -207,5 +208,6 @@ test_files:
207
208
  - spec/fixtures/excluded_dir/SwiftFile WithEscaped+CharactersThatShouldNotBeIncluded.swift
208
209
  - spec/fixtures/excluded_dir/SwiftFileThatShouldNotBeIncluded.swift
209
210
  - spec/fixtures/some_config.yml
211
+ - spec/fixtures/some_dir/SwiftFile.swift
210
212
  - spec/spec_helper.rb
211
213
  - spec/swiftlint_spec.rb