danger-chikuwatter 0.0.3 → 1.0.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/README.md +20 -2
- data/lib/chikuwatter/gem_version.rb +1 -1
- data/lib/chikuwatter/plugin.rb +55 -7
- data/spec/chikuwatter_spec.rb +26 -5
- data/spec/fixtures/riverpod_lint.log +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c734434700698b98637fd16e866f41c4655284027fd4357cd99b89f873d40c90
|
4
|
+
data.tar.gz: 9804b717d23c2fa43b6fd4227ef2881c4dd8ff9efddb2a39dc60795e43ea0065
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 867ec7780654354f8ca8534852d7743f3e97ca564c0f2b653119cd30125095b08ea1fa1abcccb71b0a19e4640b8013be421f987179c430a30ec2342a5393ae0a
|
7
|
+
data.tar.gz: 7fcdb89fb107a814489ca353416addb22557b7e0992089a6f61ba1fc14e4b062e5cb1fb9abef431fee56970c8cf3868b9873e8ea47c838cad7a07e8310833704
|
data/README.md
CHANGED
@@ -12,18 +12,36 @@ gem danger-chikuwa
|
|
12
12
|
|
13
13
|
## Usage
|
14
14
|
|
15
|
+
### Report flutter analyze errors and warnings
|
15
16
|
Run flutter analyze and save the result to a file.
|
16
17
|
|
17
18
|
```
|
18
|
-
$ flutter analyze 2>&1 | tee
|
19
|
+
$ flutter analyze 2>&1 | tee analyze.log
|
19
20
|
```
|
20
21
|
|
21
22
|
Add the following to your Dangerfile.
|
22
23
|
|
23
24
|
```
|
24
|
-
chikuwatter.
|
25
|
+
chikuwatter.analyze "analyze.log"
|
26
|
+
chikuwatter.report
|
25
27
|
```
|
26
28
|
|
29
|
+
### Repost riverpod_lint errors and warnings
|
30
|
+
Run riverpod_lint and save the result to a file.
|
31
|
+
|
32
|
+
```
|
33
|
+
$ dart run custom_lint 2>&1 | tee riverpod_lint.log
|
34
|
+
```
|
35
|
+
|
36
|
+
Add the following to your Dangerfile.
|
37
|
+
|
38
|
+
```
|
39
|
+
chikuwatter.riverpod_lint_log "riverpod_lint.log"
|
40
|
+
chikuwatter.report
|
41
|
+
```
|
42
|
+
|
43
|
+
### Report inline comments
|
44
|
+
|
27
45
|
If `inline_mode` is true, the plugin will report the errors, warnings and **info** as inline comments.
|
28
46
|
|
29
47
|
```
|
data/lib/chikuwatter/plugin.rb
CHANGED
@@ -14,7 +14,7 @@ module Danger
|
|
14
14
|
# chikuwatter.report = result.log
|
15
15
|
#
|
16
16
|
class DangerChikuwatter < Plugin
|
17
|
-
attr_accessor :project_root, :inline_mode
|
17
|
+
attr_accessor :project_root, :inline_mode, :analyze_log, :riverpod_lint_log
|
18
18
|
|
19
19
|
# Project root directory
|
20
20
|
def _project_root
|
@@ -28,14 +28,40 @@ module Danger
|
|
28
28
|
@inline_mode || false
|
29
29
|
end
|
30
30
|
|
31
|
+
# Analyze log file path
|
32
|
+
def _analyze_log
|
33
|
+
@analyze_log
|
34
|
+
end
|
35
|
+
|
36
|
+
# Riverpod lint log file path
|
37
|
+
def _riverpod_lint_log
|
38
|
+
@riverpod_lint_log
|
39
|
+
end
|
40
|
+
|
31
41
|
# Report analyze results
|
32
|
-
def report
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
42
|
+
def report
|
43
|
+
results = []
|
44
|
+
if !_analyze_log && !_riverpod_lint_log
|
45
|
+
fail "You must set report file path."
|
46
|
+
end
|
47
|
+
|
48
|
+
if _analyze_log
|
49
|
+
if File.exist?(_analyze_log)
|
50
|
+
results += parse_analyze_log(_analyze_log)
|
51
|
+
else
|
52
|
+
fail "File not found: #{_analyze_log}"
|
53
|
+
end
|
38
54
|
end
|
55
|
+
|
56
|
+
if _riverpod_lint_log
|
57
|
+
if File.exist?(_riverpod_lint_log)
|
58
|
+
results += parse_riverpod_lint_log(_riverpod_lint_log)
|
59
|
+
else
|
60
|
+
fail "File not found: #{_riverpod_lint_log}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
send_reports(results)
|
39
65
|
end
|
40
66
|
|
41
67
|
# Output level
|
@@ -91,6 +117,28 @@ module Danger
|
|
91
117
|
return report_data
|
92
118
|
end
|
93
119
|
|
120
|
+
# Parse riverpod_lint log
|
121
|
+
def parse_riverpod_lint_log(file_path)
|
122
|
+
_project_root = Dir.pwd
|
123
|
+
report_data = []
|
124
|
+
File.foreach(file_path) do |line|
|
125
|
+
logs = line.split("•")
|
126
|
+
# lib/presentation/screens/favorite_contents/favorite_contents_screen_view_model.dart:135:20 • Generated providers should only depend on other generated providers. Failing to do so may break rules such as "provider_dependencies". • avoid_manual_providers_as_generated_provider_dependency
|
127
|
+
if logs.length < 3
|
128
|
+
next
|
129
|
+
end
|
130
|
+
|
131
|
+
file, line_num = logs[0].strip!.split(":")
|
132
|
+
message = "riverpod_lint • `#{logs[2].strip!}`\n#{logs[1].strip!}"
|
133
|
+
|
134
|
+
report_data.push(
|
135
|
+
ReportData.new(message, Type::WARN, file, line_num.to_i)
|
136
|
+
)
|
137
|
+
end
|
138
|
+
|
139
|
+
return report_data
|
140
|
+
end
|
141
|
+
|
94
142
|
# Send analyze results
|
95
143
|
def send_reports(results)
|
96
144
|
results.each do |data|
|
data/spec/chikuwatter_spec.rb
CHANGED
@@ -25,18 +25,39 @@ module Danger
|
|
25
25
|
# Some examples for writing tests
|
26
26
|
# You should replace these with your own.
|
27
27
|
|
28
|
-
it "Errors on file not found" do
|
29
|
-
@my_plugin.
|
30
|
-
|
28
|
+
it "Errors on analyze file not found" do
|
29
|
+
@my_plugin.analyze_log = "no file"
|
30
|
+
@my_plugin.report
|
31
|
+
expect(@dangerfile.status_report[:errors]).to eq(["File not found: no file"])
|
31
32
|
end
|
32
33
|
|
33
|
-
it "
|
34
|
+
it "Errors on riverpod_lint file not found" do
|
35
|
+
@my_plugin.riverpod_lint_log = "no file"
|
36
|
+
@my_plugin.report
|
37
|
+
expect(@dangerfile.status_report[:errors]).to eq(["File not found: no file"])
|
38
|
+
end
|
39
|
+
|
40
|
+
it "Errors on missing parameters" do
|
41
|
+
@my_plugin.report
|
42
|
+
expect(@dangerfile.status_report[:errors]).to eq(["You must set report file path."])
|
43
|
+
end
|
44
|
+
|
45
|
+
it "Report Analyze results" do
|
34
46
|
file_path = "#{File.dirname(__FILE__)}/fixtures/analyze.log"
|
35
47
|
@my_plugin.inline_mode = true
|
36
|
-
@my_plugin.
|
48
|
+
@my_plugin.analyze_log = file_path
|
49
|
+
@my_plugin.report
|
37
50
|
expect(@dangerfile.status_report[:warnings]).to eq(["warning • `invalid_null_aware_operator`\nThe receiver can't be null, so the null-aware operator '?.' is unnecessary", "info • `deprecated_member_use`\n'headline1' is deprecated and shouldn't be used. Use displayLarge instead. This feature was deprecated after v3.1.0-0.0.pre"])
|
38
51
|
expect(@dangerfile.status_report[:errors]).to eq(["error • `argument_type_not_assignable`\nThe argument type 'String?' can't be assigned to the parameter type 'String'"])
|
39
52
|
end
|
53
|
+
|
54
|
+
it "Report Riverpod lint results" do
|
55
|
+
file_path = "#{File.dirname(__FILE__)}/fixtures/riverpod_lint.log"
|
56
|
+
@my_plugin.inline_mode = true
|
57
|
+
@my_plugin.riverpod_lint_log = file_path
|
58
|
+
@my_plugin.report
|
59
|
+
expect(@dangerfile.status_report[:warnings]).to eq(["riverpod_lint • `avoid_manual_providers_as_generated_provider_dependency`\nGenerated providers should only depend on other generated providers. Failing to do so may break rules such as \"provider_dependencies\"."])
|
60
|
+
end
|
40
61
|
end
|
41
62
|
end
|
42
63
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
lib/main.dart:20:20 • Generated providers should only depend on other generated providers. Failing to do so may break rules such as "provider_dependencies". • avoid_manual_providers_as_generated_provider_dependency
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-chikuwatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- watanavex
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- lib/danger_plugin.rb
|
174
174
|
- spec/chikuwatter_spec.rb
|
175
175
|
- spec/fixtures/analyze.log
|
176
|
+
- spec/fixtures/riverpod_lint.log
|
176
177
|
- spec/spec_helper.rb
|
177
178
|
homepage: https://github.com/watanavex/danger-chikuwatter
|
178
179
|
licenses:
|
@@ -200,4 +201,5 @@ summary: A longer description of danger-chikuwatter.
|
|
200
201
|
test_files:
|
201
202
|
- spec/chikuwatter_spec.rb
|
202
203
|
- spec/fixtures/analyze.log
|
204
|
+
- spec/fixtures/riverpod_lint.log
|
203
205
|
- spec/spec_helper.rb
|