flutter_rb 0.8.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56163d178d255fcb18d11f97c1dc765d6520e5433cf33ac542e837e1c2eecbfa
4
- data.tar.gz: 97a7d49337bf3ae6f7574540e9f0f5664c97af16f73c932a6db07b1891f4014a
3
+ metadata.gz: c2085d887e060a00177dfef11e0a1219b7fa146064c315c409cf30ceccea494b
4
+ data.tar.gz: 7bbba89d78ed94e75e95f43180ae4f59449a04019b47f81e01e697174c482121
5
5
  SHA512:
6
- metadata.gz: 2f9c7d99a0dc7ebbf9258bf9557b69019c593dfde8c90580429251f3a11845bb2be62331c500fe314b05198fb3866a5b060c0663336242f89ff546e6d1e54fb5
7
- data.tar.gz: d131de15f2576c3bc38e2e290447248a588464bd7acc927a86c840988b418c1d0f409bb169daa26e3a5786e5bd1c1299af54f9c05b81d9ccf447a80d02df5f3e
6
+ metadata.gz: 9545fa39016e347701d743ebca162d70cbc599271db993f406d6262b9d1e72c120def9c47bbc2a9a7e3b941c490437558f4ecb285830becf1f6904265bd35413
7
+ data.tar.gz: 0070f79ba964624b33ece2ea1db4b8e3b9035a46be64d7f1d6f8da75f1abe5fc3ec0d2cbddc52c35d3cb8ffb8f6935d553374aa7dbeb0c3ce8fd5d9656a8a7eb
data/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- Copyright (c) 2020-2022 Artem Fomchenkov
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2020-2023 Artem Fomchenkov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,144 +1,144 @@
1
- <img src="media/logo/ic_lib.png" height="100px">
2
-
3
- # flutter_rb
4
-
5
- [![GitHubActions](https://github.com/flutter-rb/flutter_rb/workflows/Build/badge.svg)](https://github.com/flutter-rb/flutter_rb/actions?query=workflow%3ARuby)
6
- [![Codebeat](https://codebeat.co/badges/9bb32e28-ca86-4cdc-ba66-bda7f989979a)](https://codebeat.co/projects/github-com-fartem-flutter_rb-master)
7
- [![Coveralls](https://coveralls.io/repos/github/flutter-rb/flutter_rb/badge.svg?branch=master)](https://coveralls.io/github/flutter-rb/flutter_rb?branch=master)
8
-
9
- ## About
10
-
11
- A tool for checking a Flutter plugin structure.
12
-
13
- ### Checks
14
-
15
- #### Levels
16
-
17
- Each issue has a `level` parameter that describes his significate level.
18
-
19
- | Level | Description |
20
- | --- | --- |
21
- | `NORMAL` | Issue was not found |
22
- | `WARNING` | Issue is not serious and cannot break build |
23
- | `ERROR` | Issue is critical and can break build |
24
-
25
- #### Flutter
26
-
27
- | Check | Description | Level |
28
- | --- | --- | --- |
29
- | `PluginDirectoriesCheck` | Check plugin directories structure in pubspec file. Example: if a Flutter plugin has only Android specific code but not contains iOS folder with description, then iOS build fails | `ERROR` |
30
- | `PluginPubspecNameCheck` | Check plugin name in pubspec file. Exists or not | `ERROR` |
31
- | `PluginPubspecDescriptionCheck` | Check plugin description in pubspec file. Exists or not | `WARNING` |
32
- | `PluginPubspecVersionCheck` | Check plugin version in pubspec. Exists or not | `ERROR` |
33
- | `PluginPubspecAuthorCheck` | Check plugin author in pubspec. Exists or not. `author` section deprecated in `pubspec.yaml` | `WARNING` |
34
- | `PluginPubspecHomepageCheck` | Check plugin homepage in pubspec. Exists or not | `ERROR` |
35
- | `PluginPubspecEffectiveDartCheck` | Check Flutter plugin Effective Dart depencency in pubspec file. Exists or not | `ERROR` |
36
-
37
- #### Android
38
-
39
- | Check | Description | Level |
40
- | --- | --- | --- |
41
- | `PluginGradleAndroidPackageCheck` | Validate that \android\ package not exists in Gradle project config (build.gradle file) | `ERROR` |
42
- | `PluginGradleVersionCheck` | Check plugin version in Gradle project config (build.gradle file). Version must be the same as plugin version in pubspec file | `WARNING` |
43
-
44
- #### iOS
45
-
46
- | Check | Description | Level |
47
- | --- | --- | --- |
48
- | `PluginPodspecNameCheck` | Check plugin name in podspec file. Exists or not | `WARNING` |
49
- | `PluginPodspecVersionCheck` | Check plugin version in podspec file. Exists or not | `WARNING` |
50
- | `PluginPodspecAuthorsCheck` | Check plugin's authors in podspec file. Exists or not | `ERROR` |
51
- | `PluginPodspecSourceCheck` | Check plugin iOS source path in podspec file. If Flutter plugin cannot contains iOS specific code, source path must be `'.'` | `ERROR` |
52
-
53
- ## How to use
54
-
55
- ### Android
56
-
57
- You should add [flutter-rb-gradle-plugin](https://github.com/fartem/flutter-rb-gradle-plugin) to Android side of your plugin.
58
-
59
- ### Download gem from RubyGems
60
-
61
- Install gem:
62
-
63
- ```shell
64
- gem install flutter_rb
65
- ```
66
-
67
- Then run from a Flutter plugin's project folder:
68
-
69
- ```shell
70
- frb
71
- ```
72
-
73
- ### As local installed gem
74
-
75
- Build gem from sources:
76
-
77
- ```shell
78
- gem build flutter_rb.gemspec
79
- ```
80
-
81
- Install gem:
82
-
83
- ```shell
84
- gem i flutter_rb
85
- ```
86
-
87
- Then run from a Flutter plugin's project folder:
88
-
89
- ```shell
90
- frb
91
- ```
92
-
93
- ### As local executable
94
-
95
- Add `project_folder/bin` (where `project_folder` is path to project on your machine) to `PATH` variable in your environment. Then updated environment and run from a Flutter plugin's project folder:
96
-
97
- ```shell
98
- local_frb
99
- ```
100
-
101
- ### Arguments
102
-
103
- | Argument | Description |
104
- | --- | --- |
105
- | `--help` | Print help info |
106
- | `--checkstyle-report` | Generate report in Checkstyle format |
107
-
108
-
109
- ### Configuration
110
-
111
- Add `.flutter_rb.yaml` to root of a project for select checks that you are want to execute:
112
-
113
- ```yaml
114
- include:
115
- flutter:
116
- - check1
117
- - check2
118
- - check3
119
- android:
120
- - check1
121
- - check2
122
- ios:
123
- - check1
124
- - check2
125
-
126
- ```
127
-
128
- ### Output report
129
-
130
- Tool can make report in Checkstyle format. To enable this feature, pass `--checkstyle-report` as an CLI argument. The report file name is `frb-checkstyle-report.xml`.
131
-
132
- ## How to contribute
133
-
134
- Read [Commit Convention](https://github.com/fartem/repository-rules/blob/master/commit-convention/COMMIT_CONVENTION.md). Make sure your build is green before you contribute your pull request. Then:
135
-
136
- ```shell
137
- bundle exec rake
138
- ```
139
-
140
- If you don't see any error messages, submit your pull request.
141
-
142
- ## Contributors
143
-
144
- - [@fartem](https://github.com/fartem) as Artem Fomchenkov
1
+ <img src="media/logo/ic_lib.png" height="100px" alt="Project's logo">
2
+
3
+ # flutter_rb
4
+
5
+ [![GitHubActions](https://github.com/flutter-rb/flutter-rb/workflows/Build/badge.svg)](https://github.com/flutter-rb/flutter-rb/actions?branch=master)
6
+ [![Codebeat](https://codebeat.co/badges/9bb32e28-ca86-4cdc-ba66-bda7f989979a)](https://codebeat.co/projects/github-com-fartem-flutter-rb-master)
7
+ [![Gem Version](https://badge.fury.io/rb/flutter_rb.svg)](https://badge.fury.io/rb/flutter_rb)
8
+
9
+ ## About
10
+
11
+ A tool for checking a Flutter plugin structure.
12
+
13
+ ### Checks
14
+
15
+ #### Levels
16
+
17
+ Each issue has a `level` parameter that describes his significate level.
18
+
19
+ | Level | Description |
20
+ |-----------|---------------------------------------------|
21
+ | `NORMAL` | Issue was not found |
22
+ | `WARNING` | Issue is not serious and cannot break build |
23
+ | `ERROR` | Issue is critical and can break build |
24
+
25
+ #### Flutter
26
+
27
+ | Check | Description | Level |
28
+ |-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|
29
+ | `PluginDirectoriesCheck` | Check plugin directories structure in pubspec file. Example: if a Flutter plugin has only Android specific code but not contains iOS folder with description, then iOS build fails | `ERROR` |
30
+ | `PluginPubspecNameCheck` | Check plugin name in pubspec file. Exists or not | `ERROR` |
31
+ | `PluginPubspecDescriptionCheck` | Check plugin description in pubspec file. Exists or not | `WARNING` |
32
+ | `PluginPubspecVersionCheck` | Check plugin version in pubspec. Exists or not | `ERROR` |
33
+ | `PluginPubspecAuthorCheck` | Check plugin author in pubspec. Exists or not. `author` section deprecated in `pubspec.yaml` | `WARNING` |
34
+ | `PluginPubspecHomepageCheck` | Check plugin homepage in pubspec. Exists or not | `ERROR` |
35
+ | `PluginPubspecEffectiveDartCheck` | Check Flutter plugin Effective Dart depencency in pubspec file. Exists or not | `ERROR` |
36
+
37
+ #### Android
38
+
39
+ | Check | Description | Level |
40
+ |-----------------------------------|-------------------------------------------------------------------------------------------------------------------------------|-----------|
41
+ | `PluginGradleAndroidPackageCheck` | Validate that \android\ package not exists in Gradle project config (build.gradle file) | `ERROR` |
42
+ | `PluginGradleVersionCheck` | Check plugin version in Gradle project config (build.gradle file). Version must be the same as plugin version in pubspec file | `WARNING` |
43
+
44
+ #### iOS
45
+
46
+ | Check | Description | Level |
47
+ |-----------------------------|------------------------------------------------------------------------------------------------------------------------------|-----------|
48
+ | `PluginPodspecNameCheck` | Check plugin name in podspec file. Exists or not | `WARNING` |
49
+ | `PluginPodspecVersionCheck` | Check plugin version in podspec file. Exists or not | `WARNING` |
50
+ | `PluginPodspecAuthorsCheck` | Check plugin's authors in podspec file. Exists or not | `ERROR` |
51
+ | `PluginPodspecSourceCheck` | Check plugin iOS source path in podspec file. If Flutter plugin cannot contains iOS specific code, source path must be `'.'` | `ERROR` |
52
+
53
+ ## How to use
54
+
55
+ ### Android
56
+
57
+ You should add [flutter-rb-gradle-plugin](https://github.com/flutter-rb/flutter-rb-gradle-plugin) to Android side of your plugin.
58
+
59
+ ### Download gem from RubyGems
60
+
61
+ Install gem:
62
+
63
+ ```shell
64
+ gem install flutter_rb
65
+ ```
66
+
67
+ Then run from a Flutter plugin's project folder:
68
+
69
+ ```shell
70
+ frb
71
+ ```
72
+
73
+ ### As local installed gem
74
+
75
+ Build gem from sources:
76
+
77
+ ```shell
78
+ gem build flutter_rb.gemspec
79
+ ```
80
+
81
+ Install gem:
82
+
83
+ ```shell
84
+ gem i flutter_rb
85
+ ```
86
+
87
+ Then run from a Flutter plugin's project folder:
88
+
89
+ ```shell
90
+ frb
91
+ ```
92
+
93
+ ### As local executable
94
+
95
+ Add `project_folder/bin` (where `project_folder` is path to project on your machine) to `PATH` variable in your environment. Then updated environment and run from a Flutter plugin's project folder:
96
+
97
+ ```shell
98
+ local_frb
99
+ ```
100
+
101
+ ### Arguments
102
+
103
+ | Argument | Description |
104
+ |-----------------------|--------------------------------------|
105
+ | `--help` | Print help info |
106
+ | `--checkstyle-report` | Generate report in Checkstyle format |
107
+
108
+
109
+ ### Configuration
110
+
111
+ Add `.flutter_rb.yaml` to root of a project for select checks that you are want to execute:
112
+
113
+ ```yaml
114
+ include:
115
+ flutter:
116
+ - check1
117
+ - check2
118
+ - check3
119
+ android:
120
+ - check1
121
+ - check2
122
+ ios:
123
+ - check1
124
+ - check2
125
+
126
+ ```
127
+
128
+ ### Output report
129
+
130
+ Tool can make report in Checkstyle format. To enable this feature, pass `--checkstyle-report` as an CLI argument. The report file name is `frb-checkstyle-report.xml`.
131
+
132
+ ## How to contribute
133
+
134
+ Read [Commit Convention](https://github.com/fartem/repository-rules/blob/master/commit-convention/COMMIT_CONVENTION.md). Make sure your build is green before you contribute your pull request. Then:
135
+
136
+ ```shell
137
+ bundle exec rake
138
+ ```
139
+
140
+ If you don't see any error messages, submit your pull request.
141
+
142
+ ## Contributors
143
+
144
+ - [@fartem](https://github.com/fartem) as Artem Fomchenkov
data/bin/frb CHANGED
@@ -1,19 +1,19 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'flutter_rb'
4
- require 'colorize'
5
-
6
- def light_blue_text(text)
7
- text.colorize(:light_blue)
8
- end
9
-
10
- if ARGV.include?('--help')
11
- puts "
12
- Available aruments:
13
- * #{light_blue_text('--help')}: print help info
14
- * #{light_blue_text('--checkstyle-report')}: generate report in Checkstyle format
15
- "
16
- else
17
- flutter_rb = FlutterRb::FlutterRb.new
18
- flutter_rb.start(Dir.pwd, ARGV.include?('--checkstyle-report'))
19
- end
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'flutter_rb'
4
+ require 'colorize'
5
+
6
+ def light_blue_text(text)
7
+ text.colorize(:light_blue)
8
+ end
9
+
10
+ if ARGV.include?('--help')
11
+ puts "
12
+ Available arguments:
13
+ * #{light_blue_text('--help')}: print help info
14
+ * #{light_blue_text('--checkstyle-report')}: generate report in Checkstyle format
15
+ "
16
+ else
17
+ flutter_rb = FlutterRb::FlutterRb.new
18
+ flutter_rb.start(Dir.pwd, ARGV.include?('--checkstyle-report'))
19
+ end
@@ -1,90 +1,90 @@
1
- require 'nokogiri'
2
-
3
- # Module with classes for creating reports in Checkstyle format
4
- module CheckstyleReport
5
- # Class for create report in Checkstyle format
6
- class CheckstyleReport
7
- def initialize(path, report_filename, checks)
8
- @path = path
9
- @report_filename = report_filename
10
- @checks = checks
11
- end
12
-
13
- def create_report
14
- checkstyle_files = sort_checks(@checks)
15
- report = Nokogiri::XML::Builder.new do |xml|
16
- xml.checkstyle(version: '8.38') do
17
- checkstyle_files
18
- .map { |file, errors| CheckstyleFile.new(file, errors) }
19
- .each { |file| write_file(xml, file) }
20
- end
21
- end
22
- File.open("#{@path}/#{@report_filename}.xml", 'w') { |file| file.write(report.to_xml) }
23
- end
24
-
25
- def sort_checks(checks)
26
- checkstyle_files = {}
27
- checks.each do |check|
28
- checkstyle_file = checkstyle_files[check.source]
29
- checkstyle_files[check.source] = [] if checkstyle_file.nil?
30
- checkstyle_files[check.source] += [check] if check.saverity != CheckstyleError::SAVERITY_NORMAL
31
- end
32
- checkstyle_files
33
- end
34
-
35
- def write_file(xml, checkstyle_file)
36
- xml.file(name: checkstyle_file.file) do
37
- checkstyle_file.errors.each do |error|
38
- write_error(xml, error)
39
- end
40
- end
41
- end
42
-
43
- def write_error(xml, error)
44
- xml.error(
45
- line: error.line,
46
- column: error.column,
47
- saverity: error.saverity,
48
- message: error.message,
49
- source: error.source
50
- )
51
- end
52
- end
53
-
54
- # File representation for Checkstyle format
55
- class CheckstyleFile
56
- def initialize(file, errors)
57
- @file = file
58
- @errors = errors
59
- end
60
-
61
- attr_reader :file, :errors
62
- end
63
-
64
- # Checkstyle error representation
65
- class CheckstyleError
66
- SAVERITY_NORMAL = 'normal'.freeze
67
- SAVERITY_WARNING = 'warning'.freeze
68
- SAVERITY_ERROR = 'error'.freeze
69
-
70
- # rubocop:disable Metrics/ParameterLists
71
- def initialize(
72
- saverity,
73
- message,
74
- source,
75
- line,
76
- column,
77
- name
78
- )
79
- @saverity = saverity
80
- @message = message
81
- @source = source
82
- @line = line
83
- @column = column
84
- @name = name
85
- end
86
- # rubocop:enable Metrics/ParameterLists
87
-
88
- attr_reader :saverity, :message, :source, :line, :column, :name
89
- end
90
- end
1
+ require 'nokogiri'
2
+
3
+ # Module with classes for creating reports in Checkstyle format
4
+ module CheckstyleReport
5
+ # Class for create report in Checkstyle format
6
+ class CheckstyleReport
7
+ def initialize(path, report_filename, checks)
8
+ @path = path
9
+ @report_filename = report_filename
10
+ @checks = checks
11
+ end
12
+
13
+ def create_report
14
+ checkstyle_files = sort_checks(@checks)
15
+ report = Nokogiri::XML::Builder.new do |xml|
16
+ xml.checkstyle(version: '8.38') do
17
+ checkstyle_files
18
+ .map { |file, errors| CheckstyleFile.new(file, errors) }
19
+ .each { |file| write_file(xml, file) }
20
+ end
21
+ end
22
+ File.open("#{@path}/#{@report_filename}.xml", 'w') { |file| file.write(report.to_xml) }
23
+ end
24
+
25
+ def sort_checks(checks)
26
+ checkstyle_files = {}
27
+ checks.each do |check|
28
+ checkstyle_file = checkstyle_files[check.source]
29
+ checkstyle_files[check.source] = [] if checkstyle_file.nil?
30
+ checkstyle_files[check.source] += [check] if check.severity != CheckstyleError::SEVERITY_NORMAL
31
+ end
32
+ checkstyle_files
33
+ end
34
+
35
+ def write_file(xml, checkstyle_file)
36
+ xml.file(name: checkstyle_file.file) do
37
+ checkstyle_file.errors.each do |error|
38
+ write_error(xml, error)
39
+ end
40
+ end
41
+ end
42
+
43
+ def write_error(xml, error)
44
+ xml.error(
45
+ line: error.line,
46
+ column: error.column,
47
+ severity: error.severity,
48
+ message: error.message,
49
+ source: error.source
50
+ )
51
+ end
52
+ end
53
+
54
+ # File representation for Checkstyle format
55
+ class CheckstyleFile
56
+ def initialize(file, errors)
57
+ @file = file
58
+ @errors = errors
59
+ end
60
+
61
+ attr_reader :file, :errors
62
+ end
63
+
64
+ # Checkstyle error representation
65
+ class CheckstyleError
66
+ SEVERITY_NORMAL = 'normal'.freeze
67
+ SEVERITY_WARNING = 'warning'.freeze
68
+ SEVERITY_ERROR = 'error'.freeze
69
+
70
+ # rubocop:disable Metrics/ParameterLists
71
+ def initialize(
72
+ severity,
73
+ message,
74
+ source,
75
+ line,
76
+ column,
77
+ name
78
+ )
79
+ @severity = severity
80
+ @message = message
81
+ @source = source
82
+ @line = line
83
+ @column = column
84
+ @name = name
85
+ end
86
+ # rubocop:enable Metrics/ParameterLists
87
+
88
+ attr_reader :severity, :message, :source, :line, :column, :name
89
+ end
90
+ end
@@ -1,24 +1,24 @@
1
- module FlutterRb
2
- # Base class for all checks
3
- # Class provides default methods structure
4
- # All methods using for create reports
5
- class Check
6
- UNIMPLEMENTATION_ERROR = 'Error: missing method'.freeze
7
-
8
- def name
9
- raise UNIMPLEMENTATION_ERROR
10
- end
11
-
12
- def summary
13
- raise UNIMPLEMENTATION_ERROR
14
- end
15
-
16
- def description
17
- 'No provided'
18
- end
19
-
20
- def check
21
- raise UNIMPLEMENTATION_ERROR
22
- end
23
- end
24
- end
1
+ module FlutterRb
2
+ # Base class for all checks
3
+ # Class provides default methods structure
4
+ # All methods using for create reports
5
+ class Check
6
+ UNIMPLEMENTED_ERROR = 'Error: missing method'.freeze
7
+
8
+ def name
9
+ raise UNIMPLEMENTED_ERROR
10
+ end
11
+
12
+ def summary
13
+ raise UNIMPLEMENTED_ERROR
14
+ end
15
+
16
+ def description
17
+ 'No provided'
18
+ end
19
+
20
+ def check
21
+ raise UNIMPLEMENTED_ERROR
22
+ end
23
+ end
24
+ end