danger-android_ktlint_detekt 0.0.3
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 +7 -0
- data/.gitignore +4 -0
- data/.rubocop.yml +149 -0
- data/.travis.yml +12 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +145 -0
- data/Guardfile +19 -0
- data/LICENSE.txt +22 -0
- data/README.md +25 -0
- data/Rakefile +23 -0
- data/danger-android_ktlint_detekt-0.0.1.gem +0 -0
- data/danger-android_ktlint_detekt-0.0.2.gem +0 -0
- data/danger-android_ktlint_detekt.gemspec +51 -0
- data/lib/android_ktlint_detekt/gem_version.rb +3 -0
- data/lib/android_ktlint_detekt/plugin.rb +91 -0
- data/lib/danger_android_ktlint_detekt.rb +1 -0
- data/lib/danger_plugin.rb +1 -0
- data/spec/android_ktlint_detekt_spec.rb +46 -0
- data/spec/spec_helper.rb +65 -0
- metadata +217 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 180747490b02b2daa1c2a8666802456d681b3b1acb3007a5d1a7d358b4373e7f
|
|
4
|
+
data.tar.gz: 914c327729676f04ae5214aa88e177d821d01b6b81edf02095caa109eb9e9585
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 57d5c6e6894d1d2b567c7b430f2e1011f08d6c83668c68fd7c259723eccdf0d8591f687c029309a16a7f26408f49b1236dbd53f41398ea36bdf40060d1144765
|
|
7
|
+
data.tar.gz: e3c74d7fc9f23b18904c28481bff84ecdbd5943f93e7dd8ed9617af3c4491fea7a5ef86a0411500d4d0f361f049809e49675bf7b709d9acc98e35c6b66ffe020
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
|
|
2
|
+
|
|
3
|
+
# If you don't like these settings, just delete this file :)
|
|
4
|
+
|
|
5
|
+
Style/StringLiterals:
|
|
6
|
+
EnforcedStyle: double_quotes
|
|
7
|
+
Enabled: true
|
|
8
|
+
|
|
9
|
+
# kind_of? is a good way to check a type
|
|
10
|
+
Style/ClassCheck:
|
|
11
|
+
EnforcedStyle: kind_of?
|
|
12
|
+
|
|
13
|
+
# It's better to be more explicit about the type
|
|
14
|
+
Style/BracesAroundHashParameters:
|
|
15
|
+
Enabled: false
|
|
16
|
+
|
|
17
|
+
# specs sometimes have useless assignments, which is fine
|
|
18
|
+
Lint/UselessAssignment:
|
|
19
|
+
Exclude:
|
|
20
|
+
- '**/spec/**/*'
|
|
21
|
+
|
|
22
|
+
# We could potentially enable the 2 below:
|
|
23
|
+
Layout/IndentHash:
|
|
24
|
+
Enabled: false
|
|
25
|
+
|
|
26
|
+
Layout/AlignHash:
|
|
27
|
+
Enabled: false
|
|
28
|
+
|
|
29
|
+
# HoundCI doesn't like this rule
|
|
30
|
+
Layout/DotPosition:
|
|
31
|
+
Enabled: false
|
|
32
|
+
|
|
33
|
+
# We allow !! as it's an easy way to convert ot boolean
|
|
34
|
+
Style/DoubleNegation:
|
|
35
|
+
Enabled: false
|
|
36
|
+
|
|
37
|
+
# Cop supports --auto-correct.
|
|
38
|
+
Lint/UnusedBlockArgument:
|
|
39
|
+
Enabled: false
|
|
40
|
+
|
|
41
|
+
# We want to allow class Fastlane::Class
|
|
42
|
+
Style/ClassAndModuleChildren:
|
|
43
|
+
Enabled: false
|
|
44
|
+
|
|
45
|
+
Metrics/AbcSize:
|
|
46
|
+
Max: 60
|
|
47
|
+
|
|
48
|
+
# The %w might be confusing for new users
|
|
49
|
+
Style/WordArray:
|
|
50
|
+
MinSize: 19
|
|
51
|
+
|
|
52
|
+
# raise and fail are both okay
|
|
53
|
+
Style/SignalException:
|
|
54
|
+
Enabled: false
|
|
55
|
+
|
|
56
|
+
# Better too much 'return' than one missing
|
|
57
|
+
Style/RedundantReturn:
|
|
58
|
+
Enabled: false
|
|
59
|
+
|
|
60
|
+
# Having if in the same line might not always be good
|
|
61
|
+
Style/IfUnlessModifier:
|
|
62
|
+
Enabled: false
|
|
63
|
+
|
|
64
|
+
# and and or is okay
|
|
65
|
+
Style/AndOr:
|
|
66
|
+
Enabled: false
|
|
67
|
+
|
|
68
|
+
# Configuration parameters: CountComments.
|
|
69
|
+
Metrics/ClassLength:
|
|
70
|
+
Max: 350
|
|
71
|
+
|
|
72
|
+
Metrics/CyclomaticComplexity:
|
|
73
|
+
Max: 17
|
|
74
|
+
|
|
75
|
+
# Configuration parameters: AllowURI, URISchemes.
|
|
76
|
+
Metrics/LineLength:
|
|
77
|
+
Max: 370
|
|
78
|
+
|
|
79
|
+
# Configuration parameters: CountKeywordArgs.
|
|
80
|
+
Metrics/ParameterLists:
|
|
81
|
+
Max: 10
|
|
82
|
+
|
|
83
|
+
Metrics/PerceivedComplexity:
|
|
84
|
+
Max: 18
|
|
85
|
+
|
|
86
|
+
# Sometimes it's easier to read without guards
|
|
87
|
+
Style/GuardClause:
|
|
88
|
+
Enabled: false
|
|
89
|
+
|
|
90
|
+
# something = if something_else
|
|
91
|
+
# that's confusing
|
|
92
|
+
Style/ConditionalAssignment:
|
|
93
|
+
Enabled: false
|
|
94
|
+
|
|
95
|
+
# Better to have too much self than missing a self
|
|
96
|
+
Style/RedundantSelf:
|
|
97
|
+
Enabled: false
|
|
98
|
+
|
|
99
|
+
Metrics/MethodLength:
|
|
100
|
+
Max: 60
|
|
101
|
+
|
|
102
|
+
# We're not there yet
|
|
103
|
+
Style/Documentation:
|
|
104
|
+
Enabled: false
|
|
105
|
+
|
|
106
|
+
# Adds complexity
|
|
107
|
+
Style/IfInsideElse:
|
|
108
|
+
Enabled: false
|
|
109
|
+
|
|
110
|
+
# danger specific
|
|
111
|
+
|
|
112
|
+
Style/BlockComments:
|
|
113
|
+
Enabled: false
|
|
114
|
+
|
|
115
|
+
Layout/MultilineMethodCallIndentation:
|
|
116
|
+
EnforcedStyle: indented
|
|
117
|
+
|
|
118
|
+
# FIXME: 25
|
|
119
|
+
Metrics/BlockLength:
|
|
120
|
+
Max: 345
|
|
121
|
+
Exclude:
|
|
122
|
+
- "**/*_spec.rb"
|
|
123
|
+
|
|
124
|
+
Style/MixinGrouping:
|
|
125
|
+
Enabled: false
|
|
126
|
+
|
|
127
|
+
Style/FileName:
|
|
128
|
+
Enabled: false
|
|
129
|
+
|
|
130
|
+
Layout/IndentHeredoc:
|
|
131
|
+
Enabled: false
|
|
132
|
+
|
|
133
|
+
Style/SpecialGlobalVars:
|
|
134
|
+
Enabled: false
|
|
135
|
+
|
|
136
|
+
PercentLiteralDelimiters:
|
|
137
|
+
PreferredDelimiters:
|
|
138
|
+
"%": ()
|
|
139
|
+
"%i": ()
|
|
140
|
+
"%q": ()
|
|
141
|
+
"%Q": ()
|
|
142
|
+
"%r": "{}"
|
|
143
|
+
"%s": ()
|
|
144
|
+
"%w": ()
|
|
145
|
+
"%W": ()
|
|
146
|
+
"%x": ()
|
|
147
|
+
|
|
148
|
+
Security/YAMLLoad:
|
|
149
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
danger-android_ktlint_detekt (0.0.1)
|
|
5
|
+
danger-plugin-api (~> 1.0)
|
|
6
|
+
oga
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
addressable (2.7.0)
|
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
13
|
+
ansi (1.5.0)
|
|
14
|
+
ast (2.4.0)
|
|
15
|
+
claide (1.0.3)
|
|
16
|
+
claide-plugins (0.9.2)
|
|
17
|
+
cork
|
|
18
|
+
nap
|
|
19
|
+
open4 (~> 1.3)
|
|
20
|
+
coderay (1.1.2)
|
|
21
|
+
colored2 (3.1.2)
|
|
22
|
+
cork (0.3.0)
|
|
23
|
+
colored2 (~> 3.1)
|
|
24
|
+
danger (6.1.0)
|
|
25
|
+
claide (~> 1.0)
|
|
26
|
+
claide-plugins (>= 0.9.2)
|
|
27
|
+
colored2 (~> 3.1)
|
|
28
|
+
cork (~> 0.1)
|
|
29
|
+
faraday (~> 0.9)
|
|
30
|
+
faraday-http-cache (~> 2.0)
|
|
31
|
+
git (~> 1.5)
|
|
32
|
+
kramdown (~> 2.0)
|
|
33
|
+
kramdown-parser-gfm (~> 1.0)
|
|
34
|
+
no_proxy_fix
|
|
35
|
+
octokit (~> 4.7)
|
|
36
|
+
terminal-table (~> 1)
|
|
37
|
+
danger-plugin-api (1.0.0)
|
|
38
|
+
danger (> 2.0)
|
|
39
|
+
diff-lcs (1.3)
|
|
40
|
+
faraday (0.17.1)
|
|
41
|
+
multipart-post (>= 1.2, < 3)
|
|
42
|
+
faraday-http-cache (2.0.0)
|
|
43
|
+
faraday (~> 0.8)
|
|
44
|
+
ffi (1.11.3)
|
|
45
|
+
formatador (0.2.5)
|
|
46
|
+
git (1.5.0)
|
|
47
|
+
guard (2.14.1)
|
|
48
|
+
formatador (>= 0.2.4)
|
|
49
|
+
listen (>= 2.7, < 4.0)
|
|
50
|
+
lumberjack (~> 1.0)
|
|
51
|
+
nenv (~> 0.1)
|
|
52
|
+
notiffany (~> 0.0)
|
|
53
|
+
pry (>= 0.9.12)
|
|
54
|
+
shellany (~> 0.0)
|
|
55
|
+
thor (>= 0.18.1)
|
|
56
|
+
guard-compat (1.2.1)
|
|
57
|
+
guard-rspec (4.7.3)
|
|
58
|
+
guard (~> 2.1)
|
|
59
|
+
guard-compat (~> 1.1)
|
|
60
|
+
rspec (>= 2.99.0, < 4.0)
|
|
61
|
+
kramdown (2.1.0)
|
|
62
|
+
kramdown-parser-gfm (1.1.0)
|
|
63
|
+
kramdown (~> 2.0)
|
|
64
|
+
listen (3.0.7)
|
|
65
|
+
rb-fsevent (>= 0.9.3)
|
|
66
|
+
rb-inotify (>= 0.9.7)
|
|
67
|
+
lumberjack (1.0.12)
|
|
68
|
+
method_source (0.9.0)
|
|
69
|
+
multipart-post (2.1.1)
|
|
70
|
+
nap (1.1.0)
|
|
71
|
+
nenv (0.3.0)
|
|
72
|
+
no_proxy_fix (0.1.2)
|
|
73
|
+
notiffany (0.1.1)
|
|
74
|
+
nenv (~> 0.1)
|
|
75
|
+
shellany (~> 0.0)
|
|
76
|
+
octokit (4.14.0)
|
|
77
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
|
78
|
+
oga (3.0)
|
|
79
|
+
ast
|
|
80
|
+
ruby-ll (~> 2.1)
|
|
81
|
+
open4 (1.3.4)
|
|
82
|
+
parallel (1.12.1)
|
|
83
|
+
parser (2.4.0.2)
|
|
84
|
+
ast (~> 2.3)
|
|
85
|
+
powerpack (0.1.1)
|
|
86
|
+
pry (0.11.3)
|
|
87
|
+
coderay (~> 1.1.0)
|
|
88
|
+
method_source (~> 0.9.0)
|
|
89
|
+
public_suffix (4.0.1)
|
|
90
|
+
rainbow (3.0.0)
|
|
91
|
+
rake (10.5.0)
|
|
92
|
+
rb-fsevent (0.10.2)
|
|
93
|
+
rb-inotify (0.9.10)
|
|
94
|
+
ffi (>= 0.5.0, < 2)
|
|
95
|
+
rspec (3.7.0)
|
|
96
|
+
rspec-core (~> 3.7.0)
|
|
97
|
+
rspec-expectations (~> 3.7.0)
|
|
98
|
+
rspec-mocks (~> 3.7.0)
|
|
99
|
+
rspec-core (3.7.0)
|
|
100
|
+
rspec-support (~> 3.7.0)
|
|
101
|
+
rspec-expectations (3.7.0)
|
|
102
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
103
|
+
rspec-support (~> 3.7.0)
|
|
104
|
+
rspec-mocks (3.7.0)
|
|
105
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
106
|
+
rspec-support (~> 3.7.0)
|
|
107
|
+
rspec-support (3.7.0)
|
|
108
|
+
rubocop (0.52.0)
|
|
109
|
+
parallel (~> 1.10)
|
|
110
|
+
parser (>= 2.4.0.2, < 3.0)
|
|
111
|
+
powerpack (~> 0.1)
|
|
112
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
113
|
+
ruby-progressbar (~> 1.7)
|
|
114
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
115
|
+
ruby-ll (2.1.2)
|
|
116
|
+
ansi
|
|
117
|
+
ast
|
|
118
|
+
ruby-progressbar (1.9.0)
|
|
119
|
+
sawyer (0.8.2)
|
|
120
|
+
addressable (>= 2.3.5)
|
|
121
|
+
faraday (> 0.8, < 2.0)
|
|
122
|
+
shellany (0.0.1)
|
|
123
|
+
terminal-table (1.8.0)
|
|
124
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
|
125
|
+
thor (1.0.1)
|
|
126
|
+
unicode-display_width (1.6.0)
|
|
127
|
+
yard (0.9.20)
|
|
128
|
+
|
|
129
|
+
PLATFORMS
|
|
130
|
+
ruby
|
|
131
|
+
|
|
132
|
+
DEPENDENCIES
|
|
133
|
+
bundler
|
|
134
|
+
danger-android_ktlint_detekt!
|
|
135
|
+
guard (~> 2.14)
|
|
136
|
+
guard-rspec (~> 4.7)
|
|
137
|
+
listen (= 3.0.7)
|
|
138
|
+
pry
|
|
139
|
+
rake (~> 10.0)
|
|
140
|
+
rspec (~> 3.4)
|
|
141
|
+
rubocop
|
|
142
|
+
yard
|
|
143
|
+
|
|
144
|
+
BUNDLED WITH
|
|
145
|
+
2.1.2
|
data/Guardfile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# A guardfile for making Danger Plugins
|
|
2
|
+
# For more info see https://github.com/guard/guard#readme
|
|
3
|
+
|
|
4
|
+
# To run, use `bundle exec guard`.
|
|
5
|
+
|
|
6
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
|
7
|
+
require 'guard/rspec/dsl'
|
|
8
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
|
9
|
+
|
|
10
|
+
# RSpec files
|
|
11
|
+
rspec = dsl.rspec
|
|
12
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
|
13
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
|
14
|
+
watch(rspec.spec_files)
|
|
15
|
+
|
|
16
|
+
# Ruby files
|
|
17
|
+
ruby = dsl.ruby
|
|
18
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
|
19
|
+
end
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2019 Juan Manuel Pereira <juanmanuel.pereira1@gmail.com>
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Danger plugin for ktlint and detekt on Android
|
|
2
|
+
|
|
3
|
+
It helps users report ktlint and detekt issues via Danger.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
$ gem install danger-android_ktlint_detekt
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
Just add this to your Dangerfile:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
android_ktlint_detekt.ktlint_report_file = path_to_ktlint_xml
|
|
15
|
+
android_ktlint_detekt.detekt_report_file = path_to_detekt_xml
|
|
16
|
+
android_ktlint_detekt.report(inline_mode: true)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Development
|
|
20
|
+
|
|
21
|
+
1. Clone this repo
|
|
22
|
+
2. Run `bundle install` to setup dependencies.
|
|
23
|
+
3. Run `bundle exec rake spec` to run the tests.
|
|
24
|
+
4. Use `bundle exec guard` to automatically have tests run as you make changes.
|
|
25
|
+
5. Make your changes.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
Rake::Task['spec_docs'].invoke
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc 'Run RuboCop on the lib/specs directory'
|
|
16
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
|
17
|
+
task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
desc 'Ensure that the plugin passes `danger plugins lint`'
|
|
21
|
+
task :spec_docs do
|
|
22
|
+
sh 'bundle exec danger plugins lint'
|
|
23
|
+
end
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'android_ktlint_detekt/gem_version.rb'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'danger-android_ktlint_detekt'
|
|
8
|
+
spec.version = '0.0.3'
|
|
9
|
+
spec.authors = ['Juan Manuel Pereira']
|
|
10
|
+
spec.email = ['juanmanuel.pereira1@gmail.com']
|
|
11
|
+
spec.description = %q{Ktlint and Detekt plugin for Android projects.}
|
|
12
|
+
spec.summary = %q{Ktlint and Detekt plugin for Android projects.}
|
|
13
|
+
spec.homepage = 'https://github.com/jotaemepereira/danger-android_ktlint_detekt'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files`.split($/)
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ['lib']
|
|
20
|
+
|
|
21
|
+
spec.add_dependency 'oga'
|
|
22
|
+
|
|
23
|
+
spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
|
|
24
|
+
|
|
25
|
+
# General ruby development
|
|
26
|
+
spec.add_development_dependency 'bundler'
|
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
28
|
+
|
|
29
|
+
# Testing support
|
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
|
31
|
+
|
|
32
|
+
# Linting code and docs
|
|
33
|
+
spec.add_development_dependency "rubocop"
|
|
34
|
+
spec.add_development_dependency "yard"
|
|
35
|
+
|
|
36
|
+
# Makes testing easy via `bundle exec guard`
|
|
37
|
+
spec.add_development_dependency 'guard', '~> 2.14'
|
|
38
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
|
39
|
+
|
|
40
|
+
# If you want to work on older builds of ruby
|
|
41
|
+
spec.add_development_dependency 'listen', '3.0.7'
|
|
42
|
+
|
|
43
|
+
# This gives you the chance to run a REPL inside your tests
|
|
44
|
+
# via:
|
|
45
|
+
#
|
|
46
|
+
# require 'pry'
|
|
47
|
+
# binding.pry
|
|
48
|
+
#
|
|
49
|
+
# This will stop test execution and let you inspect the results
|
|
50
|
+
spec.add_development_dependency 'pry'
|
|
51
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
module Danger
|
|
2
|
+
# This library allows you to send messages via Danger for detekt and ktlint issues
|
|
3
|
+
#
|
|
4
|
+
# @example Ensure people are well warned about merging on Mondays
|
|
5
|
+
#
|
|
6
|
+
# android_ktlint_detekt.ktlint_report_file = path_to_ktlint_xml
|
|
7
|
+
# android_ktlint_detekt.detekt_report_file = path_to_detekt_xml
|
|
8
|
+
# android_ktlint_detekt.report(inline_mode: true)
|
|
9
|
+
#
|
|
10
|
+
# @see Juan Manuel Pereira/danger-android_ktlint_detekt
|
|
11
|
+
# @tags kotlin,android,ktlint,detekt
|
|
12
|
+
#
|
|
13
|
+
class DangerAndroidKtlintDetekt < Plugin
|
|
14
|
+
# A getter for `detekt_report_file`.
|
|
15
|
+
# Returns default path if not set
|
|
16
|
+
# @return [String]
|
|
17
|
+
attr_accessor :ktlint_report_file
|
|
18
|
+
|
|
19
|
+
def ktlint_report_file
|
|
20
|
+
return @ktlint_report_file || "beacon-ui/build/reports/ktlint/ktlintMainSourceSetCheck.xml"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# A getter for `detekt_report_file`.
|
|
24
|
+
# Returns default path if not set
|
|
25
|
+
# @return [String]
|
|
26
|
+
attr_accessor :detekt_report_file
|
|
27
|
+
|
|
28
|
+
def detekt_report_file
|
|
29
|
+
return @detekt_report_file || "beacon-ui/build/reports/detekt.xml"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
### PUBLIC METHODS
|
|
33
|
+
|
|
34
|
+
# Method to report ktlint + detekt messages
|
|
35
|
+
# @return [void]
|
|
36
|
+
def report
|
|
37
|
+
ktlint_report_file_complete = "#{Dir.pwd}/#{ktlint_report_file}"
|
|
38
|
+
detekt_report_file_complete= "#{Dir.pwd}/#{detekt_report_file}"
|
|
39
|
+
|
|
40
|
+
check_file_integrity(ktlint_report_file_complete)
|
|
41
|
+
check_file_integrity(detekt_report_file_complete)
|
|
42
|
+
|
|
43
|
+
ktlint_issues = read_issues_from_report(ktlint_report_file)
|
|
44
|
+
detekt_issues = read_issues_from_report(detekt_report_file)
|
|
45
|
+
|
|
46
|
+
report_issues(ktlint_issues)
|
|
47
|
+
report_issues(detekt_issues)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
def check_file_integrity(file)
|
|
53
|
+
raise "No XML file provided. Please provide a file route." if file.empty?
|
|
54
|
+
raise "No checkstyle file was found at #{file}" unless File.exist? file
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def read_issues_from_report(report_file)
|
|
58
|
+
file = File.open(report_file)
|
|
59
|
+
|
|
60
|
+
require "oga"
|
|
61
|
+
report = Oga.parse_xml(file)
|
|
62
|
+
|
|
63
|
+
report.xpath("//file")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def report_issues(issues)
|
|
67
|
+
target_files = (git.modified_files - git.deleted_files) + git.added_files
|
|
68
|
+
dir = "#{Dir.pwd}/"
|
|
69
|
+
|
|
70
|
+
issues.each do |file|
|
|
71
|
+
location = file.get("name")
|
|
72
|
+
filename = location.gsub(dir, "")
|
|
73
|
+
|
|
74
|
+
next unless (target_files.include? filename)
|
|
75
|
+
file.xpath("error").each do |error|
|
|
76
|
+
severity = error.get("severity")
|
|
77
|
+
message = error.get("message")
|
|
78
|
+
line = error.get("line")
|
|
79
|
+
|
|
80
|
+
if severity == "error"
|
|
81
|
+
send("fail", message, file: filename, line: line)
|
|
82
|
+
elsif severity == "warning"
|
|
83
|
+
send("warn", message, file: filename, line: line)
|
|
84
|
+
else
|
|
85
|
+
send("message", message, file: filename, line: line)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "android_ktlint_detekt/gem_version"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "android_ktlint_detekt/plugin"
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
|
2
|
+
|
|
3
|
+
module Danger
|
|
4
|
+
describe Danger::DangerAndroidKtlintDetekt do
|
|
5
|
+
it "should be a plugin" do
|
|
6
|
+
expect(Danger::DangerAndroidKtlintDetekt.new(nil)).to be_a Danger::Plugin
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
#
|
|
10
|
+
# You should test your custom attributes and methods here
|
|
11
|
+
#
|
|
12
|
+
describe "with Dangerfile" do
|
|
13
|
+
before do
|
|
14
|
+
@dangerfile = testing_dangerfile
|
|
15
|
+
@my_plugin = @dangerfile.android_ktlint_detekt
|
|
16
|
+
|
|
17
|
+
# mock the PR data
|
|
18
|
+
# you can then use this, eg. github.pr_author, later in the spec
|
|
19
|
+
json = File.read(File.dirname(__FILE__) + '/support/fixtures/github_pr.json') # example json: `curl https://api.github.com/repos/danger/danger-plugin-template/pulls/18 > github_pr.json`
|
|
20
|
+
allow(@my_plugin.github).to receive(:pr_json).and_return(json)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Some examples for writing tests
|
|
24
|
+
# You should replace these with your own.
|
|
25
|
+
|
|
26
|
+
# it "Warns on a monday" do
|
|
27
|
+
# monday_date = Date.parse("2016-07-11")
|
|
28
|
+
# allow(Date).to receive(:today).and_return monday_date
|
|
29
|
+
#
|
|
30
|
+
# @my_plugin.warn_on_mondays
|
|
31
|
+
#
|
|
32
|
+
# expect(@dangerfile.status_report[:warnings]).to eq(["Trying to merge code on a Monday"])
|
|
33
|
+
# end
|
|
34
|
+
#
|
|
35
|
+
# it "Does nothing on a tuesday" do
|
|
36
|
+
# monday_date = Date.parse("2016-07-12")
|
|
37
|
+
# allow(Date).to receive(:today).and_return monday_date
|
|
38
|
+
#
|
|
39
|
+
# @my_plugin.warn_on_mondays
|
|
40
|
+
#
|
|
41
|
+
# expect(@dangerfile.status_report[:warnings]).to eq([])
|
|
42
|
+
# end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require "pathname"
|
|
2
|
+
ROOT = Pathname.new(File.expand_path("../../", __FILE__))
|
|
3
|
+
$:.unshift((ROOT + "lib").to_s)
|
|
4
|
+
$:.unshift((ROOT + "spec").to_s)
|
|
5
|
+
|
|
6
|
+
require "bundler/setup"
|
|
7
|
+
require "pry"
|
|
8
|
+
|
|
9
|
+
require "rspec"
|
|
10
|
+
require "danger"
|
|
11
|
+
|
|
12
|
+
if `git remote -v` == ''
|
|
13
|
+
puts "You cannot run tests without setting a local git remote on this repo"
|
|
14
|
+
puts "It's a weird side-effect of Danger's internals."
|
|
15
|
+
exit(0)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Use coloured output, it's the best.
|
|
19
|
+
RSpec.configure do |config|
|
|
20
|
+
config.filter_gems_from_backtrace "bundler"
|
|
21
|
+
config.color = true
|
|
22
|
+
config.tty = true
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
require "danger_plugin"
|
|
26
|
+
|
|
27
|
+
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
|
28
|
+
# If you are expanding these files, see if it's already been done ^.
|
|
29
|
+
|
|
30
|
+
# A silent version of the user interface,
|
|
31
|
+
# it comes with an extra function `.string` which will
|
|
32
|
+
# strip all ANSI colours from the string.
|
|
33
|
+
|
|
34
|
+
# rubocop:disable Lint/NestedMethodDefinition
|
|
35
|
+
def testing_ui
|
|
36
|
+
@output = StringIO.new
|
|
37
|
+
def @output.winsize
|
|
38
|
+
[20, 9999]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
cork = Cork::Board.new(out: @output)
|
|
42
|
+
def cork.string
|
|
43
|
+
out.string.gsub(/\e\[([;\d]+)?m/, "")
|
|
44
|
+
end
|
|
45
|
+
cork
|
|
46
|
+
end
|
|
47
|
+
# rubocop:enable Lint/NestedMethodDefinition
|
|
48
|
+
|
|
49
|
+
# Example environment (ENV) that would come from
|
|
50
|
+
# running a PR on TravisCI
|
|
51
|
+
def testing_env
|
|
52
|
+
{
|
|
53
|
+
"HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
|
|
54
|
+
"TRAVIS_PULL_REQUEST" => "800",
|
|
55
|
+
"TRAVIS_REPO_SLUG" => "artsy/eigen",
|
|
56
|
+
"TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
|
|
57
|
+
"DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
|
|
58
|
+
}
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# A stubbed out Dangerfile for use in tests
|
|
62
|
+
def testing_dangerfile
|
|
63
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
|
64
|
+
Danger::Dangerfile.new(env, testing_ui)
|
|
65
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: danger-android_ktlint_detekt
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.3
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Juan Manuel Pereira
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-12-26 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: oga
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: danger-plugin-api
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: bundler
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
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: rspec
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '3.4'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '3.4'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rubocop
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: yard
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: guard
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '2.14'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '2.14'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: guard-rspec
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '4.7'
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - "~>"
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '4.7'
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: listen
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - '='
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: 3.0.7
|
|
146
|
+
type: :development
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - '='
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: 3.0.7
|
|
153
|
+
- !ruby/object:Gem::Dependency
|
|
154
|
+
name: pry
|
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - ">="
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: '0'
|
|
160
|
+
type: :development
|
|
161
|
+
prerelease: false
|
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
163
|
+
requirements:
|
|
164
|
+
- - ">="
|
|
165
|
+
- !ruby/object:Gem::Version
|
|
166
|
+
version: '0'
|
|
167
|
+
description: Ktlint and Detekt plugin for Android projects.
|
|
168
|
+
email:
|
|
169
|
+
- juanmanuel.pereira1@gmail.com
|
|
170
|
+
executables: []
|
|
171
|
+
extensions: []
|
|
172
|
+
extra_rdoc_files: []
|
|
173
|
+
files:
|
|
174
|
+
- ".gitignore"
|
|
175
|
+
- ".rubocop.yml"
|
|
176
|
+
- ".travis.yml"
|
|
177
|
+
- Gemfile
|
|
178
|
+
- Gemfile.lock
|
|
179
|
+
- Guardfile
|
|
180
|
+
- LICENSE.txt
|
|
181
|
+
- README.md
|
|
182
|
+
- Rakefile
|
|
183
|
+
- danger-android_ktlint_detekt-0.0.1.gem
|
|
184
|
+
- danger-android_ktlint_detekt-0.0.2.gem
|
|
185
|
+
- danger-android_ktlint_detekt.gemspec
|
|
186
|
+
- lib/android_ktlint_detekt/gem_version.rb
|
|
187
|
+
- lib/android_ktlint_detekt/plugin.rb
|
|
188
|
+
- lib/danger_android_ktlint_detekt.rb
|
|
189
|
+
- lib/danger_plugin.rb
|
|
190
|
+
- spec/android_ktlint_detekt_spec.rb
|
|
191
|
+
- spec/spec_helper.rb
|
|
192
|
+
homepage: https://github.com/jotaemepereira/danger-android_ktlint_detekt
|
|
193
|
+
licenses:
|
|
194
|
+
- MIT
|
|
195
|
+
metadata: {}
|
|
196
|
+
post_install_message:
|
|
197
|
+
rdoc_options: []
|
|
198
|
+
require_paths:
|
|
199
|
+
- lib
|
|
200
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
201
|
+
requirements:
|
|
202
|
+
- - ">="
|
|
203
|
+
- !ruby/object:Gem::Version
|
|
204
|
+
version: '0'
|
|
205
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
|
+
requirements:
|
|
207
|
+
- - ">="
|
|
208
|
+
- !ruby/object:Gem::Version
|
|
209
|
+
version: '0'
|
|
210
|
+
requirements: []
|
|
211
|
+
rubygems_version: 3.1.1
|
|
212
|
+
signing_key:
|
|
213
|
+
specification_version: 4
|
|
214
|
+
summary: Ktlint and Detekt plugin for Android projects.
|
|
215
|
+
test_files:
|
|
216
|
+
- spec/android_ktlint_detekt_spec.rb
|
|
217
|
+
- spec/spec_helper.rb
|