ducalis 0.10.0 → 0.11.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/.rubocop.yml +1 -1
- data/.travis.yml +0 -1
- data/Gemfile.lock +14 -12
- data/bin/ducalis +1 -1
- data/config/.ducalis.yml +14 -6
- data/ducalis.gemspec +2 -3
- data/lib/ducalis.rb +2 -0
- data/lib/ducalis/commentators/github.rb +1 -1
- data/lib/ducalis/cops/descriptive_block_names.rb +1 -1
- data/lib/ducalis/cops/facade_pattern.rb +34 -0
- data/lib/ducalis/cops/preferable_methods.rb +1 -1
- data/lib/ducalis/cops/recursion.rb +27 -0
- data/lib/ducalis/documentation.rb +12 -12
- data/lib/ducalis/git_access.rb +3 -3
- data/lib/ducalis/utils.rb +3 -1
- data/lib/ducalis/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 452d05fc9f37618eee52ef036528d6c931a24a012c41725c1cf2d31e85218815
|
|
4
|
+
data.tar.gz: dcb1cce57dbed25a8bb811cac2e18ff449554e60156345dd8bd0a64e0d400316
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 522c28511c7ee1c9c8fd951b1cbfe097c8afb8d2f472b281d602ec9de6e5090d225790757ebea7a8a0e747930ca27fb06a32fd56522c86a47ee5906180cc28d0
|
|
7
|
+
data.tar.gz: 0db1d6f104b52f5dfb23f1953d1415e1578736d8743f358839ea310a7ac4a6218301a5333fc59b21ed328742a34a5ef2996951450e1849bb058cf040191fd2f3
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
ducalis (0.
|
|
4
|
+
ducalis (0.11.0)
|
|
5
5
|
git (~> 1.3, >= 1.3.0)
|
|
6
|
-
octokit (>= 4.
|
|
6
|
+
octokit (>= 4.7.0)
|
|
7
7
|
regexp-examples (~> 1.3, >= 1.3.2)
|
|
8
8
|
rubocop (>= 0.45.0)
|
|
9
9
|
|
|
@@ -15,24 +15,25 @@ GEM
|
|
|
15
15
|
ast (2.4.0)
|
|
16
16
|
coderay (1.1.2)
|
|
17
17
|
diff-lcs (1.3)
|
|
18
|
-
faraday (0.15.
|
|
18
|
+
faraday (0.15.2)
|
|
19
19
|
multipart-post (>= 1.2, < 3)
|
|
20
|
-
git (1.
|
|
20
|
+
git (1.4.0)
|
|
21
|
+
jaro_winkler (1.5.1)
|
|
21
22
|
method_source (0.9.0)
|
|
22
23
|
multipart-post (2.0.0)
|
|
23
|
-
octokit (4.
|
|
24
|
+
octokit (4.9.0)
|
|
24
25
|
sawyer (~> 0.8.0, >= 0.5.3)
|
|
25
26
|
parallel (1.12.1)
|
|
26
|
-
parser (2.5.
|
|
27
|
+
parser (2.5.1.2)
|
|
27
28
|
ast (~> 2.4.0)
|
|
28
|
-
powerpack (0.1.
|
|
29
|
+
powerpack (0.1.2)
|
|
29
30
|
pry (0.11.3)
|
|
30
31
|
coderay (~> 1.1.0)
|
|
31
32
|
method_source (~> 0.9.0)
|
|
32
33
|
public_suffix (3.0.2)
|
|
33
34
|
rainbow (3.0.0)
|
|
34
35
|
rake (12.3.0)
|
|
35
|
-
regexp-examples (1.4.
|
|
36
|
+
regexp-examples (1.4.3)
|
|
36
37
|
rspec (3.7.0)
|
|
37
38
|
rspec-core (~> 3.7.0)
|
|
38
39
|
rspec-expectations (~> 3.7.0)
|
|
@@ -46,19 +47,20 @@ GEM
|
|
|
46
47
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
47
48
|
rspec-support (~> 3.7.0)
|
|
48
49
|
rspec-support (3.7.1)
|
|
49
|
-
rubocop (0.
|
|
50
|
+
rubocop (0.58.2)
|
|
51
|
+
jaro_winkler (~> 1.5.1)
|
|
50
52
|
parallel (~> 1.10)
|
|
51
|
-
parser (>= 2.
|
|
53
|
+
parser (>= 2.5, != 2.5.1.1)
|
|
52
54
|
powerpack (~> 0.1)
|
|
53
55
|
rainbow (>= 2.2.2, < 4.0)
|
|
54
56
|
ruby-progressbar (~> 1.7)
|
|
55
57
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
56
|
-
ruby-progressbar (1.
|
|
58
|
+
ruby-progressbar (1.10.0)
|
|
57
59
|
sawyer (0.8.1)
|
|
58
60
|
addressable (>= 2.3.5, < 2.6)
|
|
59
61
|
faraday (~> 0.8, < 1.0)
|
|
60
62
|
single_cov (1.0.3)
|
|
61
|
-
unicode-display_width (1.
|
|
63
|
+
unicode-display_width (1.4.0)
|
|
62
64
|
|
|
63
65
|
PLATFORMS
|
|
64
66
|
ruby
|
data/bin/ducalis
CHANGED
|
@@ -9,7 +9,7 @@ require 'benchmark'
|
|
|
9
9
|
cli_arguments = Ducalis::CliArguments.new
|
|
10
10
|
|
|
11
11
|
if cli_arguments.help_command?
|
|
12
|
-
puts 'You can start Ducalis in the
|
|
12
|
+
puts 'You can start Ducalis in the following modes:'
|
|
13
13
|
puts ' --branch check files in RuboCop style against branch.'
|
|
14
14
|
puts ' --index check files in RuboCop style against index.'
|
|
15
15
|
puts ' --all [default] check all files in RuboCop style.'
|
data/config/.ducalis.yml
CHANGED
|
@@ -9,16 +9,17 @@ AllCops:
|
|
|
9
9
|
Ducalis/BlackListSuffix:
|
|
10
10
|
Enabled: true
|
|
11
11
|
BlackList:
|
|
12
|
-
-
|
|
13
|
-
- Manager
|
|
12
|
+
- Analyzer
|
|
14
13
|
- Client
|
|
15
|
-
- Object
|
|
16
14
|
- Handler
|
|
17
|
-
-
|
|
15
|
+
- Loader
|
|
16
|
+
- Manager
|
|
17
|
+
- Object
|
|
18
18
|
- Organizer
|
|
19
|
-
-
|
|
19
|
+
- Processor
|
|
20
20
|
- Renderer
|
|
21
|
-
-
|
|
21
|
+
- Service
|
|
22
|
+
- Sorter
|
|
22
23
|
|
|
23
24
|
Ducalis/EnforceNamespace:
|
|
24
25
|
Enabled: true
|
|
@@ -27,9 +28,16 @@ Ducalis/EnforceNamespace:
|
|
|
27
28
|
Ducalis/PreferableMethods:
|
|
28
29
|
Enabled: true
|
|
29
30
|
|
|
31
|
+
Ducalis/Recursion:
|
|
32
|
+
Enabled: true
|
|
33
|
+
|
|
30
34
|
Ducalis/CaseMapping:
|
|
31
35
|
Enabled: true
|
|
32
36
|
|
|
37
|
+
Ducalis/FacadePattern:
|
|
38
|
+
Enabled: true
|
|
39
|
+
MaxInstanceVariables: 4
|
|
40
|
+
|
|
33
41
|
Ducalis/CallbacksActiverecord:
|
|
34
42
|
Enabled: true
|
|
35
43
|
|
data/ducalis.gemspec
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
1
|
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
lib = File.expand_path('
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
|
5
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
5
|
require 'ducalis/version'
|
|
7
6
|
|
|
@@ -29,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
|
29
28
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
30
29
|
|
|
31
30
|
spec.add_dependency 'git', '~> 1.3', '>= 1.3.0'
|
|
32
|
-
spec.add_dependency 'octokit', '>= 4.
|
|
31
|
+
spec.add_dependency 'octokit', '>= 4.7.0'
|
|
33
32
|
spec.add_dependency 'regexp-examples', '~> 1.3', '>= 1.3.2'
|
|
34
33
|
spec.add_dependency 'rubocop', '>= 0.45.0'
|
|
35
34
|
end
|
data/lib/ducalis.rb
CHANGED
|
@@ -39,6 +39,7 @@ require 'ducalis/cops/descriptive_block_names'
|
|
|
39
39
|
require 'ducalis/cops/enforce_namespace'
|
|
40
40
|
require 'ducalis/cops/evlis_overusing'
|
|
41
41
|
require 'ducalis/cops/extensions/type_resolving'
|
|
42
|
+
require 'ducalis/cops/facade_pattern'
|
|
42
43
|
require 'ducalis/cops/fetch_expression'
|
|
43
44
|
require 'ducalis/cops/keyword_defaults'
|
|
44
45
|
require 'ducalis/cops/module_like_class'
|
|
@@ -52,6 +53,7 @@ require 'ducalis/cops/private_instance_assign'
|
|
|
52
53
|
require 'ducalis/cops/protected_scope_cop'
|
|
53
54
|
require 'ducalis/cops/public_send'
|
|
54
55
|
require 'ducalis/cops/raise_without_error_class'
|
|
56
|
+
require 'ducalis/cops/recursion'
|
|
55
57
|
require 'ducalis/cops/regex_cop'
|
|
56
58
|
require 'ducalis/cops/rest_only_cop'
|
|
57
59
|
require 'ducalis/cops/rubocop_disable'
|
|
@@ -5,7 +5,7 @@ require 'rubocop'
|
|
|
5
5
|
module Ducalis
|
|
6
6
|
class DescriptiveBlockNames < RuboCop::Cop::Cop
|
|
7
7
|
OFFENSE = <<-MESSAGE.gsub(/^ +\|\s/, '').strip
|
|
8
|
-
| Please, use descriptive names as block arguments. There is no any
|
|
8
|
+
| Please, use descriptive names as block arguments. There is no any sense to save on letters.
|
|
9
9
|
MESSAGE
|
|
10
10
|
|
|
11
11
|
def on_block(node)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rubocop'
|
|
4
|
+
require 'ducalis/cops/extensions/type_resolving'
|
|
5
|
+
|
|
6
|
+
module Ducalis
|
|
7
|
+
class FacadePattern < RuboCop::Cop::Cop
|
|
8
|
+
include RuboCop::Cop::DefNode
|
|
9
|
+
prepend TypeResolving
|
|
10
|
+
|
|
11
|
+
OFFENSE = <<-MESSAGE.gsub(/^ +\|\s/, '').strip
|
|
12
|
+
| There are too many instance variables for one controller action. It's beetter to refactor it with Facade pattern to simplify the controller.
|
|
13
|
+
MESSAGE
|
|
14
|
+
|
|
15
|
+
DETAILS = <<-MESSAGE.gsub(/^ +\|\s/, '').strip
|
|
16
|
+
| Good article about [Facade](<https://medium.com/kkempin/facade-design-pattern-in-ruby-on-rails-710aa88326f>).
|
|
17
|
+
MESSAGE
|
|
18
|
+
|
|
19
|
+
def on_def(node)
|
|
20
|
+
return unless in_controller?
|
|
21
|
+
return if non_public?(node)
|
|
22
|
+
return if instance_variables_matches(node).count < max_instance_variables
|
|
23
|
+
add_offense(node, :expression, OFFENSE)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def max_instance_variables
|
|
29
|
+
cop_config.fetch('MaxInstanceVariables')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def_node_search :instance_variables_matches, '(ivasgn ...)'
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -69,7 +69,7 @@ module Ducalis
|
|
|
69
69
|
|
|
70
70
|
def on_send(node)
|
|
71
71
|
who, what, *args = *node
|
|
72
|
-
return unless DESCRIPTION.
|
|
72
|
+
return unless DESCRIPTION.key?(what)
|
|
73
73
|
alternative, reason, condition = DESCRIPTION.fetch(what)
|
|
74
74
|
return unless condition.call(who, what, args)
|
|
75
75
|
add_offense(node, :expression, format(OFFENSE, original: what,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rubocop'
|
|
4
|
+
|
|
5
|
+
module Ducalis
|
|
6
|
+
class Recursion < RuboCop::Cop::Cop
|
|
7
|
+
OFFENSE = <<-MESSAGE.gsub(/^ +\|\s/, '').strip
|
|
8
|
+
It seems like you are using recursion in your code. In common, it is not a bad idea, but try to keep your business logic layer free from refursion code.
|
|
9
|
+
MESSAGE
|
|
10
|
+
|
|
11
|
+
def on_def(node)
|
|
12
|
+
@method_name, _args, body = *node
|
|
13
|
+
return unless body
|
|
14
|
+
return unless send_call?(body) || send_self_call?(body)
|
|
15
|
+
add_offense(node, :expression, OFFENSE)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def call_itself?(call_name)
|
|
21
|
+
@method_name == call_name
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def_node_search :send_call?, '(send nil? #call_itself? ...)'
|
|
25
|
+
def_node_search :send_self_call?, '(send (self) #call_itself? ...)'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -79,8 +79,8 @@ class Documentation
|
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
def call
|
|
82
|
-
cops.map do |
|
|
83
|
-
present_cop(klass_const_for(
|
|
82
|
+
cops.map do |file|
|
|
83
|
+
present_cop(klass_const_for(file), spec_cases_for(file))
|
|
84
84
|
end.flatten.join("\n")
|
|
85
85
|
end
|
|
86
86
|
|
|
@@ -103,12 +103,12 @@ class Documentation
|
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
def prepare(
|
|
107
|
-
|
|
106
|
+
def prepare(it_description)
|
|
107
|
+
it_description.sub("#{RULE_WORD} ", '')
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
def mention(
|
|
111
|
-
|
|
110
|
+
def mention(it_description)
|
|
111
|
+
it_description.include?(SIGNAL_WORD) ? '# bad' : '# good'
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
def message(klass)
|
|
@@ -118,10 +118,10 @@ class Documentation
|
|
|
118
118
|
].join("\n")
|
|
119
119
|
end
|
|
120
120
|
|
|
121
|
-
def spec_cases_for(
|
|
121
|
+
def spec_cases_for(file)
|
|
122
122
|
source_code = File.read(
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
file.sub('/lib/', '/spec/')
|
|
124
|
+
.sub(/.rb$/, '_spec.rb')
|
|
125
125
|
)
|
|
126
126
|
SpecsProcessor.new.tap do |processor|
|
|
127
127
|
processor.process(Parser::CurrentRuby.parse(source_code))
|
|
@@ -133,9 +133,9 @@ class Documentation
|
|
|
133
133
|
desc.include?(RULE_WORD)
|
|
134
134
|
end
|
|
135
135
|
|
|
136
|
-
def klass_const_for(
|
|
137
|
-
require
|
|
138
|
-
Ducalis.const_get(camelize(File.basename(
|
|
136
|
+
def klass_const_for(file)
|
|
137
|
+
require file
|
|
138
|
+
Ducalis.const_get(camelize(File.basename(file).sub(/.rb$/, '')))
|
|
139
139
|
end
|
|
140
140
|
|
|
141
141
|
def camelize(snake_case_word)
|
data/lib/ducalis/git_access.rb
CHANGED
|
@@ -28,18 +28,18 @@ class GitAccess
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def for(path)
|
|
31
|
-
find(path)
|
|
31
|
+
find(Pathname.new(path).relative_path_from(Pathname.new(Dir.pwd)).to_s)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
private
|
|
35
35
|
|
|
36
36
|
def under_git?
|
|
37
|
-
@
|
|
37
|
+
@under_git ||= Dir.exist?(File.join(Dir.pwd, GIT_DIR))
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def changes
|
|
41
41
|
return default_value if flag.nil? || !under_git?
|
|
42
|
-
@
|
|
42
|
+
@changes ||= patch_diffs
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def patch_diffs
|
data/lib/ducalis/utils.rb
CHANGED
|
@@ -9,7 +9,9 @@ module Ducalis
|
|
|
9
9
|
def octokit
|
|
10
10
|
@octokit ||= begin
|
|
11
11
|
token = ENV.fetch('GITHUB_TOKEN') { raise MissingToken }
|
|
12
|
-
Octokit::Client.new(access_token: token)
|
|
12
|
+
Octokit::Client.new(access_token: token).tap do |client|
|
|
13
|
+
client.auto_paginate = true
|
|
14
|
+
end
|
|
13
15
|
end
|
|
14
16
|
end
|
|
15
17
|
|
data/lib/ducalis/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ducalis
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ignat Zakrevsky
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-08-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: git
|
|
@@ -36,14 +36,14 @@ dependencies:
|
|
|
36
36
|
requirements:
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 4.
|
|
39
|
+
version: 4.7.0
|
|
40
40
|
type: :runtime
|
|
41
41
|
prerelease: false
|
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
44
|
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 4.
|
|
46
|
+
version: 4.7.0
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: regexp-examples
|
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -117,6 +117,7 @@ files:
|
|
|
117
117
|
- lib/ducalis/cops/enforce_namespace.rb
|
|
118
118
|
- lib/ducalis/cops/evlis_overusing.rb
|
|
119
119
|
- lib/ducalis/cops/extensions/type_resolving.rb
|
|
120
|
+
- lib/ducalis/cops/facade_pattern.rb
|
|
120
121
|
- lib/ducalis/cops/fetch_expression.rb
|
|
121
122
|
- lib/ducalis/cops/keyword_defaults.rb
|
|
122
123
|
- lib/ducalis/cops/module_like_class.rb
|
|
@@ -130,6 +131,7 @@ files:
|
|
|
130
131
|
- lib/ducalis/cops/protected_scope_cop.rb
|
|
131
132
|
- lib/ducalis/cops/public_send.rb
|
|
132
133
|
- lib/ducalis/cops/raise_without_error_class.rb
|
|
134
|
+
- lib/ducalis/cops/recursion.rb
|
|
133
135
|
- lib/ducalis/cops/regex_cop.rb
|
|
134
136
|
- lib/ducalis/cops/rest_only_cop.rb
|
|
135
137
|
- lib/ducalis/cops/rubocop_disable.rb
|