danger-flutter_lint-no-filter 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 796be253e5b35340688c8a0d2dc84ca85808a1cda4da9cb246c6073a7862ad03
4
+ data.tar.gz: 2e4eab3fbd1a43b6fa7b75904895d7775a01331de50b2314a5820a59b5eea977
5
+ SHA512:
6
+ metadata.gz: 3ba8b9b17c1e15f798c762af01259a646cd46fcb46c639314caefac98c3b4b8ef0a40e68af746ec58ca918d1f1cb1a7e0a90884c3f7a5b0ed98de87e0072ae34
7
+ data.tar.gz: 18357d189bf2634f030fd1f0dac2f846e151c9be791bfec6897156e8f5a054e77886a2b43ec5e0a48bd3e72e777a1ab27b335cb7c1b5a5f41df52088c769150f
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,120 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.2
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+ Enabled: true
7
+
8
+ Style/ClassCheck:
9
+ EnforcedStyle: kind_of?
10
+
11
+ Style/BracesAroundHashParameters:
12
+ Enabled: false
13
+
14
+ Lint/UselessAssignment:
15
+ Exclude:
16
+ - '**/spec/**/*'
17
+
18
+ Layout/IndentHash:
19
+ Enabled: false
20
+
21
+ Layout/AlignHash:
22
+ Enabled: false
23
+
24
+ Layout/DotPosition:
25
+ Enabled: false
26
+
27
+ Style/DoubleNegation:
28
+ Enabled: false
29
+
30
+ Lint/UnusedBlockArgument:
31
+ Enabled: false
32
+
33
+ Style/ClassAndModuleChildren:
34
+ Enabled: false
35
+
36
+ Metrics/AbcSize:
37
+ Max: 60
38
+
39
+ Style/WordArray:
40
+ MinSize: 19
41
+
42
+ Style/SignalException:
43
+ Enabled: false
44
+
45
+ Style/RedundantReturn:
46
+ Enabled: false
47
+
48
+ Style/IfUnlessModifier:
49
+ Enabled: false
50
+
51
+ Style/AndOr:
52
+ Enabled: false
53
+
54
+ Metrics/ClassLength:
55
+ Max: 350
56
+
57
+ Metrics/CyclomaticComplexity:
58
+ Max: 17
59
+
60
+ Metrics/LineLength:
61
+ Max: 370
62
+
63
+ Metrics/ParameterLists:
64
+ Max: 10
65
+
66
+ Metrics/PerceivedComplexity:
67
+ Max: 18
68
+
69
+ Style/GuardClause:
70
+ Enabled: false
71
+
72
+ Style/ConditionalAssignment:
73
+ Enabled: false
74
+
75
+ Style/RedundantSelf:
76
+ Enabled: false
77
+
78
+ Metrics/MethodLength:
79
+ Max: 60
80
+
81
+ Style/Documentation:
82
+ Enabled: false
83
+
84
+ Style/IfInsideElse:
85
+ Enabled: false
86
+
87
+ Style/BlockComments:
88
+ Enabled: false
89
+
90
+ Layout/MultilineMethodCallIndentation:
91
+ EnforcedStyle: indented
92
+
93
+ Metrics/BlockLength:
94
+ Max: 345
95
+ Exclude:
96
+ - "**/*_spec.rb"
97
+
98
+ Style/MixinGrouping:
99
+ Enabled: false
100
+
101
+ Layout/IndentHeredoc:
102
+ Enabled: false
103
+
104
+ Style/SpecialGlobalVars:
105
+ Enabled: false
106
+
107
+ PercentLiteralDelimiters:
108
+ PreferredDelimiters:
109
+ "%": ()
110
+ "%i": ()
111
+ "%q": ()
112
+ "%Q": ()
113
+ "%r": "{}"
114
+ "%s": ()
115
+ "%w": ()
116
+ "%W": ()
117
+ "%x": ()
118
+
119
+ Security/YAMLLoad:
120
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ sudo: false
2
+ language: ruby
3
+ os:
4
+ - osx
5
+
6
+ cache: bundler
7
+ bundler_args: --without documentation
8
+ rvm:
9
+ - 2.4.1
10
+
11
+ script: bundle exec rake spec
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,187 @@
1
+ GIT
2
+ remote: https://github.com/hatt0519/flutter-analyze-parser.git
3
+ revision: 4778648930dd68cb5d5ee933f16226a087c5493e
4
+ specs:
5
+ flutter_analyze_parser (0.1.2)
6
+
7
+ PATH
8
+ remote: .
9
+ specs:
10
+ danger-flutter_lint (1.0.1)
11
+ danger-plugin-api (~> 1.0)
12
+
13
+ GEM
14
+ remote: https://rubygems.org/
15
+ specs:
16
+ addressable (2.8.7)
17
+ public_suffix (>= 2.0.2, < 7.0)
18
+ ast (2.4.2)
19
+ claide (1.1.0)
20
+ claide-plugins (0.9.2)
21
+ cork
22
+ nap
23
+ open4 (~> 1.3)
24
+ codecov (0.6.0)
25
+ simplecov (>= 0.15, < 0.22)
26
+ coderay (1.1.3)
27
+ colored2 (3.1.2)
28
+ cork (0.3.0)
29
+ colored2 (~> 3.1)
30
+ danger (8.6.1)
31
+ claide (~> 1.0)
32
+ claide-plugins (>= 0.9.2)
33
+ colored2 (~> 3.1)
34
+ cork (~> 0.1)
35
+ faraday (>= 0.9.0, < 2.0)
36
+ faraday-http-cache (~> 2.0)
37
+ git (~> 1.7)
38
+ kramdown (~> 2.3)
39
+ kramdown-parser-gfm (~> 1.0)
40
+ no_proxy_fix
41
+ octokit (~> 4.7)
42
+ terminal-table (>= 1, < 4)
43
+ danger-plugin-api (1.0.0)
44
+ danger (> 2.0)
45
+ diff-lcs (1.5.1)
46
+ docile (1.4.0)
47
+ faraday (1.10.3)
48
+ faraday-em_http (~> 1.0)
49
+ faraday-em_synchrony (~> 1.0)
50
+ faraday-excon (~> 1.1)
51
+ faraday-httpclient (~> 1.0)
52
+ faraday-multipart (~> 1.0)
53
+ faraday-net_http (~> 1.0)
54
+ faraday-net_http_persistent (~> 1.0)
55
+ faraday-patron (~> 1.0)
56
+ faraday-rack (~> 1.0)
57
+ faraday-retry (~> 1.0)
58
+ ruby2_keywords (>= 0.0.4)
59
+ faraday-em_http (1.0.0)
60
+ faraday-em_synchrony (1.0.0)
61
+ faraday-excon (1.1.0)
62
+ faraday-http-cache (2.5.1)
63
+ faraday (>= 0.8)
64
+ faraday-httpclient (1.0.1)
65
+ faraday-multipart (1.0.4)
66
+ multipart-post (~> 2)
67
+ faraday-net_http (1.0.1)
68
+ faraday-net_http_persistent (1.2.0)
69
+ faraday-patron (1.0.0)
70
+ faraday-rack (1.0.0)
71
+ faraday-retry (1.0.3)
72
+ ffi (1.17.0)
73
+ formatador (1.1.0)
74
+ git (1.19.1)
75
+ addressable (~> 2.8)
76
+ rchardet (~> 1.8)
77
+ guard (2.18.1)
78
+ formatador (>= 0.2.4)
79
+ listen (>= 2.7, < 4.0)
80
+ lumberjack (>= 1.0.12, < 2.0)
81
+ nenv (~> 0.1)
82
+ notiffany (~> 0.0)
83
+ pry (>= 0.13.0)
84
+ shellany (~> 0.0)
85
+ thor (>= 0.18.1)
86
+ guard-compat (1.2.1)
87
+ guard-rspec (4.7.3)
88
+ guard (~> 2.1)
89
+ guard-compat (~> 1.1)
90
+ rspec (>= 2.99.0, < 4.0)
91
+ kramdown (2.4.0)
92
+ rexml
93
+ kramdown-parser-gfm (1.1.0)
94
+ kramdown (~> 2.0)
95
+ listen (3.9.0)
96
+ rb-fsevent (~> 0.10, >= 0.10.3)
97
+ rb-inotify (~> 0.9, >= 0.9.10)
98
+ lumberjack (1.2.10)
99
+ method_source (1.1.0)
100
+ multipart-post (2.4.1)
101
+ nap (1.1.0)
102
+ nenv (0.3.0)
103
+ no_proxy_fix (0.1.2)
104
+ notiffany (0.1.3)
105
+ nenv (~> 0.1)
106
+ shellany (~> 0.0)
107
+ octokit (4.25.1)
108
+ faraday (>= 1, < 3)
109
+ sawyer (~> 0.9)
110
+ open4 (1.3.4)
111
+ parallel (1.24.0)
112
+ parser (3.3.4.0)
113
+ ast (~> 2.4.1)
114
+ racc
115
+ pry (0.14.2)
116
+ coderay (~> 1.1)
117
+ method_source (~> 1.0)
118
+ public_suffix (5.1.1)
119
+ racc (1.8.0)
120
+ rainbow (3.1.1)
121
+ rake (10.5.0)
122
+ rb-fsevent (0.11.2)
123
+ rb-inotify (0.11.1)
124
+ ffi (~> 1.0)
125
+ rb-readline (0.5.5)
126
+ rchardet (1.8.0)
127
+ regexp_parser (2.9.2)
128
+ rexml (3.3.2)
129
+ strscan
130
+ rspec (3.13.0)
131
+ rspec-core (~> 3.13.0)
132
+ rspec-expectations (~> 3.13.0)
133
+ rspec-mocks (~> 3.13.0)
134
+ rspec-core (3.13.0)
135
+ rspec-support (~> 3.13.0)
136
+ rspec-expectations (3.13.1)
137
+ diff-lcs (>= 1.2.0, < 2.0)
138
+ rspec-support (~> 3.13.0)
139
+ rspec-mocks (3.13.1)
140
+ diff-lcs (>= 1.2.0, < 2.0)
141
+ rspec-support (~> 3.13.0)
142
+ rspec-support (3.13.1)
143
+ rubocop (0.93.1)
144
+ parallel (~> 1.10)
145
+ parser (>= 2.7.1.5)
146
+ rainbow (>= 2.2.2, < 4.0)
147
+ regexp_parser (>= 1.8)
148
+ rexml
149
+ rubocop-ast (>= 0.6.0)
150
+ ruby-progressbar (~> 1.7)
151
+ unicode-display_width (>= 1.4.0, < 2.0)
152
+ rubocop-ast (1.30.0)
153
+ parser (>= 3.2.1.0)
154
+ ruby-progressbar (1.13.0)
155
+ ruby2_keywords (0.0.5)
156
+ sawyer (0.9.2)
157
+ addressable (>= 2.3.5)
158
+ faraday (>= 0.17.3, < 3)
159
+ shellany (0.0.1)
160
+ simplecov (0.21.2)
161
+ docile (~> 1.1)
162
+ simplecov-html (~> 0.11)
163
+ simplecov_json_formatter (~> 0.1)
164
+ simplecov-html (0.12.3)
165
+ simplecov_json_formatter (0.1.4)
166
+ strscan (3.1.0)
167
+ terminal-table (3.0.2)
168
+ unicode-display_width (>= 1.1.1, < 3)
169
+ thor (1.3.1)
170
+ unicode-display_width (1.8.0)
171
+
172
+ PLATFORMS
173
+ ruby
174
+
175
+ DEPENDENCIES
176
+ codecov (~> 0.1)
177
+ danger-flutter_lint!
178
+ flutter_analyze_parser!
179
+ guard-rspec (~> 4.7)
180
+ rake (~> 10.0)
181
+ rb-readline (~> 0.5)
182
+ rspec (~> 3.0)
183
+ rubocop (~> 0.6)
184
+ simplecov (~> 0.16)
185
+
186
+ BUNDLED WITH
187
+ 2.1.4
data/Guardfile ADDED
@@ -0,0 +1,14 @@
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
+ require "guard/rspec/dsl"
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ # RSpec files
6
+ rspec = dsl.rspec
7
+ watch(rspec.spec_helper) { rspec.spec_dir }
8
+ watch(rspec.spec_support) { rspec.spec_dir }
9
+ watch(rspec.spec_files)
10
+
11
+ # Ruby files
12
+ ruby = dsl.ruby
13
+ dsl.watch_spec_files_for(ruby.lib_files)
14
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Mateusz Szklarek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # danger-flutter_lint
2
+
3
+ [![Gem](https://img.shields.io/gem/v/danger-flutter_lint.svg)](https://rubygems.org/gems/danger-flutter_lint)
4
+ [![Build Status](https://travis-ci.org/mateuszszklarek/danger-flutter_lint.svg?branch=master)](https://travis-ci.org/mateuszszklarek/danger-flutter_lint)
5
+ [![codecov](https://codecov.io/gh/mateuszszklarek/danger-flutter_lint/branch/master/graph/badge.svg)](https://codecov.io/gh/mateuszszklarek/danger-flutter_lint)
6
+
7
+ A Danger Plugin to lint dart files using `flutter analyze` command line interface.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ $ gem 'danger-flutter_lint'
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install danger-flutter_lint
18
+
19
+ ## Usage
20
+
21
+ Flutter Analyze doesn't give an option to generate report but you can achieve this easily using regular shell command (locally or on CI):
22
+
23
+ ```sh
24
+ $ flutter analyze > flutter_analyze_report.txt
25
+ ```
26
+
27
+ It will add output from `flutter analyze` command to `flutter_analyze_report.txt`.
28
+
29
+ Now you need to set `report_path` and invoke `lint` in your Dangerfile.
30
+
31
+ ```ruby
32
+ flutter_lint.report_path = "flutter_analyze_report.txt"
33
+ flutter_lint.lint
34
+ ```
35
+
36
+ This will add markdown table with summary into your PR.
37
+
38
+ Or make Danger comment directly on the line instead of printing a Markdown table (GitHub only)
39
+
40
+ ```ruby
41
+ flutter_lint.lint(inline_mode: true)
42
+ ```
43
+
44
+ Default value for `inline_mode` parameter is false.
45
+
46
+ #### Lint only added/modified files
47
+
48
+ If you're dealing with a legacy project, with tons of warnings, you may want to lint only new/modified files. You can easily achieve that, setting the `only_modified_files` parameter to `true`.
49
+
50
+ ```ruby
51
+ flutter_lint.only_modified_files = true
52
+ flutter_lint.report_path = "flutter_analyze_report.txt"
53
+ flutter_lint.lint
54
+ ```
55
+
56
+ ## Development
57
+
58
+ 1. Clone this repo
59
+ 2. Run `bundle install` to setup dependencies.
60
+ 3. Run `bundle exec rake spec` to run the tests.
61
+ 4. Use `bundle exec guard` to automatically have tests run as you make changes.
62
+ 5. Make your changes.
63
+
64
+ ## Contributing
65
+
66
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mateuszszklarek/danger-flutter_lint.
67
+
68
+ ## License
69
+
70
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "rubocop/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new(:specs)
6
+
7
+ task default: :specs
8
+
9
+ task :spec do
10
+ Rake::Task["specs"].invoke
11
+ Rake::Task["rubocop"].invoke
12
+ end
13
+
14
+ desc "Run RuboCop on the lib/specs directory"
15
+ RuboCop::RakeTask.new(:rubocop) do |task|
16
+ task.patterns = ["lib/**/*.rb"]
17
+ end
@@ -0,0 +1,28 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "flutter_lint/gem_version.rb"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "danger-flutter_lint-no-filter"
7
+ spec.version = FlutterLint::VERSION
8
+ spec.authors = ["hatt0519"]
9
+ spec.email = ["moroku0519@gmail.com"]
10
+ spec.summary = "original: https://github.com/mateuszszklarek/danger-flutterlint This is the fixed danger-flutterlint not to filter flutter analyze result"
11
+ spec.homepage = "https://github.com/hatt0519/danger-flutter_lint"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_runtime_dependency "danger-plugin-api", "~> 1.0"
20
+
21
+ spec.add_development_dependency "codecov", "~> 0.1"
22
+ spec.add_development_dependency "guard-rspec", "~> 4.7"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rb-readline", "~> 0.5"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ spec.add_development_dependency "rubocop", "~> 0.6"
27
+ spec.add_development_dependency "simplecov", "~> 0.16"
28
+ end
@@ -0,0 +1 @@
1
+ require "flutter_lint/gem_version"
@@ -0,0 +1 @@
1
+ require "flutter_lint/plugin"
@@ -0,0 +1,3 @@
1
+ module FlutterLint
2
+ VERSION = "1.0.0".freeze
3
+ end
@@ -0,0 +1,111 @@
1
+ module Danger
2
+ class DangerFlutterLint < Plugin
3
+ # Enable only_modified_files
4
+ # Only show messages within changed files.
5
+ attr_accessor :only_modified_files
6
+
7
+ # Report path
8
+ # You should set output from `flutter analyze` here
9
+ attr_accessor :report_path
10
+
11
+ def lint(inline_mode: false)
12
+ if flutter_exists?
13
+ lint_if_report_exists(inline_mode: inline_mode)
14
+ else
15
+ fail("Could not find `flutter` inside current directory")
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def lint_if_report_exists(inline_mode:)
22
+ if !report_path.nil? && File.exist?(report_path)
23
+ report = File.open(report_path)
24
+ violations = FlutterAnalyzeParser.violations(report)
25
+ lint_mode(inline_mode: inline_mode, violations: violations)
26
+ else
27
+ fail("Could not run lint without setting report path or report file doesn't exists")
28
+ end
29
+ end
30
+
31
+ def lint_mode(inline_mode:, violations:)
32
+ if inline_mode
33
+ send_inline_comments(violations)
34
+ else
35
+ markdown(summary_table(violations))
36
+ end
37
+ end
38
+
39
+ def send_inline_comments(violations)
40
+ filtered_violations = filtered_violations(violations)
41
+
42
+ filtered_violations.each do |violation|
43
+ send("warn", violation.description, file: violation.file, line: violation.line)
44
+ end
45
+ end
46
+
47
+ def summary_table(violations)
48
+ filtered_violations = filtered_violations(violations)
49
+
50
+ if filtered_violations.empty?
51
+ return "### Flutter Analyze found #{filtered_violations.length} issues ✅"
52
+ else
53
+ return markdown_table(filtered_violations)
54
+ end
55
+ end
56
+
57
+ def markdown_table(violations)
58
+ table = "### Flutter Analyze found #{violations.length} issues ❌\n\n"
59
+ table << "| File | Line | Rule |\n"
60
+ table << "| ---- | ---- | ---- |\n"
61
+
62
+ return violations.reduce(table) { |acc, violation| acc << table_row(violation) }
63
+ end
64
+
65
+ def table_row(violation)
66
+ "| `#{violation.file}` | #{violation.line} | #{violation.rule} |\n"
67
+ end
68
+
69
+ def filtered_violations(violations)
70
+ target_files = (git.modified_files - git.deleted_files) + git.added_files
71
+ filtered_violations = violations.select { |violation| target_files.include? violation.file }
72
+
73
+ return only_modified_files ? filtered_violations : violations
74
+ end
75
+
76
+ def flutter_exists?
77
+ `which flutter`.strip.empty? == false
78
+ end
79
+ end
80
+ FlutterViolation = Struct.new(:rule, :description, :file, :line)
81
+
82
+ class FlutterAnalyzeParser
83
+ class << self
84
+ def violations(input)
85
+ filtered_input = filter_input(input)
86
+
87
+ return [] if filtered_input.detect { |element| element.include? "No issues found!" }
88
+
89
+ filtered_input
90
+ .select { |line| line.start_with?("info", "warning", "error") }
91
+ .map(&method(:parse_line))
92
+ end
93
+
94
+ private
95
+
96
+ def filter_input(input)
97
+ input.each_line
98
+ .map(&:strip)
99
+ .reject(&:empty?)
100
+ end
101
+
102
+ def parse_line(line)
103
+ _, description, file_with_line_number, rule = line.split(" • ")
104
+ file, line = file_with_line_number.split(":")
105
+
106
+ FlutterViolation.new(rule, description, file, line.to_i)
107
+ end
108
+ end
109
+ end
110
+
111
+ end
@@ -0,0 +1,6 @@
1
+
2
+ Analyzing my_flutter_project...
3
+
4
+ info • Name types using UpperCamelCase • lib/main.dart:5:7 • camel_case_types
5
+ info • Prefer const with constant constructors • lib/home/home_page.dart:13:13 • prefer_const_constructors
6
+ info • AVOID catches without on clauses • lib/profile/user/phone_widget.dart:19:7 • avoid_catches_without_on_clauses
@@ -0,0 +1,5 @@
1
+
2
+ Analyzing my_flutter_project...
3
+
4
+
5
+ No issues found! (ran in 1.8s)
@@ -0,0 +1,155 @@
1
+ require File.expand_path("spec_helper", __dir__)
2
+
3
+ module Danger
4
+ describe Danger::DangerFlutterLint do
5
+ it "should be a danger plugin" do
6
+ expect(Danger::DangerFlutterLint.new(nil)).to be_a Danger::Plugin
7
+ end
8
+
9
+ describe "with a Dangerfile" do
10
+ before do
11
+ @dangerfile = testing_dangerfile
12
+ @flutter_lint = @dangerfile.flutter_lint
13
+ allow(@flutter_lint.git).to receive(:deleted_files).and_return([])
14
+ allow(@flutter_lint.git).to receive(:added_files).and_return([])
15
+ allow(@flutter_lint.git).to receive(:modified_files).and_return([
16
+ "lib/home/home_page.dart",
17
+ "lib/profile/user/phone_widget.dart"
18
+ ])
19
+ end
20
+
21
+ context "when flutter is not installed" do
22
+ before do
23
+ allow(@flutter_lint).to receive(:`).with("which flutter").and_return("")
24
+ end
25
+
26
+ it "should fail when lint" do
27
+ @flutter_lint.lint
28
+
29
+ expect(@flutter_lint.status_report[:errors]).to eq(["Could not find `flutter` inside current directory"])
30
+ end
31
+ end
32
+
33
+ context "when flutter is installed and report is not set" do
34
+ before do
35
+ allow(@flutter_lint).to receive(:`).with("which flutter").and_return("/Users/johndoe/.flutter/bin/flutter")
36
+ end
37
+
38
+ it "should fail when lint" do
39
+ @flutter_lint.lint
40
+
41
+ expect(@flutter_lint.status_report[:errors]).to eq(["Could not run lint without setting report path or report file doesn't exists"])
42
+ end
43
+
44
+ context "when report is set but file not exists" do
45
+ before do
46
+ allow(@flutter_lint).to receive(:`).with("which flutter").and_return("/Users/johndoe/.flutter/bin/flutter")
47
+ end
48
+
49
+ it "should fail when lint" do
50
+ @flutter_lint.report_path = "users/johndoe/invalid_path/report.txt"
51
+ @flutter_lint.lint
52
+
53
+ expect(@flutter_lint.status_report[:errors]).to eq(["Could not run lint without setting report path or report file doesn't exists"])
54
+ end
55
+ end
56
+
57
+ context "when set `flutter analyze` report path without violations" do
58
+ before do
59
+ @flutter_lint.report_path = "spec/fixtures/flutter_analyze_without_violations.txt"
60
+ end
61
+
62
+ it "should NOT fail when lint" do
63
+ @flutter_lint.lint
64
+
65
+ expect(@flutter_lint.status_report[:errors]).to be_empty
66
+ end
67
+
68
+ it "should add markdown message with 0 violations when inline mode is off" do
69
+ @flutter_lint.lint(inline_mode: false)
70
+
71
+ markdown = @flutter_lint.status_report[:markdowns].first.message
72
+ expect(markdown).to eq("### Flutter Analyze found 0 issues ✅")
73
+ end
74
+
75
+ it "should NOT print markdown message when inline mode is on" do
76
+ @flutter_lint.lint(inline_mode: true)
77
+
78
+ markdown = @flutter_lint.status_report[:markdowns]
79
+ expect(markdown).to be_empty
80
+ end
81
+ end
82
+
83
+ context "when set `flutter analyze` report with some violations" do
84
+ before do
85
+ @flutter_lint.report_path = "spec/fixtures/flutter_analyze_with_violations.txt"
86
+ end
87
+
88
+ it "should NOT fail when lint" do
89
+ @flutter_lint.lint
90
+
91
+ expect(@flutter_lint.status_report[:errors]).to be_empty
92
+ end
93
+
94
+ it "should print markdown message with 3 violations when inline mode is off & only_modified_files not set" do
95
+ @flutter_lint.lint(inline_mode: false)
96
+
97
+ expected = <<~MESSAGE
98
+ ### Flutter Analyze found 3 issues ❌\n
99
+ | File | Line | Rule |
100
+ | ---- | ---- | ---- |
101
+ | `lib/main.dart` | 5 | camel_case_types |
102
+ | `lib/home/home_page.dart` | 13 | prefer_const_constructors |
103
+ | `lib/profile/user/phone_widget.dart` | 19 | avoid_catches_without_on_clauses |
104
+ MESSAGE
105
+
106
+ expect(@flutter_lint.status_report[:markdowns].first.message).to eq(expected)
107
+ end
108
+
109
+ it "should send 3 inline comment instead of markdown when inline mode is on & only_modified_files not set" do
110
+ @flutter_lint.lint(inline_mode: true)
111
+
112
+ warnings = @flutter_lint.status_report[:warnings]
113
+
114
+ exepcted_warnings = [
115
+ "Name types using UpperCamelCase",
116
+ "Prefer const with constant constructors",
117
+ "AVOID catches without on clauses"
118
+ ]
119
+
120
+ expect(warnings).to eq(exepcted_warnings)
121
+ end
122
+
123
+ it "should print markdown message with 2 violations when inline mode is off & only_modified_files set to true" do
124
+ @flutter_lint.only_modified_files = true
125
+ @flutter_lint.lint(inline_mode: false)
126
+
127
+ expected = <<~MESSAGE
128
+ ### Flutter Analyze found 2 issues ❌\n
129
+ | File | Line | Rule |
130
+ | ---- | ---- | ---- |
131
+ | `lib/home/home_page.dart` | 13 | prefer_const_constructors |
132
+ | `lib/profile/user/phone_widget.dart` | 19 | avoid_catches_without_on_clauses |
133
+ MESSAGE
134
+
135
+ expect(@flutter_lint.status_report[:markdowns].first.message).to eq(expected)
136
+ end
137
+
138
+ it "should send 2 inline comment instead of markdown when inline mode is on & only_modified_files set to true" do
139
+ @flutter_lint.only_modified_files = true
140
+ @flutter_lint.lint(inline_mode: true)
141
+
142
+ warnings = @flutter_lint.status_report[:warnings]
143
+
144
+ exepcted_warnings = [
145
+ "Prefer const with constant constructors",
146
+ "AVOID catches without on clauses"
147
+ ]
148
+
149
+ expect(warnings).to eq(exepcted_warnings)
150
+ end
151
+ end
152
+ end
153
+ end
154
+ end
155
+ end
@@ -0,0 +1,58 @@
1
+ require "pathname"
2
+ ROOT = Pathname.new(File.expand_path("..", __dir__))
3
+ $:.unshift((ROOT + "lib").to_s)
4
+ $:.unshift((ROOT + "spec").to_s)
5
+
6
+ require "simplecov"
7
+ SimpleCov.start
8
+
9
+ if ENV["CI"] == "true"
10
+ require "codecov"
11
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
12
+ end
13
+
14
+ require "bundler/setup"
15
+
16
+ require "rspec"
17
+ require "danger"
18
+ require "danger_plugin"
19
+ require "flutter_analyze_parser"
20
+
21
+ RSpec.configure do |config|
22
+ config.example_status_persistence_file_path = ".rspec_status"
23
+ config.filter_gems_from_backtrace "bundler"
24
+ config.expect_with :rspec do |c|
25
+ c.syntax = :expect
26
+ end
27
+ config.color = true
28
+ config.tty = true
29
+ end
30
+
31
+ # Testing
32
+ def testing_env
33
+ {
34
+ "HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
35
+ "TRAVIS_PULL_REQUEST" => "800",
36
+ "TRAVIS_REPO_SLUG" => "artsy/eigen",
37
+ "TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
38
+ "DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
39
+ }
40
+ end
41
+
42
+ def testing_ui
43
+ @output = StringIO.new
44
+ def @output.winsize
45
+ [20, 9999]
46
+ end
47
+
48
+ cork = Cork::Board.new(out: @output)
49
+ def cork.string
50
+ out.string.gsub(/\e\[([;\d]+)?m/, "")
51
+ end
52
+ cork
53
+ end
54
+
55
+ def testing_dangerfile
56
+ env = Danger::EnvironmentManager.new(testing_env)
57
+ Danger::Dangerfile.new(env, testing_ui)
58
+ end
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-flutter_lint-no-filter
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - hatt0519
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-07-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: danger-plugin-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: codecov
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard-rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rb-readline
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.6'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.6'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.16'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.16'
125
+ description:
126
+ email:
127
+ - moroku0519@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".rspec"
134
+ - ".rubocop.yml"
135
+ - ".travis.yml"
136
+ - Gemfile
137
+ - Gemfile.lock
138
+ - Guardfile
139
+ - LICENSE.txt
140
+ - README.md
141
+ - Rakefile
142
+ - danger-flutter_lint-no-filter.gemspec
143
+ - lib/danger_flutter_lint.rb
144
+ - lib/danger_plugin.rb
145
+ - lib/flutter_lint/gem_version.rb
146
+ - lib/flutter_lint/plugin.rb
147
+ - spec/fixtures/flutter_analyze_with_violations.txt
148
+ - spec/fixtures/flutter_analyze_without_violations.txt
149
+ - spec/flutter_lint_spec.rb
150
+ - spec/spec_helper.rb
151
+ homepage: https://github.com/hatt0519/danger-flutter_lint
152
+ licenses:
153
+ - MIT
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubygems_version: 3.0.3
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: 'original: https://github.com/mateuszszklarek/danger-flutterlint This is
174
+ the fixed danger-flutterlint not to filter flutter analyze result'
175
+ test_files:
176
+ - spec/fixtures/flutter_analyze_with_violations.txt
177
+ - spec/fixtures/flutter_analyze_without_violations.txt
178
+ - spec/flutter_lint_spec.rb
179
+ - spec/spec_helper.rb