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 +4 -4
- data/Changelog.md +4 -0
- data/lib/danger_plugin.rb +7 -3
- data/lib/version.rb +1 -1
- data/spec/danger_plugin_spec.rb +20 -2
- data/spec/fixtures/some_dir/SwiftFile.swift +1 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dbb13219873521a9e81041978b5800a85229b02
|
4
|
+
data.tar.gz: 6386a741dfb3e982e21374514e019b5b13fee35b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 426c76446fd6ca7f595dfd4f99e97e3f33897e281b0dc983c1f0dc704be1a67950621071bacf643a84eb1907506d59872a0d1117a12a30921c43cf6dfeae3a63
|
7
|
+
data.tar.gz: 68fda7d7df9f604994f0451534fb96d9c686b4e9503bf4ca58c8a97cb68af049a69566be52cbb1940433c3db7b1eb3c8a89d8d709794ba5ec75ea20cf107f400
|
data/Changelog.md
CHANGED
@@ -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).
|
data/lib/danger_plugin.rb
CHANGED
@@ -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:
|
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|
|
data/lib/version.rb
CHANGED
data/spec/danger_plugin_spec.rb
CHANGED
@@ -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
|
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.
|
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
|