modulorails 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +13 -14
- data/CHANGELOG.md +9 -0
- data/lib/generators/modulorails/bundleraudit/bundleraudit_generator.rb +26 -0
- data/lib/generators/modulorails/docker/templates/Dockerfile.prod.tt +2 -1
- data/lib/generators/modulorails/gitlabci/templates/.gitlab-ci.yml.tt +7 -0
- data/lib/generators/modulorails/rubocop/templates/rubocop.yml.tt +252 -3
- data/lib/modulorails/railtie.rb +3 -0
- data/lib/modulorails/version.rb +1 -1
- data/lib/modulorails.rb +8 -0
- data/modulorails.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74b7d68847f4e32d43a53990e8e400702a1c667334ad7c862e2e9f6d4197c31b
|
4
|
+
data.tar.gz: 4aedbb6cc5e066b49f710d43a721f8b3a5a4e6869c98979815f8564b1a34fa5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b079774bb4f3e9cfb2eb18bd31745f641d68712426498a859ac6bb8033b1ab274f1fbb708ff9d8519484d39b2dd28676845ed2809b1d04e622bf849a696bcfe8
|
7
|
+
data.tar.gz: d29668cb45b4078b5d7b780d25281cd700cdb96f1d24e6679af5e6aa8871ae23ce1cc71b613ad1b8522c85b23ddd3c60fad766d62f61916bcbb0f0363e1b4fce
|
data/.rubocop.yml
CHANGED
@@ -26,19 +26,18 @@ AllCops:
|
|
26
26
|
|
27
27
|
# Excluding most directories with generated files and directories with configuration files.
|
28
28
|
Exclude:
|
29
|
-
- '
|
30
|
-
- '
|
31
|
-
- '
|
32
|
-
- '
|
33
|
-
- '
|
34
|
-
- '
|
35
|
-
- '
|
36
|
-
- '
|
37
|
-
- '
|
38
|
-
- '
|
39
|
-
- '
|
40
|
-
- '
|
41
|
-
- '/**/spec/**/*'
|
29
|
+
- 'vendor/**/*'
|
30
|
+
- 'db/**/*'
|
31
|
+
- 'tmp/**/*'
|
32
|
+
- 'bin'
|
33
|
+
- '**/Gemfile'
|
34
|
+
- '**/Guardfile'
|
35
|
+
- '**/Capfile'
|
36
|
+
- '**/Rakefile'
|
37
|
+
- 'config/**/*'
|
38
|
+
- 'test/**/*'
|
39
|
+
- 'node_modules/**/*'
|
40
|
+
- 'spec/**/*'
|
42
41
|
|
43
42
|
# Instructing rubocop about all standard Modulotech environments.
|
44
43
|
Rails/UnknownEnv:
|
@@ -234,7 +233,7 @@ Style/EmptyMethod:
|
|
234
233
|
Metrics/BlockLength:
|
235
234
|
Enabled: true
|
236
235
|
Exclude:
|
237
|
-
- '
|
236
|
+
- 'app/admin/**/*'
|
238
237
|
|
239
238
|
# Checks if empty lines around the bodies of classes match the configuration.
|
240
239
|
Layout/EmptyLinesAroundClassBody:
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
This file is used to list changes made in each version of the gem.
|
4
4
|
|
5
|
+
# 1.2.0
|
6
|
+
|
7
|
+
The 'audit' release.
|
8
|
+
|
9
|
+
- Add bundler-audit in CI.
|
10
|
+
- Make the rubocop configuration work during CI.
|
11
|
+
- Fix generation of .gitlab-ci.yml for PG databases.
|
12
|
+
- Remove deprecated `--deployment` flag from Dockerfile.prod
|
13
|
+
|
5
14
|
# 1.1.0
|
6
15
|
|
7
16
|
The 'new project' release.
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators'
|
4
|
+
|
5
|
+
class Modulorails::BundlerauditGenerator < Rails::Generators::Base
|
6
|
+
|
7
|
+
source_root File.expand_path('templates', __dir__)
|
8
|
+
desc 'This generator creates a configuration for Bundler-Audit'
|
9
|
+
|
10
|
+
def create_config_files
|
11
|
+
gitlab_config_path = Rails.root.join('.gitlab-ci.yml')
|
12
|
+
|
13
|
+
return if File.read(gitlab_config_path).match?(/\s+extends:\s+.bundleraudit\s*$/)
|
14
|
+
|
15
|
+
append_file gitlab_config_path do
|
16
|
+
<<~YAML
|
17
|
+
# Scan Gemfile.lock for Common Vulnerabilities and Exposures
|
18
|
+
# https://en.wikipedia.org/wiki/Common_Vulnerabilities_and_Exposures
|
19
|
+
# https://www.cve.org/
|
20
|
+
bundleraudit:
|
21
|
+
extends: .bundleraudit
|
22
|
+
YAML
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -20,7 +20,8 @@ RUN apk add --update --no-cache \
|
|
20
20
|
RUN gem install bundler -v <%= Modulorails.data.bundler_version %>
|
21
21
|
|
22
22
|
COPY Gemfile Gemfile.lock ./
|
23
|
-
RUN bundle
|
23
|
+
RUN bundle config set --local deployment 'true'
|
24
|
+
RUN bundle check || bundle install --jobs=2 \
|
24
25
|
&& rm -rf vendor/bundle/ruby/*/cache/*
|
25
26
|
|
26
27
|
COPY package.json yarn.lock ./
|
@@ -17,9 +17,16 @@ services:
|
|
17
17
|
|
18
18
|
variables:
|
19
19
|
IMAGE_NAME: <%= image_name %>
|
20
|
+
<%- if adapter =~ /mysql/ -%>
|
20
21
|
MYSQL_DATABASE: <%= image_name %>_test
|
21
22
|
MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
|
22
23
|
<%= image_name.upcase %>_DATABASE_HOST: mysql
|
24
|
+
<%- else -%>
|
25
|
+
POSTGRES_DB: <%= image_name %>_test
|
26
|
+
POSTGRES_USER: postgres
|
27
|
+
POSTGRES_PASSWORD: postgres
|
28
|
+
<%= image_name.upcase %>_DATABASE_HOST: postgres
|
29
|
+
<%- end -%>
|
23
30
|
|
24
31
|
stages:
|
25
32
|
- test
|
@@ -9,10 +9,259 @@
|
|
9
9
|
#
|
10
10
|
# See https://docs.rubocop.org/rubocop/configuration
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
# Enabling Rails-specific cops.
|
13
|
+
require: rubocop-rails
|
14
14
|
|
15
|
-
# Take into account the exclude list from the gem
|
16
15
|
inherit_mode:
|
17
16
|
merge:
|
18
17
|
- Exclude
|
18
|
+
- Include
|
19
|
+
|
20
|
+
AllCops:
|
21
|
+
# No suggestions since the gem is the sole truth for rubocop configuration.
|
22
|
+
SuggestExtensions: false
|
23
|
+
|
24
|
+
# Enable new cops by default
|
25
|
+
NewCops: enable
|
26
|
+
|
27
|
+
# Excluding most directories with generated files and directories with configuration files.
|
28
|
+
Exclude:
|
29
|
+
- 'vendor/**/*'
|
30
|
+
- 'db/**/*'
|
31
|
+
- 'tmp/**/*'
|
32
|
+
- 'bin'
|
33
|
+
- '**/Gemfile'
|
34
|
+
- '**/Guardfile'
|
35
|
+
- '**/Capfile'
|
36
|
+
- '**/Rakefile'
|
37
|
+
- 'config/**/*'
|
38
|
+
- 'test/**/*'
|
39
|
+
- 'node_modules/**/*'
|
40
|
+
- 'spec/**/*'
|
41
|
+
|
42
|
+
# Instructing rubocop about all standard Modulotech environments.
|
43
|
+
Rails/UnknownEnv:
|
44
|
+
Environments:
|
45
|
+
- production
|
46
|
+
- development
|
47
|
+
- test
|
48
|
+
- staging
|
49
|
+
- preprod
|
50
|
+
|
51
|
+
# Checks if String literals are using single quotes when no interpolation is required
|
52
|
+
Style/StringLiterals:
|
53
|
+
Enabled: true
|
54
|
+
EnforcedStyle: single_quotes
|
55
|
+
ConsistentQuotesInMultiline: false
|
56
|
+
|
57
|
+
# Checks if the quotes used for quoted symbols are single quotes when no interpolation is required
|
58
|
+
Style/QuotedSymbols:
|
59
|
+
Enabled: true
|
60
|
+
EnforcedStyle: same_as_string_literals
|
61
|
+
|
62
|
+
# This cop checks for uses of literal strings converted to a symbol where a literal symbol could be used instead.
|
63
|
+
Lint/SymbolConversion:
|
64
|
+
Enabled: true
|
65
|
+
EnforcedStyle: strict
|
66
|
+
|
67
|
+
# Useless cop. It checks for unnecessary safe navigations.
|
68
|
+
# Example:
|
69
|
+
# obj&.a && obj.b
|
70
|
+
# Triggers rubocop error: it requires to add safe navigation for "obj.b" call => "obj&.b".
|
71
|
+
# but it is not necessary. obj&.a will return nil if obj is nil, and it will stop
|
72
|
+
# execution of the operation because `&&` right part executes only when left part is truthy.
|
73
|
+
Lint/SafeNavigationConsistency:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
# Checks for places where keyword arguments can be used instead of boolean arguments when defining methods.
|
77
|
+
# Disabled because moving from default arguments to keywords is not that easy.
|
78
|
+
Style/OptionalBooleanParameter:
|
79
|
+
Enabled: false
|
80
|
+
|
81
|
+
# Checks for use of the lambda.(args) syntax.
|
82
|
+
# Disabled while the Ruby team has not voted on this.
|
83
|
+
Style/LambdaCall:
|
84
|
+
Enabled: false
|
85
|
+
EnforcedStyle: braces
|
86
|
+
|
87
|
+
# Checks for presence or absence of braces around hash literal as a last array item depending on configuration.
|
88
|
+
# Disabled because it would break a lot of permitted_params definitions
|
89
|
+
Style/HashAsLastArrayItem:
|
90
|
+
Enabled: false
|
91
|
+
|
92
|
+
# Checks for grouping of accessors in class and module bodies.
|
93
|
+
# Useless.
|
94
|
+
Style/AccessorGrouping:
|
95
|
+
Enabled: false
|
96
|
+
|
97
|
+
# Makes our lives happier: we don't need to disable it in each case/when method
|
98
|
+
# with more than 5 "when"s.
|
99
|
+
Metrics/CyclomaticComplexity:
|
100
|
+
Max: 10
|
101
|
+
|
102
|
+
# Commonly used screens these days easily fit more than 80 characters.
|
103
|
+
Layout/LineLength:
|
104
|
+
Max: 100
|
105
|
+
|
106
|
+
# Too short methods lead to extraction of single-use methods, which can make
|
107
|
+
# the code easier to read (by naming things), but can also clutter the class
|
108
|
+
Metrics/MethodLength:
|
109
|
+
Max: 20
|
110
|
+
|
111
|
+
# The guiding principle of classes is SRP, SRP can't be accurately measured by LoC
|
112
|
+
Metrics/ClassLength:
|
113
|
+
Max: 1500
|
114
|
+
|
115
|
+
# No space makes the method definition shorter and differentiates
|
116
|
+
# from a regular assignment.
|
117
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
118
|
+
EnforcedStyle: no_space
|
119
|
+
|
120
|
+
# We do not need to support Ruby 1.9, so this is good to use.
|
121
|
+
Style/SymbolArray:
|
122
|
+
Enabled: true
|
123
|
+
|
124
|
+
# Most readable form.
|
125
|
+
Layout/HashAlignment:
|
126
|
+
EnforcedHashRocketStyle: table
|
127
|
+
EnforcedColonStyle: table
|
128
|
+
|
129
|
+
# Mixing the styles looks just silly.
|
130
|
+
Style/HashSyntax:
|
131
|
+
EnforcedStyle: ruby19_no_mixed_keys
|
132
|
+
|
133
|
+
# has_key? and has_value? are far more readable than key? and value?
|
134
|
+
Style/PreferredHashMethods:
|
135
|
+
Enabled: false
|
136
|
+
|
137
|
+
# String#% is by far the least verbose and only object oriented variant.
|
138
|
+
Style/FormatString:
|
139
|
+
EnforcedStyle: percent
|
140
|
+
|
141
|
+
# Annotated or template are too verbose and rarely needed.
|
142
|
+
Style/FormatStringToken:
|
143
|
+
EnforcedStyle: unannotated
|
144
|
+
|
145
|
+
Style/CollectionMethods:
|
146
|
+
Enabled: true
|
147
|
+
PreferredMethods:
|
148
|
+
# inject seems more common in the community.
|
149
|
+
reduce: "inject"
|
150
|
+
|
151
|
+
# Either allow this style or don't. Marking it as safe with parenthesis
|
152
|
+
# is silly. Let's try to live without them for now.
|
153
|
+
Style/ParenthesesAroundCondition:
|
154
|
+
AllowSafeAssignment: false
|
155
|
+
Lint/AssignmentInCondition:
|
156
|
+
AllowSafeAssignment: false
|
157
|
+
|
158
|
+
# A specialized exception class will take one or more arguments and construct the message from it.
|
159
|
+
# So both variants make sense.
|
160
|
+
Style/RaiseArgs:
|
161
|
+
Enabled: false
|
162
|
+
|
163
|
+
# Indenting the chained dots beneath each other is not supported by this cop,
|
164
|
+
# see https://github.com/bbatsov/rubocop/issues/1633
|
165
|
+
Layout/MultilineOperationIndentation:
|
166
|
+
Enabled: false
|
167
|
+
|
168
|
+
# Fail is an alias of raise. Avoid aliases, it's more cognitive load for no gain.
|
169
|
+
# The argument that fail should be used to abort the program is wrong too,
|
170
|
+
# there's Kernel#abort for that.
|
171
|
+
Style/SignalException:
|
172
|
+
EnforcedStyle: only_raise
|
173
|
+
|
174
|
+
# Suppressing exceptions can be perfectly fine, and be it to avoid to
|
175
|
+
# explicitly type nil into the rescue since that's what you want to return,
|
176
|
+
# or suppressing LoadError for optional dependencies
|
177
|
+
Lint/SuppressedException:
|
178
|
+
Enabled: false
|
179
|
+
|
180
|
+
# { ... } for multi-line blocks is okay, follow Weirichs rule instead:
|
181
|
+
# https://web.archive.org/web/20140221124509/http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc
|
182
|
+
Style/BlockDelimiters:
|
183
|
+
Enabled: false
|
184
|
+
|
185
|
+
# do / end blocks should be used for side effects,
|
186
|
+
# methods that run a block for side effects and have
|
187
|
+
# a useful return value are rare, assign the return
|
188
|
+
# value to a local variable for those cases.
|
189
|
+
Style/MethodCalledOnDoEndBlock:
|
190
|
+
Enabled: true
|
191
|
+
|
192
|
+
# Enforcing the names of variables? To single letter ones? Just no.
|
193
|
+
Style/SingleLineBlockParams:
|
194
|
+
Enabled: false
|
195
|
+
|
196
|
+
# Shadowing outer local variables with block parameters is often useful
|
197
|
+
# to not reinvent a new name for the same thing, it highlights the relation
|
198
|
+
# between the outer variable and the parameter. The cases where it's actually
|
199
|
+
# confusing are rare, and usually bad for other reasons already, for example
|
200
|
+
# because the method is too long.
|
201
|
+
Lint/ShadowingOuterLocalVariable:
|
202
|
+
Enabled: false
|
203
|
+
|
204
|
+
# Check with yard instead.
|
205
|
+
Style/Documentation:
|
206
|
+
Enabled: false
|
207
|
+
|
208
|
+
# This is just silly. Calling the argument `other` in all cases makes no sense.
|
209
|
+
Naming/BinaryOperatorParameterName:
|
210
|
+
Enabled: false
|
211
|
+
|
212
|
+
# Disable frozen string
|
213
|
+
Style/FrozenStringLiteralComment:
|
214
|
+
Enabled: false
|
215
|
+
|
216
|
+
# Disable No ASCII char in comments
|
217
|
+
Style/AsciiComments:
|
218
|
+
Enabled: false
|
219
|
+
|
220
|
+
# Disable ordered Gems By ascii
|
221
|
+
Bundler/OrderedGems:
|
222
|
+
Enabled: false
|
223
|
+
|
224
|
+
# Change ABC max value
|
225
|
+
Metrics/AbcSize:
|
226
|
+
Max: 35
|
227
|
+
|
228
|
+
# Disable empty method in one line
|
229
|
+
Style/EmptyMethod:
|
230
|
+
EnforcedStyle: expanded
|
231
|
+
|
232
|
+
# Disable max height block
|
233
|
+
Metrics/BlockLength:
|
234
|
+
Enabled: true
|
235
|
+
Exclude:
|
236
|
+
- 'app/admin/**/*'
|
237
|
+
- 'lib/tasks/**/*'
|
238
|
+
|
239
|
+
# Checks if empty lines around the bodies of classes match the configuration.
|
240
|
+
Layout/EmptyLinesAroundClassBody:
|
241
|
+
EnforcedStyle: empty_lines
|
242
|
+
# Checks if empty lines around the bodies of modules match the configuration.
|
243
|
+
Layout/EmptyLinesAroundModuleBody:
|
244
|
+
EnforcedStyle: empty_lines
|
245
|
+
|
246
|
+
# Enforces the consistent usage of %-literal delimiters.
|
247
|
+
Style/PercentLiteralDelimiters:
|
248
|
+
PreferredDelimiters:
|
249
|
+
default: '()'
|
250
|
+
'%i': '[]'
|
251
|
+
'%I': '[]'
|
252
|
+
'%r': '{}'
|
253
|
+
'%w': '[]'
|
254
|
+
'%W': '[]'
|
255
|
+
|
256
|
+
# Unnecessary cop. In what universe "A || B && C" or "A && B || C && D" is ambiguous? looks
|
257
|
+
# like a cop for those who can't in boolean.
|
258
|
+
Lint/AmbiguousOperatorPrecedence:
|
259
|
+
Enabled: false
|
260
|
+
|
261
|
+
# Checks for simple usages of parallel assignment.
|
262
|
+
Style/ParallelAssignment:
|
263
|
+
Enabled: false
|
264
|
+
|
265
|
+
# Checks the style of children definitions at classes and modules.
|
266
|
+
Style/ClassAndModuleChildren:
|
267
|
+
Enabled: false
|
data/lib/modulorails/railtie.rb
CHANGED
@@ -51,6 +51,9 @@ module Modulorails
|
|
51
51
|
# Add/update Rubocop config
|
52
52
|
Modulorails.generate_rubocop_template
|
53
53
|
|
54
|
+
# Add/update Bundler-audit config
|
55
|
+
Modulorails.generate_bundleraudit_template
|
56
|
+
|
54
57
|
# Gem's self-update if a new version was released
|
55
58
|
Modulorails.self_update
|
56
59
|
end
|
data/lib/modulorails/version.rb
CHANGED
data/lib/modulorails.rb
CHANGED
@@ -7,6 +7,7 @@ require 'generators/modulorails/gitlabci/gitlabci_generator'
|
|
7
7
|
require 'generators/modulorails/healthcheck/health_check_generator'
|
8
8
|
require 'generators/modulorails/self_update/self_update_generator'
|
9
9
|
require 'generators/modulorails/rubocop/rubocop_generator'
|
10
|
+
require 'generators/modulorails/bundleraudit/bundleraudit_generator'
|
10
11
|
require 'httparty'
|
11
12
|
require 'modulorails/error_data'
|
12
13
|
require 'modulorails/success_data'
|
@@ -165,6 +166,13 @@ module Modulorails
|
|
165
166
|
Modulorails::RubocopGenerator.new([], {}, {}).invoke_all
|
166
167
|
end
|
167
168
|
|
169
|
+
# @author Matthieu 'ciappa_m' Ciappara
|
170
|
+
#
|
171
|
+
# Generate a bundler-audit configuration.
|
172
|
+
def generate_bundleraudit_template
|
173
|
+
Modulorails::BundlerauditGenerator.new([], {}, {}).invoke_all
|
174
|
+
end
|
175
|
+
|
168
176
|
end
|
169
177
|
|
170
178
|
end
|
data/modulorails.gemspec
CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_runtime_dependency 'railties', '>= 4.2.0'
|
37
37
|
spec.add_runtime_dependency 'rubocop', '>= 1.28.2'
|
38
38
|
spec.add_runtime_dependency 'rubocop-rails', '>= 2.14.2'
|
39
|
+
spec.add_runtime_dependency 'bundler-audit', '~> 0.9.1'
|
39
40
|
|
40
41
|
spec.add_development_dependency 'activerecord', '>= 4.2.0'
|
41
42
|
spec.add_development_dependency 'appraisal'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modulorails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthieu Ciappara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -114,6 +114,20 @@ dependencies:
|
|
114
114
|
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: 2.14.2
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: bundler-audit
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 0.9.1
|
124
|
+
type: :runtime
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 0.9.1
|
117
131
|
- !ruby/object:Gem::Dependency
|
118
132
|
name: activerecord
|
119
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,6 +198,7 @@ files:
|
|
184
198
|
- gemfiles/rails_60.gemfile
|
185
199
|
- gemfiles/rails_61.gemfile
|
186
200
|
- gemfiles/rails_70.gemfile
|
201
|
+
- lib/generators/modulorails/bundleraudit/bundleraudit_generator.rb
|
187
202
|
- lib/generators/modulorails/docker/docker_generator.rb
|
188
203
|
- lib/generators/modulorails/docker/templates/Dockerfile.prod.tt
|
189
204
|
- lib/generators/modulorails/docker/templates/Dockerfile.tt
|