danger-swiftlint 0.1.2 → 0.2.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
  SHA1:
3
- metadata.gz: 724a5435fe3b3b09ef18f15e76407a5f9d2deea0
4
- data.tar.gz: ad2d97395e8578039090fdf1898b8f290f6b1ff8
3
+ metadata.gz: eb6c93186c9141189a2be976b2728381f983bc5e
4
+ data.tar.gz: d100191c3a3ab38801ec23ba87f79294e4a7d26b
5
5
  SHA512:
6
- metadata.gz: c181f89260aa3c63f1efae0b2a63312025a0bc23cf6471a207c8a6c6f0296129bcc5434c3129211d661e729d75cdcc89a88c99a63bd7da07762644673cd9cbb8
7
- data.tar.gz: 5b6916bb7e8011aaff00bb19b96ccf30cd80c7f8cdd9572ee9ac4a92a53908e4e7a340511155c778831e77fb1937b19962b971a3b67326a1e216daf1a4e592c6
6
+ metadata.gz: e4469183c1e4b05686ae048cbeda886eaa25e96bb9197e12473bb63a1a1cd6e228245503dcc66266fae698641f8fb4dd62c21f4de1334d888a803804848de24e
7
+ data.tar.gz: 467441b08eef27d8415ecaa4302412a087c93848cf298c17afa2624375bfdaa6de59534d56438d9798924c21fec195280fc3e98cdada21723f190760c0b4b921
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-swiftlint (0.1.0)
4
+ danger-swiftlint (0.1.2)
5
5
  danger
6
6
 
7
7
  GEM
@@ -14,7 +14,7 @@ GEM
14
14
  colored (1.2)
15
15
  cork (0.1.0)
16
16
  colored (~> 1.2)
17
- danger (0.8.4)
17
+ danger (0.8.5)
18
18
  claide (~> 1.0)
19
19
  colored (~> 1.2)
20
20
  cork (~> 0.1)
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Danger SwiftLint
4
4
 
5
- A [Danger](https://github.com/danger/danger) plugin for [SwiftLint](https://github.com/realm/SwiftLint).
5
+ A [Danger](https://github.com/danger/danger) plugin for [SwiftLint](https://github.com/realm/SwiftLint) that runs on macOS.
6
6
 
7
7
  ## Installation
8
8
 
@@ -20,24 +20,13 @@ The easiest way to use is just add this to your Dangerfile:
20
20
  swiftlint.lint_files
21
21
  ```
22
22
 
23
- That will lint any changed or added Swift files in the PR. You can also set up a config file first.
23
+ That's going to lint all your Swift files. It would be better to only lint the changed or added ones, which is complicated due. Check out [this issue](https://github.com/ashfurrow/danger-swiftlint/issues/16) for more details.
24
24
 
25
25
  ```rb
26
26
  swiftlint.config_file = '.swiftlint.yml'
27
27
  swiftlint.lint_files
28
28
  ```
29
29
 
30
- And finally, you can provide a list of files manually:
31
-
32
- ``` ruby
33
- # Look through all changed Swift files
34
- swift_files = (modified_files + added_files).select do |file|
35
- file.end_with?(".swift")
36
- end
37
-
38
- swiftlint.lint_files swift_files
39
- ```
40
-
41
30
  ## Attribution
42
31
 
43
32
  Original structure, sequence, and organization of repo taken from [danger-prose](https://github.com/dbgrandi/danger-prose) by [David Grandinetti](https://github.com/dbgrandi/).
@@ -26,7 +26,7 @@ module Danger
26
26
  # if nil, modified and added files from the diff will be used.
27
27
  # @return [void]
28
28
  #
29
- def lint_files(files=nil)
29
+ def lint_files
30
30
  # Installs SwiftLint if needed
31
31
  system "brew install swiftlint" unless swiftlint_installed?
32
32
 
@@ -36,21 +36,14 @@ module Danger
36
36
  return
37
37
  end
38
38
 
39
- # Either use files provided, or use the modified + added
40
- swift_files = files ? Dir.glob(files) : (modified_files + added_files)
41
- swift_files.select! do |line| line.end_with?(".swift") end
42
-
43
- # Make sure we don't fail when paths have spaces
44
- swift_files = swift_files.map { |file| "\"#{file}\"" }
45
-
46
39
  swiftlint_command = "swiftlint lint --quiet --reporter json"
47
40
  swiftlint_command += " --config #{config_file}" if config_file
48
41
 
49
42
  require 'json'
50
- result_json = swift_files.uniq.collect { |f| JSON.parse(`#{swiftlint_command} --path #{f}`.strip).flatten }.flatten
43
+ result_json = JSON.parse(`#{swiftlint_command}`).flatten
51
44
 
52
45
  # Convert to swiftlint results
53
- warnings = result_json.flatten.select do |results|
46
+ warnings = result_json.select do |results|
54
47
  results['severity'] == 'Warning'
55
48
  end
56
49
  errors = result_json.select do |results|
@@ -61,13 +54,13 @@ module Danger
61
54
 
62
55
  # We got some error reports back from swiftlint
63
56
  if warnings.count > 0 || errors.count > 0
64
- message = '### SwiftLint found issues\n\n'
57
+ message = "### SwiftLint found issues\n\n"
65
58
  end
66
59
 
67
60
  message << parse_results(warnings, 'Warnings') unless warnings.empty?
68
61
  message << parse_results(errors, 'Errors') unless errors.empty?
69
62
 
70
- markdown message
63
+ markdown message unless message.empty?
71
64
  end
72
65
 
73
66
  # Parses swiftlint invocation results into a string
@@ -1,3 +1,3 @@
1
1
  module DangerSwiftlint
2
- VERSION = "0.1.2".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
@@ -24,6 +24,14 @@ module Danger
24
24
  expect(@swiftlint.swiftlint_installed?).to be_truthy
25
25
  end
26
26
 
27
+ it 'does not markdown an empty message' do
28
+ allow(@swiftlint).to receive(:`)
29
+ .with('swiftlint lint --quiet --reporter json')
30
+ .and_return('[]')
31
+
32
+ expect(@swiftlint.status_report[:markdowns].first).to be_nil
33
+ end
34
+
27
35
  describe :lint_files do
28
36
  before do
29
37
  # So it doesn't try to install on your computer
@@ -34,10 +42,10 @@ module Danger
34
42
  end
35
43
 
36
44
  it 'handles a known SwiftLint report' do
37
- allow(@swiftlint).to receive(:`).with('swiftlint lint --quiet --reporter json --path "spec/fixtures/SwiftFile.swift"').and_return(@swiftlint_response)
45
+ allow(@swiftlint).to receive(:`).with('swiftlint lint --quiet --reporter json').and_return(@swiftlint_response)
38
46
 
39
47
  # Do it
40
- @swiftlint.lint_files("spec/fixtures/*.swift")
48
+ @swiftlint.lint_files
41
49
 
42
50
  output = @swiftlint.status_report[:markdowns].first
43
51
 
@@ -50,9 +58,7 @@ module Danger
50
58
  end
51
59
 
52
60
  it 'handles no files' do
53
- allow(@swiftlint).to receive(:modified_files).and_return(['spec/fixtures/SwiftFile.swift'])
54
- allow(@swiftlint).to receive(:added_files).and_return([])
55
- allow(@swiftlint).to receive(:`).with('swiftlint lint --quiet --reporter json --path "spec/fixtures/SwiftFile.swift"').and_return(@swiftlint_response)
61
+ allow(@swiftlint).to receive(:`).with('swiftlint lint --quiet --reporter json').and_return(@swiftlint_response)
56
62
 
57
63
  @swiftlint.lint_files
58
64
 
@@ -61,9 +67,9 @@ module Danger
61
67
 
62
68
  it 'uses a config file' do
63
69
  @swiftlint.config_file = 'some_config.yml'
64
- allow(@swiftlint).to receive(:`).with('swiftlint lint --quiet --reporter json --config some_config.yml --path "spec/fixtures/SwiftFile.swift"').and_return(@swiftlint_response)
70
+ allow(@swiftlint).to receive(:`).with('swiftlint lint --quiet --reporter json --config some_config.yml').and_return(@swiftlint_response)
65
71
 
66
- @swiftlint.lint_files("spec/fixtures/*.swift")
72
+ @swiftlint.lint_files
67
73
 
68
74
  expect(@swiftlint.status_report[:markdowns].first).to_not be_empty
69
75
  end
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.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ash Furrow
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-07-12 00:00:00.000000000 Z
13
+ date: 2016-07-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: danger