danger-swiftformat 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +4 -10
- data/.rubocop.yml +2 -2
- data/Gemfile +1 -1
- data/Gemfile.lock +63 -56
- data/README.md +6 -0
- data/lib/swiftformat/gem_version.rb +1 -1
- data/lib/swiftformat/plugin.rb +39 -12
- data/spec/swiftformat/plugin_spec.rb +13 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eef65e57aabf2cf8d1260a48acbd2394b74d1c359548fe058146fc4161649afe
|
4
|
+
data.tar.gz: c5d8cf5e39e3d9491b41c2ca941163b046d261647b5382659ce62f8cfc778819
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 373c74dd0f0a993945361d74a930560112dd6b4132ab466ad789a609608beb3b0b956fd2782cf473aee0bdef679ded7bb0085649c0c9e6b9f5bfcc86d866193b
|
7
|
+
data.tar.gz: 8ac70d51871ac7b77d6db6b46ac2d68d4f1385617505554a7136c5aa6fb0b747064242fff6496c8443266410394913a306baabe497e0b835728e56f73654afe6
|
data/.github/workflows/ruby.yml
CHANGED
@@ -8,19 +8,13 @@ on:
|
|
8
8
|
|
9
9
|
jobs:
|
10
10
|
test:
|
11
|
-
|
12
11
|
runs-on: ubuntu-latest
|
13
|
-
strategy:
|
14
|
-
matrix:
|
15
|
-
ruby-version: ['2.6', '2.7']
|
16
12
|
|
17
13
|
steps:
|
18
|
-
- uses: actions/checkout@
|
19
|
-
-
|
20
|
-
uses: ruby/setup-ruby@v1
|
14
|
+
- uses: actions/checkout@v4
|
15
|
+
- uses: ruby/setup-ruby@v1
|
21
16
|
with:
|
22
|
-
ruby-version:
|
17
|
+
ruby-version: '3.2'
|
23
18
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
24
19
|
|
25
|
-
-
|
26
|
-
run: bundle exec rake
|
20
|
+
- run: bundle exec rake
|
data/.rubocop.yml
CHANGED
@@ -85,7 +85,7 @@ Metrics/CyclomaticComplexity:
|
|
85
85
|
Max: 17
|
86
86
|
|
87
87
|
# Configuration parameters: AllowURI, URISchemes.
|
88
|
-
|
88
|
+
Layout/LineLength:
|
89
89
|
Max: 370
|
90
90
|
|
91
91
|
# Configuration parameters: CountKeywordArgs.
|
@@ -145,7 +145,7 @@ Layout/HeredocIndentation:
|
|
145
145
|
Style/SpecialGlobalVars:
|
146
146
|
Enabled: false
|
147
147
|
|
148
|
-
PercentLiteralDelimiters:
|
148
|
+
Style/PercentLiteralDelimiters:
|
149
149
|
PreferredDelimiters:
|
150
150
|
"%": ()
|
151
151
|
"%i": ()
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
danger-swiftformat (0.
|
4
|
+
danger-swiftformat (0.9.0)
|
5
5
|
danger-plugin-api (~> 1.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
addressable (2.
|
11
|
-
public_suffix (>= 2.0.2, <
|
10
|
+
addressable (2.8.5)
|
11
|
+
public_suffix (>= 2.0.2, < 6.0)
|
12
12
|
ast (2.4.2)
|
13
|
-
|
13
|
+
base64 (0.2.0)
|
14
|
+
claide (1.1.0)
|
14
15
|
claide-plugins (0.9.2)
|
15
16
|
cork
|
16
17
|
nap
|
@@ -19,37 +20,41 @@ GEM
|
|
19
20
|
colored2 (3.1.2)
|
20
21
|
cork (0.3.0)
|
21
22
|
colored2 (~> 3.1)
|
22
|
-
danger (
|
23
|
+
danger (9.3.2)
|
23
24
|
claide (~> 1.0)
|
24
25
|
claide-plugins (>= 0.9.2)
|
25
26
|
colored2 (~> 3.1)
|
26
27
|
cork (~> 0.1)
|
27
|
-
faraday (>= 0.9.0, <
|
28
|
+
faraday (>= 0.9.0, < 3.0)
|
28
29
|
faraday-http-cache (~> 2.0)
|
29
|
-
git (~> 1.
|
30
|
+
git (~> 1.13)
|
30
31
|
kramdown (~> 2.3)
|
31
32
|
kramdown-parser-gfm (~> 1.0)
|
32
33
|
no_proxy_fix
|
33
|
-
octokit (~>
|
34
|
-
terminal-table (
|
34
|
+
octokit (~> 6.0)
|
35
|
+
terminal-table (>= 1, < 4)
|
35
36
|
danger-plugin-api (1.0.0)
|
36
37
|
danger (> 2.0)
|
37
|
-
diff-lcs (1.
|
38
|
-
faraday (
|
39
|
-
|
40
|
-
|
38
|
+
diff-lcs (1.5.0)
|
39
|
+
faraday (2.7.11)
|
40
|
+
base64
|
41
|
+
faraday-net_http (>= 2.0, < 3.1)
|
42
|
+
ruby2_keywords (>= 0.0.4)
|
43
|
+
faraday-http-cache (2.5.0)
|
41
44
|
faraday (>= 0.8)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
+
faraday-net_http (3.0.2)
|
46
|
+
ffi (1.16.3)
|
47
|
+
formatador (1.1.0)
|
48
|
+
git (1.18.0)
|
49
|
+
addressable (~> 2.8)
|
45
50
|
rchardet (~> 1.8)
|
46
|
-
guard (2.
|
51
|
+
guard (2.18.1)
|
47
52
|
formatador (>= 0.2.4)
|
48
53
|
listen (>= 2.7, < 4.0)
|
49
54
|
lumberjack (>= 1.0.12, < 2.0)
|
50
55
|
nenv (~> 0.1)
|
51
56
|
notiffany (~> 0.0)
|
52
|
-
pry (>= 0.
|
57
|
+
pry (>= 0.13.0)
|
53
58
|
shellany (~> 0.0)
|
54
59
|
thor (>= 0.18.1)
|
55
60
|
guard-compat (1.2.1)
|
@@ -57,54 +62,55 @@ GEM
|
|
57
62
|
guard (~> 2.1)
|
58
63
|
guard-compat (~> 1.1)
|
59
64
|
rspec (>= 2.99.0, < 4.0)
|
60
|
-
kramdown (2.
|
65
|
+
kramdown (2.4.0)
|
61
66
|
rexml
|
62
67
|
kramdown-parser-gfm (1.1.0)
|
63
68
|
kramdown (~> 2.0)
|
64
|
-
listen (3.
|
69
|
+
listen (3.8.0)
|
65
70
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
66
71
|
rb-inotify (~> 0.9, >= 0.9.10)
|
67
|
-
lumberjack (1.2.
|
72
|
+
lumberjack (1.2.9)
|
68
73
|
method_source (1.0.0)
|
69
|
-
multipart-post (2.1.1)
|
70
74
|
nap (1.1.0)
|
71
75
|
nenv (0.3.0)
|
72
76
|
no_proxy_fix (0.1.2)
|
73
77
|
notiffany (0.1.3)
|
74
78
|
nenv (~> 0.1)
|
75
79
|
shellany (~> 0.0)
|
76
|
-
octokit (
|
77
|
-
faraday (>=
|
78
|
-
sawyer (~> 0.
|
80
|
+
octokit (6.1.1)
|
81
|
+
faraday (>= 1, < 3)
|
82
|
+
sawyer (~> 0.9)
|
79
83
|
open4 (1.3.4)
|
80
|
-
parallel (1.
|
81
|
-
parser (3.
|
84
|
+
parallel (1.23.0)
|
85
|
+
parser (3.2.2.4)
|
82
86
|
ast (~> 2.4.1)
|
83
|
-
|
87
|
+
racc
|
88
|
+
pry (0.14.2)
|
84
89
|
coderay (~> 1.1)
|
85
90
|
method_source (~> 1.0)
|
86
|
-
public_suffix (
|
87
|
-
|
91
|
+
public_suffix (5.0.3)
|
92
|
+
racc (1.7.3)
|
93
|
+
rainbow (3.1.1)
|
88
94
|
rake (12.3.3)
|
89
|
-
rb-fsevent (0.
|
95
|
+
rb-fsevent (0.11.2)
|
90
96
|
rb-inotify (0.10.1)
|
91
97
|
ffi (~> 1.0)
|
92
98
|
rchardet (1.8.0)
|
93
|
-
regexp_parser (2.
|
94
|
-
rexml (3.2.
|
95
|
-
rspec (3.
|
96
|
-
rspec-core (~> 3.
|
97
|
-
rspec-expectations (~> 3.
|
98
|
-
rspec-mocks (~> 3.
|
99
|
-
rspec-core (3.
|
100
|
-
rspec-support (~> 3.
|
101
|
-
rspec-expectations (3.
|
99
|
+
regexp_parser (2.8.2)
|
100
|
+
rexml (3.2.6)
|
101
|
+
rspec (3.12.0)
|
102
|
+
rspec-core (~> 3.12.0)
|
103
|
+
rspec-expectations (~> 3.12.0)
|
104
|
+
rspec-mocks (~> 3.12.0)
|
105
|
+
rspec-core (3.12.2)
|
106
|
+
rspec-support (~> 3.12.0)
|
107
|
+
rspec-expectations (3.12.3)
|
102
108
|
diff-lcs (>= 1.2.0, < 2.0)
|
103
|
-
rspec-support (~> 3.
|
104
|
-
rspec-mocks (3.
|
109
|
+
rspec-support (~> 3.12.0)
|
110
|
+
rspec-mocks (3.12.6)
|
105
111
|
diff-lcs (>= 1.2.0, < 2.0)
|
106
|
-
rspec-support (~> 3.
|
107
|
-
rspec-support (3.
|
112
|
+
rspec-support (~> 3.12.0)
|
113
|
+
rspec-support (3.12.1)
|
108
114
|
rubocop (0.93.1)
|
109
115
|
parallel (~> 1.10)
|
110
116
|
parser (>= 2.7.1.5)
|
@@ -114,18 +120,19 @@ GEM
|
|
114
120
|
rubocop-ast (>= 0.6.0)
|
115
121
|
ruby-progressbar (~> 1.7)
|
116
122
|
unicode-display_width (>= 1.4.0, < 2.0)
|
117
|
-
rubocop-ast (1.
|
118
|
-
parser (>= 2.
|
119
|
-
ruby-progressbar (1.
|
120
|
-
|
123
|
+
rubocop-ast (1.30.0)
|
124
|
+
parser (>= 3.2.1.0)
|
125
|
+
ruby-progressbar (1.13.0)
|
126
|
+
ruby2_keywords (0.0.5)
|
127
|
+
sawyer (0.9.2)
|
121
128
|
addressable (>= 2.3.5)
|
122
|
-
faraday (
|
129
|
+
faraday (>= 0.17.3, < 3)
|
123
130
|
shellany (0.0.1)
|
124
|
-
terminal-table (
|
125
|
-
unicode-display_width (
|
126
|
-
thor (1.
|
127
|
-
unicode-display_width (1.
|
128
|
-
yard (0.9.
|
131
|
+
terminal-table (3.0.2)
|
132
|
+
unicode-display_width (>= 1.1.1, < 3)
|
133
|
+
thor (1.3.0)
|
134
|
+
unicode-display_width (1.8.0)
|
135
|
+
yard (0.9.34)
|
129
136
|
|
130
137
|
PLATFORMS
|
131
138
|
ruby
|
@@ -133,7 +140,7 @@ PLATFORMS
|
|
133
140
|
DEPENDENCIES
|
134
141
|
bundler (~> 2.1)
|
135
142
|
danger-swiftformat!
|
136
|
-
faraday (=
|
143
|
+
faraday (= 2.7.11)
|
137
144
|
guard (~> 2.14)
|
138
145
|
guard-rspec (~> 4.7)
|
139
146
|
listen (~> 3.1)
|
@@ -144,4 +151,4 @@ DEPENDENCIES
|
|
144
151
|
yard (~> 0.9)
|
145
152
|
|
146
153
|
BUNDLED WITH
|
147
|
-
2.
|
154
|
+
2.4.22
|
data/README.md
CHANGED
@@ -63,6 +63,12 @@ certain directories or files such as `Pods`, you can use the `exclude` parameter
|
|
63
63
|
swiftformat.exclude = %w(Pods/** Carthage/** Sources/Nope.swift **/*_autogenerated.swift)
|
64
64
|
```
|
65
65
|
|
66
|
+
If you want the format results shows in the diff instead of a comment, you can use the `inline_mode` option. Violations that are out of the diff will be shown in danger's fail or warn section:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
swiftformat.inline_mode = true
|
70
|
+
```
|
71
|
+
|
66
72
|
The `exclude` option takes an array of glob patterns; you can find additional documentation on the patterns
|
67
73
|
[here](https://ruby-doc.org/core-2.6.3/File.html#method-c-fnmatch).
|
68
74
|
|
data/lib/swiftformat/plugin.rb
CHANGED
@@ -34,6 +34,11 @@ module Danger
|
|
34
34
|
# @return [String]
|
35
35
|
attr_accessor :swiftversion
|
36
36
|
|
37
|
+
# Show issues inline in the diff instead of in a comment.
|
38
|
+
#
|
39
|
+
# @return [Boolean]
|
40
|
+
attr_accessor :inline_mode
|
41
|
+
|
37
42
|
# Runs swiftformat
|
38
43
|
#
|
39
44
|
# @param [Boolean] fail_on_error
|
@@ -56,20 +61,24 @@ module Danger
|
|
56
61
|
# Stop processing if the errors array is empty
|
57
62
|
return if results[:errors].empty?
|
58
63
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
message << "|
|
64
|
+
if inline_mode
|
65
|
+
send_inline_comment(results, fail_on_error ? :fail : :warn)
|
66
|
+
else
|
67
|
+
# Process the errors
|
68
|
+
message = "### SwiftFormat found issues:\n\n"
|
69
|
+
message << "| File | Rules |\n"
|
70
|
+
message << "| ---- | ----- |\n"
|
71
|
+
results[:errors].each do |error|
|
72
|
+
message << "| #{error[:file].gsub("#{Dir.pwd}/", '')} | #{error[:rules].join(', ')} |\n"
|
73
|
+
end
|
74
|
+
|
75
|
+
unless additional_message.nil?
|
76
|
+
message << "\n" << additional_message
|
77
|
+
end
|
78
|
+
|
79
|
+
markdown message
|
65
80
|
end
|
66
81
|
|
67
|
-
unless additional_message.nil?
|
68
|
-
message << "\n" << additional_message
|
69
|
-
end
|
70
|
-
|
71
|
-
markdown message
|
72
|
-
|
73
82
|
if fail_on_error
|
74
83
|
fail "SwiftFormat found issues"
|
75
84
|
end
|
@@ -95,6 +104,24 @@ module Danger
|
|
95
104
|
.sort
|
96
105
|
end
|
97
106
|
|
107
|
+
# Send inline comment with danger's warn or fail method
|
108
|
+
#
|
109
|
+
# @return [void]
|
110
|
+
def send_inline_comment(results, method)
|
111
|
+
results[:errors].each do |error|
|
112
|
+
file = error[:file]
|
113
|
+
file_components = file.split(":")
|
114
|
+
line = file_components[1]
|
115
|
+
filename = file_components.first.split("/").last
|
116
|
+
file_path = file_components.first
|
117
|
+
|
118
|
+
message = error[:rules].join(", ").to_s.dup
|
119
|
+
message << " `#{filename}:#{line}`" # file:line for pasting into Xcode Quick Open
|
120
|
+
|
121
|
+
send(method, message, file: file_path, line: line)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
98
125
|
# Constructs the SwiftFormat class
|
99
126
|
#
|
100
127
|
# @return [SwiftFormat]
|
@@ -211,6 +211,19 @@ module Danger
|
|
211
211
|
status = @sut.status_report
|
212
212
|
expect(status[:errors]).to be_empty
|
213
213
|
expect(status[:markdowns]).to_not be_empty
|
214
|
+
expect(status[:warnings]).to be_empty
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should send inline comments when inline_mode is true" do
|
218
|
+
@sut.inline_mode = true
|
219
|
+
|
220
|
+
@sut.check_format
|
221
|
+
|
222
|
+
status = @sut.status_report
|
223
|
+
p status
|
224
|
+
expect(status[:errors]).to be_empty
|
225
|
+
expect(status[:markdowns]).to be_empty
|
226
|
+
expect(status[:warnings]).to_not be_empty
|
214
227
|
end
|
215
228
|
end
|
216
229
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-swiftformat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Garrigues
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|
@@ -188,7 +188,7 @@ licenses:
|
|
188
188
|
- MIT
|
189
189
|
metadata:
|
190
190
|
github_repo: ssh://github.com/garriguv/danger-ruby-swiftformat
|
191
|
-
post_install_message:
|
191
|
+
post_install_message:
|
192
192
|
rdoc_options: []
|
193
193
|
require_paths:
|
194
194
|
- lib
|
@@ -203,8 +203,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
203
|
- !ruby/object:Gem::Version
|
204
204
|
version: '0'
|
205
205
|
requirements: []
|
206
|
-
rubygems_version: 3.
|
207
|
-
signing_key:
|
206
|
+
rubygems_version: 3.4.10
|
207
|
+
signing_key:
|
208
208
|
specification_version: 4
|
209
209
|
summary: A danger plugin for checking Swift formatting using SwiftFormat.
|
210
210
|
test_files:
|