rubocop-config-captive 1.0.0.pre.alpha.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/Gemfile +13 -0
- data/README.md +56 -0
- data/lib/rubocop/captive/inject.rb +20 -0
- data/lib/rubocop/captive.rb +16 -0
- data/lib/rubocop/cop/captive/active_admin/active_admin_addons_presence.rb +29 -0
- data/lib/rubocop/cop/captive/string_where_in_scope.rb +24 -0
- data/lib/rubocop/cop/captive/translation/devise_i18n_presence.rb +29 -0
- data/lib/rubocop/cop/captive/translation/kaminari_i18n_presence.rb +31 -0
- data/lib/rubocop/cop/captive/translation/rails_i18n_presence.rb +31 -0
- data/lib/rubocop-captive.rb +14 -0
- data/rubocop-config-captive.gemspec +33 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 89d38bf5656750c061e2f17069a6b5b9e2919d462cc1fb527c15896cf807c751
|
4
|
+
data.tar.gz: 700106edcfd7d46a29150039913a00d1033c6c80ba222cf54c4754da0d729a75
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d24d1dff0a51f0fa491d7233ccc9a2e5b7f9d1ca14519feaa6c65120c3694455bc353e044d625848bad04c53ea69a733ca35fe834ec5449a126deaca64cd75a3
|
7
|
+
data.tar.gz: d79d9497e83fcfbb5b26cee87bc7fea4b1d017899bda5b75baf22f9cfcac5977589ba5efb870a9f80b07f7d62f9f2b135d698a0503426e3c1682e702b25b5339
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Captive Rubocop config
|
2
|
+
|
3
|
+
[![License][license-image]][license-url]
|
4
|
+
|
5
|
+
> Rubocop shared configurations for projects
|
6
|
+
|
7
|
+
## Install
|
8
|
+
|
9
|
+
add the follow line into your `Gemfile`
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
group :test, :development do
|
13
|
+
gem 'rubocop-config-captive', github: 'Captive-Studio/rubocop-config'
|
14
|
+
end
|
15
|
+
```
|
16
|
+
|
17
|
+
And then in a terminal
|
18
|
+
|
19
|
+
```console
|
20
|
+
$ bundle install
|
21
|
+
[...]
|
22
|
+
```
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
```yml
|
27
|
+
# /.rubocop.yml
|
28
|
+
inherit_gem:
|
29
|
+
rubocop-config-captive:
|
30
|
+
- config/default.yml
|
31
|
+
# -OR-
|
32
|
+
# - config/rubocop-XXX.yml
|
33
|
+
```
|
34
|
+
|
35
|
+
## My project has too many errors
|
36
|
+
|
37
|
+
Firstly, you can use `bundle exec rubocop -a` to auto-correct your project
|
38
|
+
|
39
|
+
Then if you have too many warnings, you can use the command line :
|
40
|
+
|
41
|
+
`bundle exec rubocop --auto-gen-config` to create `.rubocop_todo.yml` file that ignore these errors
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
To contribute, here are some inspirations for good configurations :
|
46
|
+
|
47
|
+
- [Airbnb](https://github.com/airbnb/ruby/tree/main/rubocop-airbnb)
|
48
|
+
|
49
|
+
## License
|
50
|
+
<!-- AUTO-GENERATED-CONTENT:START (PKG_JSON:template=[${license}][license-url] © ${author}) -->
|
51
|
+
[MIT][license-url] © Captive Studio <julien.polo@captive.fr>
|
52
|
+
|
53
|
+
<!-- AUTO-GENERATED-CONTENT:START (PKG_JSON:template=[license-image]: https://img.shields.io/badge/license-${license}-green.svg?style=flat-square) -->
|
54
|
+
[license-image]: https://img.shields.io/badge/license-MIT-green.svg?style=flat-square
|
55
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
56
|
+
[license-url]: ./LICENSE
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Straight up ripped from the custom Rspec rubocop
|
2
|
+
# https://github.com/nevir/rubocop-rspec/blob/master/lib/rubocop/rspec/inject.rb
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Captive
|
7
|
+
# Because RuboCop doesn't yet support plugins, we have to monkey patch in a
|
8
|
+
# bit of our configuration.
|
9
|
+
module Inject
|
10
|
+
def self.defaults!
|
11
|
+
path = CONFIG_DEFAULT.to_s
|
12
|
+
hash = ConfigLoader.load_file(path).to_hash
|
13
|
+
config = Config.new(hash, path)
|
14
|
+
puts "configuration from #{path}" if ConfigLoader.debug?
|
15
|
+
config = ConfigLoader.merge_with_default(config, path)
|
16
|
+
ConfigLoader.instance_variable_set(:@default_configuration, config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'psych'
|
3
|
+
|
4
|
+
Dir.glob(File.expand_path('cop/**/*.rb', File.dirname(__FILE__))).map(&method(:require))
|
5
|
+
|
6
|
+
module RuboCop
|
7
|
+
# RuboCop Captive project namespace
|
8
|
+
module Captive
|
9
|
+
PROJECT_ROOT =
|
10
|
+
Pathname.new(__FILE__).parent.parent.parent.expand_path.freeze
|
11
|
+
CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
|
12
|
+
CONFIG = Psych.safe_load(CONFIG_DEFAULT.read).freeze
|
13
|
+
|
14
|
+
private_constant(*constants(false))
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Captive
|
6
|
+
module ActiveAdmin
|
7
|
+
class ActiveAdminAddonsPresence < RuboCop::Cop::Cop
|
8
|
+
MSG = "The gem `activeadmin_addons` should be added to the Gemfile "\
|
9
|
+
"if `activeadmin` is present in Gemfile"
|
10
|
+
|
11
|
+
def on_send(node)
|
12
|
+
return unless node.command?(:gem)
|
13
|
+
|
14
|
+
gem_name = node.arguments[0]&.value
|
15
|
+
return unless gem_name == 'activeadmin'
|
16
|
+
|
17
|
+
add_offense(node, message: MSG) unless activeadmin_addons_present?
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def activeadmin_addons_present?
|
23
|
+
Gem.loaded_specs.keys.include?('activeadmin_addons')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Captive
|
6
|
+
class StringWhereInScope < RuboCop::Cop::Cop
|
7
|
+
MSG = 'The `where` method should be used in a scope in a model.'
|
8
|
+
|
9
|
+
def_node_matcher :where_with_string?, <<~PATTERN
|
10
|
+
(send _ :where (str _) ...)
|
11
|
+
PATTERN
|
12
|
+
|
13
|
+
def on_send(node)
|
14
|
+
return unless where_with_string?(node)
|
15
|
+
|
16
|
+
options_node = node.arguments[0]
|
17
|
+
return if options_node&.hash_type?
|
18
|
+
|
19
|
+
add_offense(options_node, message: MSG)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Captive
|
6
|
+
module Translation
|
7
|
+
class DeviseI18nPresence < RuboCop::Cop::Cop
|
8
|
+
MSG = "The gem `devise-i18n` should be added to the Gemfile "\
|
9
|
+
"if `devise` is present in Gemfile"
|
10
|
+
|
11
|
+
def on_send(node)
|
12
|
+
return unless node.command?(:gem)
|
13
|
+
|
14
|
+
gem_name = node.arguments[0]&.value
|
15
|
+
return unless gem_name == 'devise'
|
16
|
+
|
17
|
+
add_offense(node, message: MSG) unless devise_i18n_present?
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def devise_i18n_present?
|
23
|
+
Gem.loaded_specs.keys.include?('devise-i18n')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubocop'
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
module Captive
|
8
|
+
module Translation
|
9
|
+
class KaminariI18nPresence < RuboCop::Cop::Cop
|
10
|
+
MSG = "The gem `kaminari-i18n` should be added to the Gemfile "\
|
11
|
+
"if `kaminari` is present in Gemfile"
|
12
|
+
|
13
|
+
def on_send(node)
|
14
|
+
return unless node.command?(:gem)
|
15
|
+
|
16
|
+
gem_name = node.arguments[0]&.value
|
17
|
+
return unless gem_name == 'kaminari'
|
18
|
+
|
19
|
+
add_offense(node, message: MSG) unless kaminari_i18n_present?
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def kaminari_i18n_present?
|
25
|
+
Gem.loaded_specs.keys.include?('kaminari-i18n')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubocop'
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
module Captive
|
8
|
+
module Translation
|
9
|
+
class RailsI18nPresence < RuboCop::Cop::Cop
|
10
|
+
MSG = "The gem `rails-i18n` should be added to the Gemfile "\
|
11
|
+
"if `rails` is present in Gemfile"
|
12
|
+
|
13
|
+
def on_send(node)
|
14
|
+
return unless node.command?(:gem)
|
15
|
+
|
16
|
+
gem_name = node.arguments[0]&.value
|
17
|
+
return unless gem_name == 'rails'
|
18
|
+
|
19
|
+
add_offense(node, message: MSG) unless rails_i18n_present?
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def rails_i18n_present?
|
25
|
+
Gem.loaded_specs.keys.include?('rails-i18n')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
# Load original rubocop gem
|
5
|
+
require 'rubocop'
|
6
|
+
|
7
|
+
require 'rubocop-performance'
|
8
|
+
require 'rubocop-rails'
|
9
|
+
|
10
|
+
require 'rubocop/captive'
|
11
|
+
require 'rubocop/captive/inject'
|
12
|
+
# require 'rubocop/airbnb/version'
|
13
|
+
|
14
|
+
RuboCop::Captive::Inject.defaults!
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'rubocop-config-captive'
|
5
|
+
gem.version = '1.0.0-alpha.3'
|
6
|
+
gem.summary = 'Shared rubocop configurations'
|
7
|
+
gem.description = 'Shared rubocop configuration for Captive projects'
|
8
|
+
gem.authors = ['Captive', 'Julien Polo', "Clément Prod'homme"]
|
9
|
+
gem.email = ['julien.polo@captive.fr']
|
10
|
+
gem.homepage = 'https://github.com/Captive-Studio/rubocop-config'
|
11
|
+
gem.license = 'MIT'
|
12
|
+
gem.required_ruby_version = '>= 2.5'
|
13
|
+
|
14
|
+
gem.files = Dir[
|
15
|
+
'{conf,lib}/**/*',
|
16
|
+
'*.md',
|
17
|
+
'*.gemspec',
|
18
|
+
'Gemfile',
|
19
|
+
]
|
20
|
+
|
21
|
+
# It is not clear what the level of support is provided by Airbnb
|
22
|
+
# ⚠️ Instead of depending on rubocop-airbnb we copy sources
|
23
|
+
#
|
24
|
+
# gem.add_dependency('rubocop-airbnb', '~> 4.0.0')
|
25
|
+
gem.add_dependency('rubocop', '~> 1.49.0')
|
26
|
+
gem.add_dependency('rubocop-performance', '~> 1.16.0 ')
|
27
|
+
gem.add_dependency('rubocop-rake', '~> 0.6.0')
|
28
|
+
gem.add_dependency('rubocop-rails', '~> 2.18.0')
|
29
|
+
gem.add_dependency('rubocop-rspec', '~> 2.19.0')
|
30
|
+
gem.add_dependency('rubocop-capybara', '~> 2.17.1')
|
31
|
+
gem.add_development_dependency('rspec', '~> 3.12')
|
32
|
+
# gem.metadata['rubygems_mfa_required'] = 'true'
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubocop-config-captive
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.pre.alpha.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Captive
|
8
|
+
- Julien Polo
|
9
|
+
- Clément Prod'homme
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2023-04-06 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rubocop
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.49.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 1.49.0
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rubocop-performance
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 1.16.0
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.16.0
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: rubocop-rake
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.6.0
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.6.0
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rubocop-rails
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 2.18.0
|
64
|
+
type: :runtime
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 2.18.0
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: rubocop-rspec
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.19.0
|
78
|
+
type: :runtime
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 2.19.0
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: rubocop-capybara
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 2.17.1
|
92
|
+
type: :runtime
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - "~>"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 2.17.1
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: rspec
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - "~>"
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '3.12'
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - "~>"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '3.12'
|
113
|
+
description: Shared rubocop configuration for Captive projects
|
114
|
+
email:
|
115
|
+
- julien.polo@captive.fr
|
116
|
+
executables: []
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- Gemfile
|
121
|
+
- README.md
|
122
|
+
- lib/rubocop-captive.rb
|
123
|
+
- lib/rubocop/captive.rb
|
124
|
+
- lib/rubocop/captive/inject.rb
|
125
|
+
- lib/rubocop/cop/captive/active_admin/active_admin_addons_presence.rb
|
126
|
+
- lib/rubocop/cop/captive/string_where_in_scope.rb
|
127
|
+
- lib/rubocop/cop/captive/translation/devise_i18n_presence.rb
|
128
|
+
- lib/rubocop/cop/captive/translation/kaminari_i18n_presence.rb
|
129
|
+
- lib/rubocop/cop/captive/translation/rails_i18n_presence.rb
|
130
|
+
- rubocop-config-captive.gemspec
|
131
|
+
homepage: https://github.com/Captive-Studio/rubocop-config
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '2.5'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">"
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: 1.3.1
|
149
|
+
requirements: []
|
150
|
+
rubygems_version: 3.3.26
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: Shared rubocop configurations
|
154
|
+
test_files: []
|