danger-textlint 1.1.0 → 1.2.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
  SHA256:
3
- metadata.gz: e2382053d93e9c0e1eed4097159796a353a3bd9276fa9a44e4d2d407712e6045
4
- data.tar.gz: 8d9bbb9847bdb36c5adda08c680deb2eaf48c9a64886a834bb1fed0ee33b207a
3
+ metadata.gz: 4390839bd6f828e1785379ba7d06040f8c5029602b20d47f2a4480eae6752d4c
4
+ data.tar.gz: a353be06a739e47e57d23aa790b7e469b7ac8e5d60005f1e0fef175b8cb6fd62
5
5
  SHA512:
6
- metadata.gz: 19e222aa434bd619b2362c147607ffd6cbd84ca4485358596eba26df6e7331e1f232a8109b800b8931cefa8a7ed79987e6c5e04cf85827fb52fa21bfa0db9698
7
- data.tar.gz: 4a34ed18e8280a83de8b755b1ace97cf5ee9fff674f9e2cd8f059ac88dea0341482b5f98755efec0bcd5bc59a69768704b4fbf11eb12905b3560c3662d232e20
6
+ metadata.gz: 32b9a7b3606c0b0bda6b3e0edc2f4085d00f915a7d76aa3aaa404a7f90f1ed11d72163f5121332eeafea80f2a6bf5d864aa5c24ffbb6ddcf536d889708084939
7
+ data.tar.gz: 5a728a6b925e76970694144a4ee8f9037fd2a1904ee2fbdcb6524841a11dbd78327632ddbd2065774e90e8709c7975759c357170ce2333f7081dc76fb91702c7
data/.rubocop.yml CHANGED
@@ -153,3 +153,6 @@ Security/YAMLLoad:
153
153
 
154
154
  Style/FrozenStringLiteralComment:
155
155
  Enabled: false
156
+
157
+ Metrics/ModuleLength:
158
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-textlint (1.1.0)
4
+ danger-textlint (1.2.0)
5
5
  danger-plugin-api (~> 1.0)
6
6
 
7
7
  GEM
@@ -1,3 +1,3 @@
1
1
  module Textlint
2
- VERSION = "1.1.0".freeze
2
+ VERSION = "1.2.0".freeze
3
3
  end
@@ -14,6 +14,11 @@ module Danger
14
14
  # textlint.max_severity = "warn"
15
15
  # textlint.lint
16
16
  #
17
+ # @example Max inline comment number. If you want disable this feature, please set nil. Default: nil
18
+ #
19
+ # textlint.max_comment_num = 5
20
+ # textlint.lint
21
+ #
17
22
  # @see Kesin11/danger-textlint
18
23
  # @tags lint, textlint
19
24
  #
@@ -27,6 +32,11 @@ module Danger
27
32
  # @return [String]
28
33
  attr_accessor :max_severity
29
34
 
35
+ # Set max danger reporting comment number
36
+ # choice: nil or integer
37
+ # @return [String]
38
+ attr_accessor :max_comment_num
39
+
30
40
  # Execute textlint and send comment
31
41
  # @return [void]
32
42
  def lint
@@ -88,7 +98,13 @@ module Danger
88
98
  end
89
99
 
90
100
  def send_comment(errors)
91
- errors.each do |error|
101
+ limited_errors = errors
102
+ if max_comment_num && limited_errors.size > max_comment_num
103
+ limited_errors = limited_errors.first(max_comment_num)
104
+ send("warn", "Textlint reported more than #{max_comment_num} problems, but danger-textlint doesn't to display all problems. Please run textlint in your machine and check all problems.")
105
+ end
106
+
107
+ limited_errors.each do |error|
92
108
  send(error[:severity], error[:message], file: error[:file_path], line: error[:line])
93
109
  end
94
110
  end
@@ -100,6 +100,33 @@ module Danger
100
100
  )
101
101
  end
102
102
  end
103
+
104
+ context "with .max_comment_num = 5" do
105
+ let(:max_comment_num) { 5 }
106
+ before do
107
+ @textlint.max_comment_num = max_comment_num
108
+ @textlint.lint
109
+ end
110
+
111
+ it "status_report" do
112
+ status_report = @textlint.status_report
113
+ expect(status_report[:errors].size).to eq(max_comment_num)
114
+ end
115
+
116
+ it "violation_report" do
117
+ violation_report = @textlint.violation_report
118
+ expect(violation_report[:errors].size).to eq(max_comment_num)
119
+ end
120
+
121
+ it "danger comment" do
122
+ # find not inline comment
123
+ comment = @textlint.violation_report[:warnings].find do |warning|
124
+ warning.message.match(/Textlint reported more than/)
125
+ end
126
+
127
+ expect(comment).not_to be_nil
128
+ end
129
+ end
103
130
  end
104
131
 
105
132
  describe ".target_files" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-textlint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kesin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-22 00:00:00.000000000 Z
11
+ date: 2018-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api