danger-swiftformat 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4725bb4b3e493d619b7bcc38c909823aa6d014a31fe938341f8488a40690e8ce
4
- data.tar.gz: 7ea2c85afac6d489fc255f0618e0e02002feba04e59f50df23374cab5c6e2a3b
3
+ metadata.gz: 7c9b3279bd74c07c0484451302265163c566fb8cf833ee02f11d19c718452a08
4
+ data.tar.gz: b36e4a5b90fff935710634fa63d743b9a538b60830df7fd7b0bdf854dc3b461f
5
5
  SHA512:
6
- metadata.gz: fb8be55f45b39b9b2a7f7adee5a1f4cfbfb87b029cf36a6cc2ca69a27885ce1a3c9009d9de687202e4e071dd8174f1ee623c3725570401c949add0f841ce162a
7
- data.tar.gz: 8d78eb43d9e124cdd39b70521ac0b7583e17fa32851928cd72aeb9ab3d40bd3a6fb96536d797585e68d4ebfc8dfb657f949490502fb04e6d75dd8868419bf1a8
6
+ metadata.gz: 040feb0a05ffa56ac333620d1a162cfdc660743e0ff3dc26ba6223a437e4fab52b218c23d89c3bc6ff889793887ced05dc45e1f68b411f4184d2df698f58aacf
7
+ data.tar.gz: 44ab68d8cbd5b545bab694b4463c2232c269a5ab1bb6e5295c59f82d98f9f15445b3993bd96e4323babde11c1acc6b8b160ff44d7b33cf48b013c0b67f22c324
@@ -3,7 +3,7 @@
3
3
  # If you don't like these settings, just delete this file :)
4
4
 
5
5
  AllCops:
6
- TargetRubyVersion: 2.2
6
+ TargetRubyVersion: 2.3
7
7
 
8
8
  Style/StringLiterals:
9
9
  EnforcedStyle: double_quotes
@@ -23,7 +23,7 @@ Lint/UselessAssignment:
23
23
  - '**/spec/**/*'
24
24
 
25
25
  # We could potentially enable the 2 below:
26
- Layout/IndentHash:
26
+ Layout/IndentFirstHashElement:
27
27
  Enabled: false
28
28
 
29
29
  Layout/AlignHash:
@@ -37,6 +37,9 @@ Layout/DotPosition:
37
37
  Style/DoubleNegation:
38
38
  Enabled: false
39
39
 
40
+ Style/FrozenStringLiteralComment:
41
+ Enabled: false
42
+
40
43
  # Cop supports --auto-correct.
41
44
  Lint/UnusedBlockArgument:
42
45
  Enabled: false
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-swiftformat (0.5.0)
4
+ danger-swiftformat (0.6.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.5.2)
10
+ addressable (2.6.0)
11
11
  public_suffix (>= 2.0.2, < 4.0)
12
12
  ast (2.4.0)
13
13
  claide (1.0.2)
@@ -19,13 +19,13 @@ GEM
19
19
  colored2 (3.1.2)
20
20
  cork (0.3.0)
21
21
  colored2 (~> 3.1)
22
- danger (6.0.6)
22
+ danger (6.0.9)
23
23
  claide (~> 1.0)
24
24
  claide-plugins (>= 0.9.2)
25
25
  colored2 (~> 3.1)
26
26
  cork (~> 0.1)
27
27
  faraday (~> 0.9)
28
- faraday-http-cache (~> 1.0)
28
+ faraday-http-cache (~> 2.0)
29
29
  git (~> 1.5)
30
30
  kramdown (~> 2.0)
31
31
  kramdown-parser-gfm (~> 1.0)
@@ -37,9 +37,9 @@ GEM
37
37
  diff-lcs (1.3)
38
38
  faraday (0.15.4)
39
39
  multipart-post (>= 1.2, < 3)
40
- faraday-http-cache (1.3.1)
40
+ faraday-http-cache (2.0.0)
41
41
  faraday (~> 0.8)
42
- ffi (1.10.0)
42
+ ffi (1.11.1)
43
43
  formatador (0.2.5)
44
44
  git (1.5.0)
45
45
  guard (2.15.0)
@@ -56,9 +56,9 @@ GEM
56
56
  guard (~> 2.1)
57
57
  guard-compat (~> 1.1)
58
58
  rspec (>= 2.99.0, < 4.0)
59
- jaro_winkler (1.5.2)
59
+ jaro_winkler (1.5.3)
60
60
  kramdown (2.1.0)
61
- kramdown-parser-gfm (1.0.1)
61
+ kramdown-parser-gfm (1.1.0)
62
62
  kramdown (~> 2.0)
63
63
  listen (3.1.5)
64
64
  rb-fsevent (~> 0.9, >= 0.9.4)
@@ -66,7 +66,7 @@ GEM
66
66
  ruby_dep (~> 1.2)
67
67
  lumberjack (1.0.13)
68
68
  method_source (0.9.2)
69
- multipart-post (2.0.0)
69
+ multipart-post (2.1.1)
70
70
  nap (1.1.0)
71
71
  nenv (0.3.0)
72
72
  no_proxy_fix (0.1.2)
@@ -77,15 +77,14 @@ GEM
77
77
  sawyer (~> 0.8.0, >= 0.5.3)
78
78
  open4 (1.3.4)
79
79
  parallel (1.17.0)
80
- parser (2.6.2.1)
80
+ parser (2.6.3.0)
81
81
  ast (~> 2.4.0)
82
82
  pry (0.12.2)
83
83
  coderay (~> 1.1.0)
84
84
  method_source (~> 0.9.0)
85
- psych (3.1.0)
86
- public_suffix (3.0.3)
85
+ public_suffix (3.1.1)
87
86
  rainbow (3.0.0)
88
- rake (12.3.2)
87
+ rake (12.3.3)
89
88
  rb-fsevent (0.10.3)
90
89
  rb-inotify (0.10.0)
91
90
  ffi (~> 1.0)
@@ -93,34 +92,33 @@ GEM
93
92
  rspec-core (~> 3.8.0)
94
93
  rspec-expectations (~> 3.8.0)
95
94
  rspec-mocks (~> 3.8.0)
96
- rspec-core (3.8.0)
95
+ rspec-core (3.8.2)
97
96
  rspec-support (~> 3.8.0)
98
- rspec-expectations (3.8.3)
97
+ rspec-expectations (3.8.4)
99
98
  diff-lcs (>= 1.2.0, < 2.0)
100
99
  rspec-support (~> 3.8.0)
101
- rspec-mocks (3.8.0)
100
+ rspec-mocks (3.8.1)
102
101
  diff-lcs (>= 1.2.0, < 2.0)
103
102
  rspec-support (~> 3.8.0)
104
- rspec-support (3.8.0)
105
- rubocop (0.67.2)
103
+ rspec-support (3.8.2)
104
+ rubocop (0.73.0)
106
105
  jaro_winkler (~> 1.5.1)
107
106
  parallel (~> 1.10)
108
- parser (>= 2.5, != 2.5.1.1)
109
- psych (>= 3.1.0)
107
+ parser (>= 2.6)
110
108
  rainbow (>= 2.2.2, < 4.0)
111
109
  ruby-progressbar (~> 1.7)
112
- unicode-display_width (>= 1.4.0, < 1.6)
113
- ruby-progressbar (1.10.0)
110
+ unicode-display_width (>= 1.4.0, < 1.7)
111
+ ruby-progressbar (1.10.1)
114
112
  ruby_dep (1.5.0)
115
- sawyer (0.8.1)
116
- addressable (>= 2.3.5, < 2.6)
117
- faraday (~> 0.8, < 1.0)
113
+ sawyer (0.8.2)
114
+ addressable (>= 2.3.5)
115
+ faraday (> 0.8, < 2.0)
118
116
  shellany (0.0.1)
119
117
  terminal-table (1.8.0)
120
118
  unicode-display_width (~> 1.1, >= 1.1.1)
121
119
  thor (0.20.3)
122
- unicode-display_width (1.5.0)
123
- yard (0.9.19)
120
+ unicode-display_width (1.6.0)
121
+ yard (0.9.20)
124
122
 
125
123
  PLATFORMS
126
124
  ruby
@@ -1,3 +1,3 @@
1
1
  module Swiftformat
2
- VERSION = "0.5.0".freeze
2
+ VERSION = "0.6.0".freeze
3
3
  end
@@ -74,7 +74,12 @@ module Danger
74
74
  #
75
75
  # @return [Array<String]
76
76
  def find_swift_files
77
- files = (git.modified_files - git.deleted_files) + git.added_files
77
+ renamed_files_hash = git.renamed_files.map { |rename| [rename[:before], rename[:after]] }.to_h
78
+
79
+ post_rename_modified_files = git.modified_files
80
+ .map { |modified_file| renamed_files_hash[modified_file] || modified_file }
81
+
82
+ files = (post_rename_modified_files - git.deleted_files) + git.added_files
78
83
 
79
84
  @exclude = %w() if @exclude.nil?
80
85
 
@@ -39,6 +39,7 @@ module Danger
39
39
  allow(@sut.git).to receive(:added_files).and_return(["Added.swift"])
40
40
  allow(@sut.git).to receive(:modified_files).and_return(["Modified.swift"])
41
41
  allow(@sut.git).to receive(:deleted_files).and_return(["Deleted.swift"])
42
+ allow(@sut.git).to receive(:renamed_files).and_return([{}])
42
43
  allow_any_instance_of(SwiftFormat).to receive(:installed?).and_return(true)
43
44
  allow_any_instance_of(SwiftFormat).to receive(:check_format)
44
45
  .with(%w(Added.swift Modified.swift), additional_args)
@@ -62,6 +63,7 @@ module Danger
62
63
  allow(@sut.git).to receive(:added_files).and_return(["Added.swift"])
63
64
  allow(@sut.git).to receive(:modified_files).and_return(["Modified.swift"])
64
65
  allow(@sut.git).to receive(:deleted_files).and_return(["Deleted.swift"])
66
+ allow(@sut.git).to receive(:renamed_files).and_return([{}])
65
67
  allow_any_instance_of(SwiftFormat).to receive(:installed?).and_return(true)
66
68
  allow_any_instance_of(SwiftFormat).to receive(:check_format).with(%w(Added.swift Modified.swift), nil).and_return(error_output)
67
69
  @sut.additional_message = additional_message
@@ -81,6 +83,7 @@ module Danger
81
83
  allow(@sut.git).to receive(:added_files).and_return(%w(Added.swift Pods/Test.swift Carthage/SQLite.swift Sources/Module/JSONParsing_autogenerated.swift))
82
84
  allow(@sut.git).to receive(:modified_files).and_return(["Source/Modified.swift"])
83
85
  allow(@sut.git).to receive(:deleted_files).and_return(["Deleted.swift"])
86
+ allow(@sut.git).to receive(:renamed_files).and_return([{}])
84
87
  allow_any_instance_of(SwiftFormat).to receive(:installed?).and_return(true)
85
88
  allow_any_instance_of(SwiftFormat).to receive(:check_format)
86
89
  .with(%w(Added.swift), nil)
@@ -96,6 +99,30 @@ module Danger
96
99
  end
97
100
  end
98
101
 
102
+ context "with renamed files" do
103
+ let(:additional_args) { "--indent tab --self insert" }
104
+ let(:success_output) { { errors: [], stats: { run_time: "0.08s" } } }
105
+
106
+ it "should use the post-rename filename" do
107
+ allow(@sut.git).to receive(:added_files).and_return(["Added.swift"])
108
+ allow(@sut.git).to receive(:modified_files).and_return(["ModifiedBefore.swift"])
109
+ allow(@sut.git).to receive(:deleted_files).and_return(["Deleted.swift"])
110
+ allow(@sut.git).to receive(:renamed_files).and_return([{ before: "ModifiedBefore.swift", after: "ModifiedAfter.swift" }])
111
+ allow_any_instance_of(SwiftFormat).to receive(:installed?).and_return(true)
112
+ allow_any_instance_of(SwiftFormat).to receive(:check_format)
113
+ .with(%w(Added.swift ModifiedAfter.swift), additional_args)
114
+ .and_return(success_output)
115
+
116
+ @sut.additional_args = additional_args
117
+
118
+ @sut.check_format(fail_on_error: true)
119
+
120
+ status = @sut.status_report
121
+ expect(status[:errors]).to be_empty
122
+ expect(status[:markdowns]).to be_empty
123
+ end
124
+ end
125
+
99
126
  describe "#check_format" do
100
127
  let(:success_output) { { errors: [], stats: { run_time: "0.08s" } } }
101
128
  let(:error_output) { { errors: [{ file: "Modified.swift", rules: %w(firstRule secondRule) }], stats: { run_time: "0.16s" } } }
@@ -106,6 +133,7 @@ module Danger
106
133
  allow(@sut.git).to receive(:added_files).and_return(["Added.m"])
107
134
  allow(@sut.git).to receive(:modified_files).and_return(["Modified.m"])
108
135
  allow(@sut.git).to receive(:deleted_files).and_return(["Deleted.m"])
136
+ allow(@sut.git).to receive(:renamed_files).and_return([{}])
109
137
  end
110
138
 
111
139
  it "should not do anything" do
@@ -123,6 +151,7 @@ module Danger
123
151
  allow(@sut.git).to receive(:added_files).and_return(["Added.swift"])
124
152
  allow(@sut.git).to receive(:modified_files).and_return(["Modified.swift"])
125
153
  allow(@sut.git).to receive(:deleted_files).and_return(["Deleted.swift"])
154
+ allow(@sut.git).to receive(:renamed_files).and_return([{}])
126
155
  end
127
156
 
128
157
  context "when swiftformat does not find any errors" do
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.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Garrigues
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-24 00:00:00.000000000 Z
11
+ date: 2019-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  - !ruby/object:Gem::Version
199
199
  version: '0'
200
200
  requirements: []
201
- rubygems_version: 3.0.3
201
+ rubygems_version: 3.0.1
202
202
  signing_key:
203
203
  specification_version: 4
204
204
  summary: A danger plugin for checking Swift formatting using SwiftFormat.