rubocop-codeur 0.1.18 → 0.3.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/.github/workflows/quality.yml +34 -0
- data/.github/workflows/test.yml +41 -0
- data/.gitignore +10 -0
- data/.rubocop.yml +9 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +74 -0
- data/LICENSE.txt +21 -0
- data/README.md +6 -3
- data/Rakefile +31 -0
- data/bin/console +15 -0
- data/bin/rake +29 -0
- data/bin/setup +8 -0
- data/config/default.yml +13 -0
- data/default.yml +73 -11
- data/lib/rubocop/codeur/inject.rb +20 -0
- data/lib/rubocop/codeur/version.rb +7 -0
- data/lib/rubocop/codeur.rb +17 -0
- data/lib/rubocop/cop/codeur/rails_app_patterns.rb +81 -0
- data/lib/rubocop/cop/codeur/rails_avoid_instance_methods_in_helpers.rb +37 -0
- data/lib/rubocop/cop/codeur_cops.rb +4 -0
- data/lib/rubocop-codeur.rb +11 -0
- data/rubocop-codeur.gemspec +27 -0
- metadata +29 -13
- data/MIT-LICENSE +0 -20
- data/lib/rubocop_codeur/version.rb +0 -5
- data/lib/rubocop_codeur.rb +0 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 420f3301ff009bf96c52547e4246fa419d902281f56c7f47700572a144c92f09
|
|
4
|
+
data.tar.gz: 5e9d83bbb45232a8d37ec82e6635a1861a5d6a30c600c65fe12d00f8bdb8ae2b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 207d14d404508d364b8abca572ae641ecf3c223b30cbdc69e9d3a665e9f54d6ee034081ef3d277bf8290026b62e2dbfb5f1619e393a8b6a5a7ae743dc8011c91
|
|
7
|
+
data.tar.gz: 0d71a43971ce29790b74fc25ecd5555c1d263a5edf8cc55a64e03c9be82419616a3e79b5ce4b304779bbe339f910c066db0ebe18d757c3c2bac560632afd9e94
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Quality audit
|
|
2
|
+
|
|
3
|
+
on: [pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
rubocop:
|
|
7
|
+
name: rubocop
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- name: Check out code
|
|
11
|
+
uses: actions/checkout@v1
|
|
12
|
+
- uses: ruby/setup-ruby@v1
|
|
13
|
+
with:
|
|
14
|
+
ruby-version: 2.7
|
|
15
|
+
bundler-cache: true
|
|
16
|
+
- name: Run Rubocop
|
|
17
|
+
uses: reviewdog/action-rubocop@v1
|
|
18
|
+
with:
|
|
19
|
+
github_token: ${{ secrets.github_token }}
|
|
20
|
+
rubocop_version: gemfile
|
|
21
|
+
reporter: github-pr-check
|
|
22
|
+
|
|
23
|
+
brakeman:
|
|
24
|
+
name: brakeman
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
steps:
|
|
27
|
+
- name: Check out code
|
|
28
|
+
uses: actions/checkout@v1
|
|
29
|
+
- name: Run Brakeman
|
|
30
|
+
uses: reviewdog/action-brakeman@v1
|
|
31
|
+
with:
|
|
32
|
+
github_token: ${{ secrets.github_token }}
|
|
33
|
+
brakeman_version: 5.0.4
|
|
34
|
+
reporter: github-pr-check
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
|
|
3
|
+
on: [pull_request]
|
|
4
|
+
|
|
5
|
+
env:
|
|
6
|
+
RAILS_ENV: test
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
ruby: ['2.7', '3.0']
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v2
|
|
19
|
+
|
|
20
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
|
21
|
+
uses: ruby/setup-ruby@v1
|
|
22
|
+
with:
|
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
|
24
|
+
bundler-cache: true
|
|
25
|
+
|
|
26
|
+
- name: Run tests
|
|
27
|
+
run: bin/rake test
|
|
28
|
+
env:
|
|
29
|
+
COVERAGE: true
|
|
30
|
+
|
|
31
|
+
- name: Simplecov Report
|
|
32
|
+
uses: aki77/simplecov-report-action@v1
|
|
33
|
+
with:
|
|
34
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
35
|
+
failedThreshold: 100
|
|
36
|
+
|
|
37
|
+
- name: Upload coverage
|
|
38
|
+
uses: actions/upload-artifact@v1
|
|
39
|
+
with:
|
|
40
|
+
name: Coverage
|
|
41
|
+
path: coverage
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source 'https://rubygems.org'
|
|
4
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
5
|
+
|
|
6
|
+
# Specify your gem's dependencies in rubocop-codeur.gemspec
|
|
7
|
+
gemspec
|
|
8
|
+
|
|
9
|
+
gem 'minitest', '~> 5.0'
|
|
10
|
+
gem 'rake', '~> 12.0'
|
|
11
|
+
gem 'rubocop-minitest', '~> 0.17'
|
|
12
|
+
gem 'simplecov', require: false
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
rubocop-codeur (0.3.0)
|
|
5
|
+
rubocop (~> 1.25)
|
|
6
|
+
rubocop-minitest (~> 0.10, >= 0.10.2)
|
|
7
|
+
rubocop-performance (~> 1.9, >= 1.9.2)
|
|
8
|
+
rubocop-rails (~> 2.9, >= 2.9.1)
|
|
9
|
+
|
|
10
|
+
GEM
|
|
11
|
+
remote: https://rubygems.org/
|
|
12
|
+
specs:
|
|
13
|
+
activesupport (7.0.1)
|
|
14
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
15
|
+
i18n (>= 1.6, < 2)
|
|
16
|
+
minitest (>= 5.1)
|
|
17
|
+
tzinfo (~> 2.0)
|
|
18
|
+
ast (2.4.2)
|
|
19
|
+
concurrent-ruby (1.1.9)
|
|
20
|
+
docile (1.4.0)
|
|
21
|
+
i18n (1.9.1)
|
|
22
|
+
concurrent-ruby (~> 1.0)
|
|
23
|
+
minitest (5.15.0)
|
|
24
|
+
parallel (1.21.0)
|
|
25
|
+
parser (3.1.0.0)
|
|
26
|
+
ast (~> 2.4.1)
|
|
27
|
+
rack (2.2.3)
|
|
28
|
+
rainbow (3.1.1)
|
|
29
|
+
rake (12.3.3)
|
|
30
|
+
regexp_parser (2.2.0)
|
|
31
|
+
rexml (3.2.5)
|
|
32
|
+
rubocop (1.25.0)
|
|
33
|
+
parallel (~> 1.10)
|
|
34
|
+
parser (>= 3.1.0.0)
|
|
35
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
36
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
37
|
+
rexml
|
|
38
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
|
39
|
+
ruby-progressbar (~> 1.7)
|
|
40
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
41
|
+
rubocop-ast (1.15.1)
|
|
42
|
+
parser (>= 3.0.1.1)
|
|
43
|
+
rubocop-minitest (0.17.0)
|
|
44
|
+
rubocop (>= 0.90, < 2.0)
|
|
45
|
+
rubocop-performance (1.13.2)
|
|
46
|
+
rubocop (>= 1.7.0, < 2.0)
|
|
47
|
+
rubocop-ast (>= 0.4.0)
|
|
48
|
+
rubocop-rails (2.13.2)
|
|
49
|
+
activesupport (>= 4.2.0)
|
|
50
|
+
rack (>= 1.1)
|
|
51
|
+
rubocop (>= 1.7.0, < 2.0)
|
|
52
|
+
ruby-progressbar (1.11.0)
|
|
53
|
+
simplecov (0.21.2)
|
|
54
|
+
docile (~> 1.1)
|
|
55
|
+
simplecov-html (~> 0.11)
|
|
56
|
+
simplecov_json_formatter (~> 0.1)
|
|
57
|
+
simplecov-html (0.12.3)
|
|
58
|
+
simplecov_json_formatter (0.1.3)
|
|
59
|
+
tzinfo (2.0.4)
|
|
60
|
+
concurrent-ruby (~> 1.0)
|
|
61
|
+
unicode-display_width (2.1.0)
|
|
62
|
+
|
|
63
|
+
PLATFORMS
|
|
64
|
+
ruby
|
|
65
|
+
|
|
66
|
+
DEPENDENCIES
|
|
67
|
+
minitest (~> 5.0)
|
|
68
|
+
rake (~> 12.0)
|
|
69
|
+
rubocop-codeur!
|
|
70
|
+
rubocop-minitest (~> 0.17)
|
|
71
|
+
simplecov
|
|
72
|
+
|
|
73
|
+
BUNDLED WITH
|
|
74
|
+
2.1.4
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright 2021 Codeur SARL
|
|
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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# RuboCop Codeur
|
|
2
2
|
Shared rubocop config gem for every Ruby projects at Codeur SARL
|
|
3
3
|
|
|
4
4
|
## Installation
|
|
@@ -25,9 +25,12 @@ Then run:
|
|
|
25
25
|
`bundle exec rubocop`
|
|
26
26
|
|
|
27
27
|
You don't need to include rubocop directly in your application's dependencies.
|
|
28
|
-
`rubocop-codeur` will include `rubocop`, `rubocop-minitest`, `rubocop-performance
|
|
28
|
+
`rubocop-codeur` will include `rubocop`, `rubocop-minitest`, `rubocop-performance`,
|
|
29
|
+
and `rubocop-rails` dependencies.
|
|
29
30
|
|
|
30
|
-
It might be necessary to override style rules set in this gem for some projects
|
|
31
|
+
It might be necessary to override style rules set in this gem for some projects
|
|
32
|
+
or to add specific ones. Rule inheritance provided by RuboCop works like the
|
|
33
|
+
following:
|
|
31
34
|
`inherit_gem → inherit_from → local rules`
|
|
32
35
|
|
|
33
36
|
For example:
|
data/Rakefile
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
require 'rake/testtask'
|
|
5
|
+
|
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
|
7
|
+
t.libs << 'test'
|
|
8
|
+
t.libs << 'lib'
|
|
9
|
+
t.test_files = FileList['test/**/*_test.rb']
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
task default: :test
|
|
13
|
+
|
|
14
|
+
desc 'Generate a new cop with a template'
|
|
15
|
+
task :new_cop, [:cop] do |_task, args|
|
|
16
|
+
require 'rubocop'
|
|
17
|
+
|
|
18
|
+
cop_name = args.fetch(:cop) do
|
|
19
|
+
warn 'usage: bundle exec rake new_cop[Department/Name]'
|
|
20
|
+
exit!
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
generator = RuboCop::Cop::Generator.new(cop_name)
|
|
24
|
+
|
|
25
|
+
generator.write_source
|
|
26
|
+
generator.write_spec
|
|
27
|
+
generator.inject_require(root_file_path: 'lib/rubocop/cop/codeur_cops.rb')
|
|
28
|
+
generator.inject_config(config_file_path: 'config/default.yml')
|
|
29
|
+
|
|
30
|
+
puts generator.todo
|
|
31
|
+
end
|
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require 'bundler/setup'
|
|
5
|
+
require 'rubocop/codeur'
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
+
# require "pry"
|
|
12
|
+
# Pry.start
|
|
13
|
+
|
|
14
|
+
require 'irb'
|
|
15
|
+
IRB.start(__FILE__)
|
data/bin/rake
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require 'pathname'
|
|
12
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
|
13
|
+
Pathname.new(__FILE__).realpath)
|
|
14
|
+
|
|
15
|
+
bundle_binstub = File.expand_path('bundle', __dir__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
require 'rubygems'
|
|
27
|
+
require 'bundler/setup'
|
|
28
|
+
|
|
29
|
+
load Gem.bin_path('rake', 'rake')
|
data/bin/setup
ADDED
data/config/default.yml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Codeur/RailsAppPatterns:
|
|
2
|
+
Description: 'Allows or forbids patterns in app directories'
|
|
3
|
+
Enabled: pending
|
|
4
|
+
VersionAdded: '0.2.0'
|
|
5
|
+
AllowedPatterns: []
|
|
6
|
+
ForbiddenPatterns: []
|
|
7
|
+
|
|
8
|
+
Codeur/RailsAvoidInstanceMethodsInHelpers:
|
|
9
|
+
Description: 'Forbids instance methods in Rails helpers'
|
|
10
|
+
Enabled: pending
|
|
11
|
+
VersionAdded: '0.2.0'
|
|
12
|
+
Include:
|
|
13
|
+
- app/helpers/**/*.rb
|
data/default.yml
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require:
|
|
2
|
+
- rubocop-codeur
|
|
2
3
|
- rubocop-minitest
|
|
3
4
|
- rubocop-performance
|
|
4
5
|
- rubocop-rails
|
|
@@ -20,29 +21,44 @@ AllCops:
|
|
|
20
21
|
Rails:
|
|
21
22
|
Enabled: true
|
|
22
23
|
|
|
24
|
+
Codeur/RailsAppPatterns:
|
|
25
|
+
Enabled: true
|
|
26
|
+
ForbiddenPatterns:
|
|
27
|
+
- presenters
|
|
28
|
+
- view_objects
|
|
29
|
+
- modules
|
|
30
|
+
|
|
31
|
+
Codeur/RailsAvoidInstanceMethodsInHelpers:
|
|
32
|
+
Enabled: true
|
|
33
|
+
|
|
23
34
|
Layout/AccessModifierIndentation:
|
|
35
|
+
Enabled: true
|
|
24
36
|
EnforcedStyle: outdent
|
|
25
37
|
IndentationWidth: 2
|
|
26
38
|
|
|
27
39
|
Layout/ArgumentAlignment:
|
|
40
|
+
Enabled: true
|
|
28
41
|
EnforcedStyle: with_first_argument
|
|
29
42
|
|
|
30
43
|
Layout/ClassStructure:
|
|
31
44
|
Enabled: true
|
|
32
45
|
AutoCorrect: false
|
|
33
46
|
ExpectedOrder:
|
|
47
|
+
- devise
|
|
34
48
|
- module_inclusion
|
|
35
49
|
- constants
|
|
36
50
|
- attributes
|
|
51
|
+
- has_ancestry
|
|
52
|
+
- delegated_type
|
|
37
53
|
- belongs_to
|
|
38
54
|
- has_many
|
|
39
55
|
- has_one
|
|
40
|
-
-
|
|
41
|
-
- has_attached_file
|
|
56
|
+
- attachments
|
|
42
57
|
- public_delegate
|
|
58
|
+
- class_macros
|
|
43
59
|
- callbacks
|
|
44
60
|
- state_machine
|
|
45
|
-
-
|
|
61
|
+
- aasm
|
|
46
62
|
- scope
|
|
47
63
|
- default_scope
|
|
48
64
|
- validations
|
|
@@ -59,20 +75,31 @@ Layout/ClassStructure:
|
|
|
59
75
|
- include
|
|
60
76
|
- prepend
|
|
61
77
|
- extend
|
|
78
|
+
attachments:
|
|
79
|
+
- has_one_attached
|
|
80
|
+
- has_many_attached
|
|
81
|
+
- has_attached_file
|
|
62
82
|
attributes:
|
|
63
|
-
- acts_as_voter
|
|
64
83
|
- attr_accessor
|
|
65
84
|
- attr_reader
|
|
66
85
|
- attr_writer
|
|
67
86
|
- attr_readonly
|
|
68
|
-
- devise
|
|
69
87
|
- emojify
|
|
70
88
|
- enum
|
|
71
|
-
- has_ancestry
|
|
72
89
|
- monetize
|
|
73
|
-
- pg_search_scope
|
|
74
90
|
- serialize
|
|
75
91
|
- has_secure_token
|
|
92
|
+
- alias_attribute
|
|
93
|
+
- slug
|
|
94
|
+
class_macros:
|
|
95
|
+
- acts_as_voter
|
|
96
|
+
- pg_search_scope
|
|
97
|
+
- counter_culture
|
|
98
|
+
- accepts_nested_attributes_for
|
|
99
|
+
- paginates_per
|
|
100
|
+
- ransack_alias
|
|
101
|
+
- ransacker
|
|
102
|
+
- ratyrate_rater
|
|
76
103
|
callbacks:
|
|
77
104
|
- before_validation
|
|
78
105
|
- after_validation
|
|
@@ -94,33 +121,43 @@ Layout/ClassStructure:
|
|
|
94
121
|
- validates
|
|
95
122
|
- validate
|
|
96
123
|
|
|
97
|
-
Lint/DuplicateMethods:
|
|
98
|
-
Exclude:
|
|
99
|
-
- 'db/migrate/*'
|
|
100
|
-
|
|
101
124
|
Layout/FirstArrayElementIndentation:
|
|
125
|
+
Enabled: true
|
|
102
126
|
EnforcedStyle: consistent
|
|
103
127
|
|
|
104
128
|
Layout/FirstHashElementIndentation:
|
|
129
|
+
Enabled: true
|
|
105
130
|
EnforcedStyle: consistent
|
|
106
131
|
|
|
107
132
|
Layout/HashAlignment:
|
|
133
|
+
Enabled: true
|
|
108
134
|
EnforcedHashRocketStyle: table
|
|
109
135
|
EnforcedColonStyle: table
|
|
110
136
|
|
|
111
137
|
Layout/LineLength:
|
|
138
|
+
Enabled: true
|
|
112
139
|
Max: 200
|
|
113
140
|
AutoCorrect: false
|
|
114
141
|
Exclude:
|
|
115
142
|
- 'db/migrate/*'
|
|
116
143
|
|
|
117
144
|
Layout/MultilineMethodCallIndentation:
|
|
145
|
+
Enabled: true
|
|
118
146
|
EnforcedStyle: indented
|
|
119
147
|
|
|
120
148
|
Layout/ParameterAlignment:
|
|
149
|
+
Enabled: true
|
|
121
150
|
EnforcedStyle: with_fixed_indentation
|
|
122
151
|
IndentationWidth: 2
|
|
123
152
|
|
|
153
|
+
Lint/DuplicateMethods:
|
|
154
|
+
Enabled: true
|
|
155
|
+
Exclude:
|
|
156
|
+
- 'db/migrate/*'
|
|
157
|
+
|
|
158
|
+
Lint/MissingSuper:
|
|
159
|
+
Enabled: false
|
|
160
|
+
|
|
124
161
|
Lint/RaiseException:
|
|
125
162
|
Enabled: true
|
|
126
163
|
|
|
@@ -128,11 +165,13 @@ Lint/StructNewOverride:
|
|
|
128
165
|
Enabled: true
|
|
129
166
|
|
|
130
167
|
Metrics/AbcSize:
|
|
168
|
+
Enabled: true
|
|
131
169
|
Max: 65
|
|
132
170
|
Exclude:
|
|
133
171
|
- 'db/migrate/*'
|
|
134
172
|
|
|
135
173
|
Metrics/BlockLength:
|
|
174
|
+
Enabled: true
|
|
136
175
|
Max: 60
|
|
137
176
|
Exclude:
|
|
138
177
|
- 'config/routes.rb'
|
|
@@ -140,28 +179,34 @@ Metrics/BlockLength:
|
|
|
140
179
|
- 'app/states/*'
|
|
141
180
|
|
|
142
181
|
Metrics/ClassLength:
|
|
182
|
+
Enabled: true
|
|
143
183
|
Max: 300
|
|
144
184
|
Exclude:
|
|
145
185
|
- 'app/models/**/*'
|
|
146
186
|
|
|
147
187
|
Metrics/CyclomaticComplexity:
|
|
188
|
+
Enabled: true
|
|
148
189
|
Max: 10
|
|
149
190
|
|
|
150
191
|
Metrics/MethodLength:
|
|
192
|
+
Enabled: true
|
|
151
193
|
Max: 60
|
|
152
194
|
Exclude:
|
|
153
195
|
- 'db/migrate/*'
|
|
154
196
|
|
|
155
197
|
Metrics/ModuleLength:
|
|
198
|
+
Enabled: true
|
|
156
199
|
Max: 300
|
|
157
200
|
|
|
158
201
|
Metrics/PerceivedComplexity:
|
|
202
|
+
Enabled: true
|
|
159
203
|
Max: 10
|
|
160
204
|
|
|
161
205
|
Minitest/TestMethodName:
|
|
162
206
|
Enabled: false
|
|
163
207
|
|
|
164
208
|
Minitest/MultipleAssertions:
|
|
209
|
+
Enabled: true
|
|
165
210
|
Max: 30
|
|
166
211
|
|
|
167
212
|
# Disabled because it doesn't with symbols like: record_001
|
|
@@ -172,16 +217,20 @@ Rails/BulkChangeTable:
|
|
|
172
217
|
Enabled: false
|
|
173
218
|
|
|
174
219
|
Rails/CreateTableWithTimestamps:
|
|
220
|
+
Enabled: true
|
|
175
221
|
Exclude:
|
|
176
222
|
- 'db/migrate/{2012,2013,2014,2015,2016,2017,2018}*.rb'
|
|
177
223
|
|
|
178
224
|
Rails/EnvironmentVariableAccess:
|
|
225
|
+
Enabled: true
|
|
179
226
|
AllowReads: true
|
|
180
227
|
|
|
181
228
|
Rails/FilePath:
|
|
229
|
+
Enabled: true
|
|
182
230
|
EnforcedStyle: arguments
|
|
183
231
|
|
|
184
232
|
Rails/ReversibleMigration:
|
|
233
|
+
Enabled: true
|
|
185
234
|
Exclude:
|
|
186
235
|
- 'db/migrate/{2012,2013,2014,2015,2016,2017,2018}*.rb'
|
|
187
236
|
|
|
@@ -199,6 +248,7 @@ Rails/TimeZone:
|
|
|
199
248
|
AutoCorrect: false
|
|
200
249
|
|
|
201
250
|
Rails/UnknownEnv:
|
|
251
|
+
Enabled: true
|
|
202
252
|
Environments:
|
|
203
253
|
- development
|
|
204
254
|
- test
|
|
@@ -209,6 +259,7 @@ Style/AsciiComments:
|
|
|
209
259
|
Enabled: false
|
|
210
260
|
|
|
211
261
|
Style/ClassAndModuleChildren:
|
|
262
|
+
Enabled: true
|
|
212
263
|
AutoCorrect: true
|
|
213
264
|
|
|
214
265
|
Style/ConditionalAssignment:
|
|
@@ -218,15 +269,21 @@ Style/Documentation:
|
|
|
218
269
|
Enabled: false
|
|
219
270
|
|
|
220
271
|
Style/EmptyMethod:
|
|
272
|
+
Enabled: true
|
|
221
273
|
EnforcedStyle: expanded
|
|
222
274
|
|
|
223
275
|
Style/GuardClause:
|
|
276
|
+
Enabled: true
|
|
224
277
|
MinBodyLength: 3
|
|
225
278
|
|
|
226
279
|
Style/HashEachMethods:
|
|
227
280
|
Enabled: true
|
|
228
281
|
AutoCorrect: true
|
|
229
282
|
|
|
283
|
+
Style/HashSyntax:
|
|
284
|
+
Enabled: true
|
|
285
|
+
EnforcedStyle: ruby19
|
|
286
|
+
|
|
230
287
|
Style/HashTransformKeys:
|
|
231
288
|
Enabled: true
|
|
232
289
|
AutoCorrect: true
|
|
@@ -247,7 +304,12 @@ Style/NestedTernaryOperator:
|
|
|
247
304
|
Style/NumericPredicate:
|
|
248
305
|
Enabled: false
|
|
249
306
|
|
|
307
|
+
Style/StringLiterals:
|
|
308
|
+
Enabled: true
|
|
309
|
+
EnforcedStyle: single_quotes
|
|
310
|
+
|
|
250
311
|
Style/SymbolArray:
|
|
312
|
+
Enabled: true
|
|
251
313
|
MinSize: 7
|
|
252
314
|
|
|
253
315
|
Style/FormatStringToken:
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# The original code is from https://github.com/rubocop/rubocop-rspec/blob/master/lib/rubocop/rspec/inject.rb
|
|
4
|
+
# See https://github.com/rubocop/rubocop-rspec/blob/master/MIT-LICENSE.md
|
|
5
|
+
module RuboCop
|
|
6
|
+
module Codeur
|
|
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.send(:load_yaml_configuration, path)
|
|
13
|
+
config = Config.new(hash, path).tap(&:make_excludes_absolute)
|
|
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,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rubocop/codeur/version'
|
|
4
|
+
require 'yaml'
|
|
5
|
+
|
|
6
|
+
module RuboCop
|
|
7
|
+
# RuboCop Codeur project namespace
|
|
8
|
+
module Codeur
|
|
9
|
+
class Error < StandardError; end
|
|
10
|
+
# Your code goes here...
|
|
11
|
+
PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
|
|
12
|
+
CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
|
|
13
|
+
CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
|
|
14
|
+
|
|
15
|
+
private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Codeur
|
|
6
|
+
# This cop makes sure that Rails app only uses patterns (app subdirectories)
|
|
7
|
+
# defined in Cop config.
|
|
8
|
+
#
|
|
9
|
+
# @example ForbiddenPatterns: [presenters, view_objects, uploaders, modules]
|
|
10
|
+
# # bad
|
|
11
|
+
# app/presenters/order_presenter.rb
|
|
12
|
+
#
|
|
13
|
+
# # bad
|
|
14
|
+
# app/modules/stuffy.rb
|
|
15
|
+
#
|
|
16
|
+
# # good
|
|
17
|
+
# app/view_components/order_component.rb
|
|
18
|
+
#
|
|
19
|
+
# # good
|
|
20
|
+
# app/models/concerns/stuffy.rb
|
|
21
|
+
#
|
|
22
|
+
# @example AllowedPatterns: [assets, controllers, javascript, jobs, mailers, models, views]
|
|
23
|
+
# # bad
|
|
24
|
+
# app/controller/some_controller.rb
|
|
25
|
+
#
|
|
26
|
+
# # good
|
|
27
|
+
# app/controllers/some_controller.rb
|
|
28
|
+
#
|
|
29
|
+
class RailsAppPatterns < Base
|
|
30
|
+
MSG_FORBIDDEN = '`%<pattern>s` are forbidden.'
|
|
31
|
+
MSG_NOT_ALLOWED = '`%<pattern>s` are not allowed. Allowed patterns are: %<allowed_patterns>s.'
|
|
32
|
+
|
|
33
|
+
def on_new_investigation
|
|
34
|
+
file_path = processed_source.file_path
|
|
35
|
+
return if config.file_to_exclude?(file_path)
|
|
36
|
+
|
|
37
|
+
for_bad_patterns(file_path) { |msg| add_global_offense(msg, severity: :warning) }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def for_bad_patterns(file_path)
|
|
43
|
+
pattern = pattern_from_path(file_path)
|
|
44
|
+
return if pattern.nil?
|
|
45
|
+
|
|
46
|
+
if pattern_forbidden?(pattern)
|
|
47
|
+
msg = format(MSG_FORBIDDEN, pattern: pattern)
|
|
48
|
+
elsif pattern_not_allowed?(pattern)
|
|
49
|
+
msg = format(MSG_NOT_ALLOWED,
|
|
50
|
+
pattern: pattern,
|
|
51
|
+
allowed_patterns: allowed_patterns.map { |p| "`#{p}`" }.join(', '))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
yield msg if msg
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def pattern_from_path(path)
|
|
58
|
+
return nil unless path.match(%r{/app/(?<pattern>.+)/.+})
|
|
59
|
+
|
|
60
|
+
Regexp.last_match(:pattern)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def pattern_forbidden?(pattern)
|
|
64
|
+
forbidden_patterns.any? && forbidden_patterns.include?(pattern)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def pattern_not_allowed?(pattern)
|
|
68
|
+
allowed_patterns.any? && !allowed_patterns.include?(pattern)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def allowed_patterns
|
|
72
|
+
cop_config['AllowedPatterns'] || []
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def forbidden_patterns
|
|
76
|
+
cop_config['ForbiddenPatterns'] || []
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Codeur
|
|
6
|
+
# This cop makes sure that Rails helpers only uses class methods in order
|
|
7
|
+
# to be able to use them in the test, views or from anywhere else.
|
|
8
|
+
# ApplicationHelper is excluded from this rule by default.
|
|
9
|
+
#
|
|
10
|
+
# @example
|
|
11
|
+
# # bad
|
|
12
|
+
# module CoolHelper
|
|
13
|
+
# def foobar
|
|
14
|
+
# # ...
|
|
15
|
+
# end
|
|
16
|
+
# end
|
|
17
|
+
#
|
|
18
|
+
# # good
|
|
19
|
+
# module CoolHelper
|
|
20
|
+
# def self.foobar
|
|
21
|
+
# # ...
|
|
22
|
+
# end
|
|
23
|
+
# end
|
|
24
|
+
#
|
|
25
|
+
class RailsAvoidInstanceMethodsInHelpers < Base
|
|
26
|
+
MSG = 'Prefer class methods in helpers.'
|
|
27
|
+
|
|
28
|
+
def on_def(node)
|
|
29
|
+
# NOTE: :sclass node is a "class << self" node
|
|
30
|
+
return if node.parent.sclass_type?
|
|
31
|
+
|
|
32
|
+
add_offense(node)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rubocop'
|
|
4
|
+
|
|
5
|
+
require_relative 'rubocop/codeur'
|
|
6
|
+
require_relative 'rubocop/codeur/version'
|
|
7
|
+
require_relative 'rubocop/codeur/inject'
|
|
8
|
+
|
|
9
|
+
RuboCop::Codeur::Inject.defaults!
|
|
10
|
+
|
|
11
|
+
require_relative 'rubocop/cop/codeur_cops'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/rubocop/codeur/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'rubocop-codeur'
|
|
7
|
+
spec.version = RuboCop::Codeur::VERSION
|
|
8
|
+
spec.authors = ['Codeur']
|
|
9
|
+
spec.email = ['dev@codeur.com']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'Codeur rubocop config gem'
|
|
12
|
+
spec.description = 'Shared rubocop config gem for every Ruby projects at Codeur SARL'
|
|
13
|
+
spec.homepage = 'https://github.com/codeur/rubocop-codeur'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
|
|
16
|
+
|
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
19
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
spec.add_dependency 'rubocop', '~> 1.25'
|
|
24
|
+
spec.add_dependency 'rubocop-minitest', '~> 0.10', '>=0.10.2'
|
|
25
|
+
spec.add_dependency 'rubocop-performance', '~> 1.9', '>= 1.9.2'
|
|
26
|
+
spec.add_dependency 'rubocop-rails', '~> 2.9', '>= 2.9.1'
|
|
27
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop-codeur
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
7
|
+
- Codeur
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-02-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rubocop
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 1.
|
|
19
|
+
version: '1.25'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 1.
|
|
26
|
+
version: '1.25'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rubocop-minitest
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -91,32 +91,48 @@ executables: []
|
|
|
91
91
|
extensions: []
|
|
92
92
|
extra_rdoc_files: []
|
|
93
93
|
files:
|
|
94
|
-
-
|
|
94
|
+
- ".github/workflows/quality.yml"
|
|
95
|
+
- ".github/workflows/test.yml"
|
|
96
|
+
- ".gitignore"
|
|
97
|
+
- ".rubocop.yml"
|
|
98
|
+
- Gemfile
|
|
99
|
+
- Gemfile.lock
|
|
100
|
+
- LICENSE.txt
|
|
95
101
|
- README.md
|
|
102
|
+
- Rakefile
|
|
103
|
+
- bin/console
|
|
104
|
+
- bin/rake
|
|
105
|
+
- bin/setup
|
|
106
|
+
- config/default.yml
|
|
96
107
|
- default.yml
|
|
97
|
-
- lib/
|
|
98
|
-
- lib/
|
|
108
|
+
- lib/rubocop-codeur.rb
|
|
109
|
+
- lib/rubocop/codeur.rb
|
|
110
|
+
- lib/rubocop/codeur/inject.rb
|
|
111
|
+
- lib/rubocop/codeur/version.rb
|
|
112
|
+
- lib/rubocop/cop/codeur/rails_app_patterns.rb
|
|
113
|
+
- lib/rubocop/cop/codeur/rails_avoid_instance_methods_in_helpers.rb
|
|
114
|
+
- lib/rubocop/cop/codeur_cops.rb
|
|
115
|
+
- rubocop-codeur.gemspec
|
|
99
116
|
homepage: https://github.com/codeur/rubocop-codeur
|
|
100
117
|
licenses:
|
|
101
118
|
- MIT
|
|
102
|
-
metadata:
|
|
103
|
-
homepage_uri: https://github.com/codeur/rubocop-codeur
|
|
119
|
+
metadata: {}
|
|
104
120
|
post_install_message:
|
|
105
121
|
rdoc_options: []
|
|
106
122
|
require_paths:
|
|
107
123
|
- lib
|
|
108
124
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
125
|
requirements:
|
|
110
|
-
- - "
|
|
126
|
+
- - ">="
|
|
111
127
|
- !ruby/object:Gem::Version
|
|
112
|
-
version:
|
|
128
|
+
version: 2.6.0
|
|
113
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
130
|
requirements:
|
|
115
131
|
- - ">="
|
|
116
132
|
- !ruby/object:Gem::Version
|
|
117
133
|
version: '0'
|
|
118
134
|
requirements: []
|
|
119
|
-
rubygems_version: 3.
|
|
135
|
+
rubygems_version: 3.1.4
|
|
120
136
|
signing_key:
|
|
121
137
|
specification_version: 4
|
|
122
138
|
summary: Codeur rubocop config gem
|
data/MIT-LICENSE
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
Copyright 2021 Codeur SARL
|
|
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.
|