lifen-ruby-style 0.2.1 → 1.0.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/.overcommit.yml +55 -0
- data/.rubocop.yml +1 -1
- data/Gemfile +2 -0
- data/README.md +358 -31
- data/Rakefile +2 -0
- data/default_overcommit.yml +55 -0
- data/default_rubocop.yml +133 -0
- data/lib/lifen/ruby_style/version.rb +5 -1
- data/lib/lifen/ruby_style.rb +2 -0
- data/lifen-ruby-style.gemspec +23 -17
- data/rubocop +1 -0
- data/style_guide.md +673 -0
- metadata +82 -8
- data/default.yml +0 -170
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1f86ee33406608d1b9b2cf8d14d80585a09dcb798a2528c1b06a7205d61bb47
|
4
|
+
data.tar.gz: 42914e1c8155e225d5fcedce3d9d14ef8d5116b51df50213cd24f899aca039c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b86279d1645d36567b71689f3f5b634086975cf0be3f0f29436da8ff9171d3739df1017aa21b8f4323ff423dab23410b315cbb12f11008a081fa9e6e31d3dadc
|
7
|
+
data.tar.gz: 28df7786610a74fe2b4bdc7534409f857962020002c7bce2271c18dfd10bf717e25ddaf0d4f3bfcf1785d2430f36feb4cf80ed700585ce812180fc2c3943ce4e
|
data/.overcommit.yml
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Use this file to configure the Overcommit hooks you wish to use. This will
|
2
|
+
# extend the default configuration defined in:
|
3
|
+
# https://github.com/sds/overcommit/blob/master/config/default.yml
|
4
|
+
#
|
5
|
+
# At the topmost level of this YAML file is a key representing type of hook
|
6
|
+
# being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
|
7
|
+
# customize each hook, such as whether to only run it on certain files (via
|
8
|
+
# `include`), whether to only display output if it fails (via `quiet`), etc.
|
9
|
+
#
|
10
|
+
# For a complete list of hooks, see:
|
11
|
+
# https://github.com/sds/overcommit/tree/master/lib/overcommit/hook
|
12
|
+
#
|
13
|
+
# For a complete list of options that you can use to customize hooks, see:
|
14
|
+
# https://github.com/sds/overcommit#configuration
|
15
|
+
#
|
16
|
+
# Uncomment the following lines to make the configuration take effect.
|
17
|
+
|
18
|
+
PreCommit:
|
19
|
+
Pronto:
|
20
|
+
enabled: true
|
21
|
+
|
22
|
+
GoFmt:
|
23
|
+
enabled: false
|
24
|
+
|
25
|
+
CommitMsg:
|
26
|
+
CapitalizedSubject:
|
27
|
+
enabled: false
|
28
|
+
|
29
|
+
SingleLineSubject:
|
30
|
+
enabled: true
|
31
|
+
on_warn: fail
|
32
|
+
|
33
|
+
TextWidth:
|
34
|
+
enabled: true
|
35
|
+
on_warn: fail
|
36
|
+
|
37
|
+
TrailingPeriod:
|
38
|
+
enabled: true
|
39
|
+
on_warn: fail
|
40
|
+
#PreCommit:
|
41
|
+
# RuboCop:
|
42
|
+
# enabled: true
|
43
|
+
# on_warn: fail # Treat all warnings as failures
|
44
|
+
#
|
45
|
+
# TrailingWhitespace:
|
46
|
+
# enabled: true
|
47
|
+
# exclude:
|
48
|
+
# - '**/db/structure.sql' # Ignore trailing whitespace in generated files
|
49
|
+
#
|
50
|
+
#PostCheckout:
|
51
|
+
# ALL: # Special hook name that customizes all hooks of this type
|
52
|
+
# quiet: true # Change all post-checkout hooks to only display output on failure
|
53
|
+
#
|
54
|
+
# IndexTags:
|
55
|
+
# enabled: true # Generate a tags file with `ctags` each time HEAD changes
|
data/.rubocop.yml
CHANGED
@@ -1 +1 @@
|
|
1
|
-
inherit_from:
|
1
|
+
inherit_from: default_rubocop.yml
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,40 @@
|
|
1
1
|
# lifen-ruby-style
|
2
2
|
|
3
|
-
|
3
|
+
**Ensembe des outils et bonnes pratiques Ruby chez Lifen :**
|
4
|
+
|
5
|
+
1. Le [Guide de style Lifen](./style_guide.md) présente les guidelines Lifen et détaille les règles de style.
|
6
|
+
|
7
|
+
2. [RuboCop](https://github.com/rubocop-hq/rubocop) est un outil statique d'analyse et de formattage du code, qui repose sur le [guide de style](https://github.com/rubocop-hq/ruby-style-guide) de la communauté Ruby et que nous configurons selon le [guide de style Lifen](./style_guide.md). Nous utilisons plusieurs extensions :
|
8
|
+
|
9
|
+
- [Rubocop-performance](https://github.com/rubocop-hq/rubocop-performance) pour la performance et l'optimisation
|
10
|
+
- [Rubocop-rspec](https://github.com/rubocop-hq/rubocop-rspec) pour l'analyse des tests RSpec
|
11
|
+
- [Rubocop-rails](https://github.com/rubocop-hq/rubocop-rails) pour les vérifications spécifiques à Rails.
|
12
|
+
|
13
|
+
3. [Pronto](https://github.com/prontolabs/pronto) permet de lancer simultanément **plusieurs outils d'analyse** (e.g. Rubocop, Reek, Fasterer) **sur un sous-ensemble de lignes** (e.g. le contenu de l'index ou le diff entre 2 commits). Nous ne l'utilisons pour le moment que pour l'analyse Rubocop. [Pronto Rubocop](https://github.com/prontolabs/pronto-rubocop) est l'extension qui va permettre de lancer RuboCop via Pronto.
|
14
|
+
|
15
|
+
4. [Overcommit](https://github.com/sds/overcommit) permet de gérer et paramétrer les hooks Git.
|
16
|
+
|
17
|
+
## Sommaire
|
18
|
+
|
19
|
+
- [Installation](#installation)
|
20
|
+
- [Usage](#usage)
|
21
|
+
- [Rubocop](#rubocop)
|
22
|
+
- [Pronto](#pronto)
|
23
|
+
- [Overcommit](#overcommit)
|
24
|
+
- [Utilisation d'une version locale](#utilisation-dune-version-locale)
|
25
|
+
- [Contributions](#contributions)
|
26
|
+
- [TODO](#todo)
|
27
|
+
- [Archives](#archives)
|
4
28
|
|
5
29
|
## Installation
|
6
30
|
|
7
|
-
|
31
|
+
<details>
|
32
|
+
|
33
|
+
<summary>Pour un nouveau projet ou un repo Lifen non configuré</summary>
|
34
|
+
|
35
|
+
### 1. Ajout de la gem au projet
|
36
|
+
|
37
|
+
Ajouter dans le `Gemfile` :
|
8
38
|
|
9
39
|
```ruby
|
10
40
|
group :test, :development do
|
@@ -18,67 +48,364 @@ Ou dans le `.gemspec` s'il s'agit d'une gem :
|
|
18
48
|
spec.add_development_dependency 'lifen-ruby-style'
|
19
49
|
```
|
20
50
|
|
21
|
-
|
51
|
+
### 2. Config Rubocop
|
52
|
+
|
53
|
+
Créer le fichier `.rubocop.yml` avec le code suivant :
|
54
|
+
|
55
|
+
```yaml
|
56
|
+
inherit_gem:
|
57
|
+
lifen-ruby-style:
|
58
|
+
- default_rubocop.yml
|
59
|
+
```
|
60
|
+
|
61
|
+
### 3. Config Overcommit
|
62
|
+
|
63
|
+
Créer le fichier `.overcommit.yml` à partir du contenu de [ce fichier](./default_overcommit.yml).
|
64
|
+
|
65
|
+
Note : Il n'est pas nécessaire d'ajouter Rubocop dans les dépendances de l'application.
|
66
|
+
|
67
|
+
</details>
|
68
|
+
|
69
|
+
<details>
|
70
|
+
<summary>Pour un repo Lifen déjà configuré</summary>
|
71
|
+
|
72
|
+
### 1. Installer les dépendences :
|
22
73
|
|
23
74
|
```bash
|
24
75
|
$ bundle install
|
25
76
|
```
|
26
77
|
|
27
|
-
|
78
|
+
En cas de problème avec l'installation de la sous-dépendance `rugged` il faudra vous assurer que `cmake` est installé sur votre machine. Si elle n'est pas installée il faudra le faire de la façon suivante :
|
79
|
+
```bash
|
80
|
+
brew install cmake
|
81
|
+
```
|
28
82
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
83
|
+
### 2. Installer les hooks Git :
|
84
|
+
|
85
|
+
```bash
|
86
|
+
$ bundle exec overcommit --install
|
33
87
|
```
|
34
88
|
|
35
|
-
|
89
|
+
</details>
|
36
90
|
|
37
|
-
|
91
|
+
<details>
|
92
|
+
<summary>Recommandations spécifiques pour VSCode</summary>
|
38
93
|
|
94
|
+
### 1. Configuration générale
|
95
|
+
|
96
|
+
```json
|
97
|
+
"editor.tabSize": 2, // Uses 2 spaces for indentation
|
98
|
+
"editor.rulers": [
|
99
|
+
80,
|
100
|
+
120
|
101
|
+
], // Add rulers at 80 and 120 characters
|
102
|
+
"files.trimTrailingWhitespace": true, // Remove trailing auto inserted whitespaces
|
103
|
+
"files.insertFinalNewline": true, // Insert a final new line at the end of the file when saving it
|
104
|
+
"files.associations": {
|
105
|
+
"Gemfile": "ruby",
|
106
|
+
}, // Use Ruby language mode for Gemfiles
|
39
107
|
```
|
40
|
-
#!/bin/bash
|
41
108
|
|
42
|
-
|
109
|
+
### 2. Extension ruby
|
110
|
+
|
111
|
+
- Installer l'extension [rebornix.ruby](https://marketplace.visualstudio.com/items?itemName=rebornix.Ruby), qui intègre notamment `RuboCop`.
|
112
|
+
|
113
|
+
Note : Inutile d'installer [ruby-rubocop](https://marketplace.visualstudio.com/items?itemName=misogi.ruby-rubocop) qui fait doublon et qui introduit des conflits avec les environnement `rvm`.
|
114
|
+
|
115
|
+
- Paramétrage recommandé de l'extension :
|
116
|
+
|
117
|
+
```json
|
118
|
+
"ruby.useBundler": true, // run non-lint commands with bundle exec
|
119
|
+
"ruby.useLanguageServer": true, // use the internal language server (see below)
|
120
|
+
"ruby.lint": {
|
121
|
+
"rubocop": {
|
122
|
+
"useBundler": true // enable rubocop via bundler
|
123
|
+
}
|
124
|
+
},
|
125
|
+
"ruby.format": "rubocop", // use rubocop for formatting
|
126
|
+
```
|
127
|
+
|
128
|
+
- **FORCER RUBOCOP À RESPECTER LES EXCLUSIONS DÉFINIES DANS LE FICHIER DE PARAMÉTRAGE :**
|
129
|
+
|
130
|
+
```bash
|
131
|
+
$ echo '--force-exclusion' > .rubocop
|
132
|
+
```
|
133
|
+
|
134
|
+
- Paramétrage recommandé pour l'auto-formatting :
|
135
|
+
|
136
|
+
```json
|
137
|
+
"[ruby]": {
|
138
|
+
"editor.formatOnPaste": true, // auto-format ruby code when pasting
|
139
|
+
"editor.formatOnSave": true // auto-format ruby code when saving
|
140
|
+
},
|
141
|
+
```
|
142
|
+
|
143
|
+
ou
|
144
|
+
|
145
|
+
```json
|
146
|
+
"editor.formatOnPaste": true, // auto-format code when pasting
|
147
|
+
"editor.formatOnSave": true, // auto-format code when saving
|
148
|
+
```
|
149
|
+
|
150
|
+
### 3. Bonus - Autres extensions utiles :
|
151
|
+
|
152
|
+
- [Bracket Pair Colorizer 2](https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer-2)
|
153
|
+
- [Endwise](https://marketplace.visualstudio.com/items?itemName=kaiwood.endwise)
|
154
|
+
- [Git Blame](https://marketplace.visualstudio.com/items?itemName=waderyan.gitblame)
|
155
|
+
- [Rails Go to Spec ](https://marketplace.visualstudio.com/items?itemName=sporto.rails-go-to-spec)
|
156
|
+
- [RSpec Snippets](https://marketplace.visualstudio.com/items?itemName=karunamurti.rspec-snippets)
|
157
|
+
|
158
|
+
</details>
|
159
|
+
|
160
|
+
<details>
|
161
|
+
<summary>Recommandations spécifiques pour Sublime Text</summary>
|
162
|
+
|
163
|
+
### Configuration de Sublime Text
|
164
|
+
Il faut aller dans `Preferences > Settings` et modifier le fichier `Preferences.sublime-settings -- User` et y ajouter les paramètres suivants :
|
165
|
+
```json
|
166
|
+
{
|
167
|
+
...,
|
168
|
+
"rulers":
|
169
|
+
[
|
170
|
+
80,
|
171
|
+
120
|
172
|
+
],
|
173
|
+
"tab_size": 2,
|
174
|
+
"translate_tabs_to_spaces": true,
|
175
|
+
"trim_trailing_white_space_on_save": true,
|
176
|
+
"word_wrap": "true",
|
177
|
+
...
|
178
|
+
}
|
179
|
+
```
|
180
|
+
|
181
|
+
### Configuration de Rubocop
|
182
|
+
#### 1. Installation du plugin
|
183
|
+
Il faut installer l'extension [sublime_rubocop](https://packagecontrol.io/packages/RuboCop)
|
184
|
+
|
185
|
+
Et tout devrait marcher par défaut si votre système n'utilise pas rvm ou rbenv. Le cas échéant il faut personnaliser la configuration en allant dans `Preferences > Package Settings > Rubocop > Settings - User` et mettre la configuration qui va bien dans le fichier, par exemple ceci si vous utilisez Rbenv :
|
43
186
|
```
|
187
|
+
{
|
188
|
+
"check_for_rvm": false,
|
189
|
+
"check_for_rbenv": true,
|
190
|
+
"rbenv_path": "/usr/local/bin/rbenv"
|
191
|
+
}
|
192
|
+
```
|
193
|
+
|
194
|
+
#### 2. Utilisation
|
195
|
+
Une fois le plugin installé vous accéderez à des commandes supplémentaires liées à Rubocop et vous pourrez par exemple :
|
196
|
+
- Corriger automatiquement des fichiers
|
197
|
+
- Activer/Désactiver l'auto-check des fichiers
|
198
|
+
|
199
|
+
</details>
|
200
|
+
|
201
|
+
<details>
|
202
|
+
<summary>Recommandations spécifiques pour VIM (`dense-analysis/ale`)</summary>
|
203
|
+
|
204
|
+
### 1. Installation
|
205
|
+
|
206
|
+
#### via Plug (recommandé)
|
207
|
+
|
208
|
+
- Ajoutez à votre `.vimrc` (dans la liste des plugins):
|
209
|
+
|
210
|
+
```
|
211
|
+
Plug 'dense-analysis/ale'
|
212
|
+
```
|
213
|
+
|
214
|
+
- Lancez `:PlugInstall`
|
215
|
+
|
216
|
+
#### Autres méthodes
|
217
|
+
|
218
|
+
Voir https://github.com/dense-analysis/ale#3-installation
|
219
|
+
|
220
|
+
### 2. Configuration recommandée
|
221
|
+
|
222
|
+
Dans votre `.vimrc`:
|
223
|
+
|
224
|
+
- Pour que le linter passe lorsque le texte change (hors sauvegardes):
|
225
|
+
|
226
|
+
```
|
227
|
+
let g:ale_lint_on_text_changed = 'never'
|
228
|
+
```
|
229
|
+
|
230
|
+
- Pour que le linter passe lorsque la touche 'enter' est pressée:
|
231
|
+
|
232
|
+
```
|
233
|
+
let g:ale_lint_on_enter = 1
|
234
|
+
```
|
235
|
+
|
236
|
+
- Pour que le linter nettoie les petites imperfections à la sauvegarde:
|
237
|
+
```
|
238
|
+
let g:ale_fix_on_save = 1
|
239
|
+
let g:ale_fixers = {
|
240
|
+
\ 'ruby': 'rubocop',
|
241
|
+
\ 'javascript': 'eslint'
|
242
|
+
\}
|
243
|
+
```
|
244
|
+
(il faut aussi configurer les "fixers")
|
245
|
+
|
246
|
+
### Pour aller plus loin
|
247
|
+
|
248
|
+
https://github.com/dense-analysis/ale
|
249
|
+
|
250
|
+
</details>
|
44
251
|
|
45
252
|
## Usage
|
46
253
|
|
47
|
-
###
|
254
|
+
### Workflow
|
48
255
|
|
49
|
-
|
256
|
+
- Je code ma feature en local. Mon environnement (projet + IDE) étant configuré, je suis alerté en direct des règles de style que j'enfreins. Certaines sont mêmes corrigées automatiquement, lors de la sauvegarde du fichier.
|
257
|
+
- Je commit :
|
258
|
+
- Un hook de pre-commit lance une analyse Pronto (= RuboCop pour le moment) sur les lignes "staged". D'autres vérifications fournies par défaut par la gem `overcommit` sont également faites. Si l'analye renvoie des erreurs, le commit est bloqué.
|
259
|
+
- Un hook vérifie le message de commit
|
260
|
+
- Si je veux bypasser les hooks (déconseillé) : `OVERCOMMIT_DISABLE=1 git commit ...`
|
261
|
+
- Je push (pas de hooks paramétrés pour l'instant)
|
262
|
+
|
263
|
+
### Commandes Rubocop
|
264
|
+
|
265
|
+
Pour de la vérification :
|
50
266
|
|
51
267
|
```bash
|
52
|
-
$ bundle exec rubocop
|
268
|
+
$ bundle exec rubocop # checks all the repo
|
269
|
+
$ bundle exec rubocop [PATH] # checks the path
|
270
|
+
$ bundle exec rubocop --fail-fast # inspect files in order of modification time and stop after the first file
|
53
271
|
```
|
54
272
|
|
55
|
-
|
273
|
+
Pour de la correction automatique :
|
56
274
|
|
57
275
|
```bash
|
58
|
-
$ bundle exec rubocop -a
|
276
|
+
$ bundle exec rubocop -a # auto-correct offenses.
|
277
|
+
$ bundle exec rubocop --safe # run only safe cops.
|
278
|
+
$ bundle exec rubocop --safe-auto-correct # run auto-correct only when it's safe.
|
279
|
+
$ bundle exec rubocop --lint # run only lint cops.
|
280
|
+
$ bundle exec rubocop --fix-layout # run only layout cops, with auto-correct on.
|
59
281
|
```
|
60
282
|
|
61
|
-
|
283
|
+
Liste des commandes disponibles :
|
62
284
|
|
63
|
-
|
285
|
+
```bash
|
286
|
+
$ bundle exec rubocop --help
|
287
|
+
```
|
288
|
+
|
289
|
+
### Commandes Pronto
|
64
290
|
|
65
291
|
```bash
|
66
|
-
|
292
|
+
$ bundle exec pronto run [PATH] # Runs Pronto on the diff between last commit and master
|
67
293
|
```
|
68
294
|
|
69
|
-
|
295
|
+
Vous pouvez ajouter les options suivantes :
|
296
|
+
|
297
|
+
```bash
|
298
|
+
-c, [--commit=COMMIT] # Runs Pronto on the diff between last commit and specified commit
|
299
|
+
-i, --index # Analyze changes not staged for commit (does not include untracked files)
|
300
|
+
--unstaged, --no-unstaged # Analyze only untracked files
|
301
|
+
--staged, --no-staged # Analyze changes to be committed (git staging area)
|
302
|
+
```
|
70
303
|
|
71
|
-
|
304
|
+
Liste des commandes disponibles :
|
72
305
|
|
73
|
-
```
|
74
|
-
|
75
|
-
|
76
|
-
end
|
306
|
+
```bash
|
307
|
+
$ bundle exec pronto --help
|
308
|
+
$ bundle exec pronto help run
|
77
309
|
```
|
78
310
|
|
79
|
-
|
311
|
+
### Commandes Overcommit
|
80
312
|
|
81
|
-
```
|
82
|
-
|
83
|
-
|
84
|
-
```
|
313
|
+
```bash
|
314
|
+
$ OVERCOMMIT_DISABLE=1 git [command] # Executes the git command without running the hooks
|
315
|
+
$ bundle exec overcommit --run # Run pre-commit hook against all git tracked files
|
316
|
+
```
|
317
|
+
|
318
|
+
Liste des commandes disponibles :
|
319
|
+
|
320
|
+
```bash
|
321
|
+
$ bundle exec overcommit --help
|
322
|
+
```
|
323
|
+
|
324
|
+
### CI
|
325
|
+
|
326
|
+
Créer un flow avec la commande `bundle exec overcommit --run`.
|
327
|
+
|
328
|
+
## Utilisation d'une version locale
|
329
|
+
|
330
|
+
Pour utiliser une version locale de la gem `lifen-ruby-style` :
|
331
|
+
|
332
|
+
- Cloner le repo
|
333
|
+
|
334
|
+
```bash
|
335
|
+
git clone git@github.com:honestica/lifen-ruby-style.git
|
336
|
+
```
|
337
|
+
|
338
|
+
- Modifier le `Gemfile` de votre projet local (e.g. Alphonse) :
|
339
|
+
|
340
|
+
```ruby
|
341
|
+
group :development, :test do
|
342
|
+
gem 'lifen-ruby-style', path: '../lifen-ruby-style'
|
343
|
+
end
|
344
|
+
```
|
345
|
+
|
346
|
+
- Modifier le fichier `.rubocop.yml` :
|
347
|
+
|
348
|
+
```yaml
|
349
|
+
inherit_from:
|
350
|
+
- ../lifen-ruby-style/default_rubocop.yml
|
351
|
+
```
|
352
|
+
|
353
|
+
- Créer le fichier `.overcommit.yml` et coller le contenu du fichier `lifen-ruby-style/default_overcommit.yml`
|
354
|
+
|
355
|
+
- Installer les dépendences et les hooks Git :
|
356
|
+
|
357
|
+
```bash
|
358
|
+
$ bundle install
|
359
|
+
$ bundle exec overcommit --install
|
360
|
+
```
|
361
|
+
|
362
|
+
- Vous pouvez maintenant apporter des modifications à la gem (repo `lifen-ruby-style`) et les visualiser sur votre projet local (e.g. `alphonse`).
|
363
|
+
|
364
|
+
**ATTENTION : La configuration d'overcommit n'est pas liée automatiquement au projet, il faut la copier/coller dans le projet cible après avoir effectué des changements.**
|
365
|
+
|
366
|
+
## Contributions
|
367
|
+
|
368
|
+
Comme pour n'importe quel autre projet :
|
369
|
+
|
370
|
+
- cloner le repo
|
371
|
+
- créer une nouvelle branche
|
372
|
+
- soumettre une PR
|
373
|
+
|
374
|
+
Vous allez vouloir tester localement les modifications de règle de style que vous proposez. L'idée est d'utiliser votre version locale de la gem `lifen-ruby-style` sur un projet local (e.g. Alphonse), suivre les instructions pour l'[utilisation d'une version locale](#utilisation-dune-version-locale).
|
375
|
+
|
376
|
+
**ATTENTION : La configuration d'overcommit n'est pas liée automatiquement au projet, il faut la copier/coller dans le projet cible après avoir effectué des changements.**
|
377
|
+
|
378
|
+
## TODO
|
379
|
+
|
380
|
+
[ ] Recommandations spécifiques pour Sublime Text
|
381
|
+
[ ] Lier la configuration d'overcommit aux repos
|
382
|
+
[ ] Ajouter un hook de pre-push ?
|
383
|
+
[ ] Ajouter le hook de pre-commit au CI
|
384
|
+
[ ] Ajouter `pronto-faster` si pertinent
|
385
|
+
[ ] Ajouter `pronto-reek` si pertinent
|
386
|
+
[ ] Ajouter `pronto-slim_lint` si pertinent
|
387
|
+
[ ] Ajouter `pronto-scss` si pertinent
|
388
|
+
|
389
|
+
## Archives
|
390
|
+
|
391
|
+
<details><summary>Ajouter un "hook" git d'exécution de rubocop</summary>
|
392
|
+
|
393
|
+
Créer le fichier `.git/hooks/pre-commit` avec :
|
394
|
+
|
395
|
+
```bash
|
396
|
+
#!/bin/bash
|
397
|
+
|
398
|
+
git status -s | grep -E 'A|M' | awk '{print $2}' | xargs rubocop --display-cop-names --extra-details --parallel --force-exclusion
|
399
|
+
```
|
400
|
+
|
401
|
+
</details>
|
402
|
+
|
403
|
+
<details><summary>Ajouter rubocop au CircleCI</summary>
|
404
|
+
|
405
|
+
Il suffit d'ajouter dans le flow un job avant les tests (ou en parallèles) avec la commande suivante :
|
406
|
+
|
407
|
+
```bash
|
408
|
+
git diff-tree -r --no-commit-id --name-status 'origin/develop..HEAD' | grep -E 'A|M' | awk '{print $2}' | xargs --no-run-if-empty bundle exec rubocop --config .rubocop.yml --force-exclusion --fail-level warn
|
409
|
+
```
|
410
|
+
|
411
|
+
</details>
|
data/Rakefile
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Use this file to configure the Overcommit hooks you wish to use. This will
|
2
|
+
# extend the default configuration defined in:
|
3
|
+
# https://github.com/sds/overcommit/blob/master/config/default.yml
|
4
|
+
#
|
5
|
+
# At the topmost level of this YAML file is a key representing type of hook
|
6
|
+
# being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
|
7
|
+
# customize each hook, such as whether to only run it on certain files (via
|
8
|
+
# `include`), whether to only display output if it fails (via `quiet`), etc.
|
9
|
+
#
|
10
|
+
# For a complete list of hooks, see:
|
11
|
+
# https://github.com/sds/overcommit/tree/master/lib/overcommit/hook
|
12
|
+
#
|
13
|
+
# For a complete list of options that you can use to customize hooks, see:
|
14
|
+
# https://github.com/sds/overcommit#configuration
|
15
|
+
#
|
16
|
+
# Uncomment the following lines to make the configuration take effect.
|
17
|
+
|
18
|
+
PreCommit:
|
19
|
+
Pronto:
|
20
|
+
enabled: true
|
21
|
+
|
22
|
+
GoFmt:
|
23
|
+
enabled: false
|
24
|
+
|
25
|
+
CommitMsg:
|
26
|
+
CapitalizedSubject:
|
27
|
+
enabled: false
|
28
|
+
|
29
|
+
SingleLineSubject:
|
30
|
+
enabled: true
|
31
|
+
on_warn: fail
|
32
|
+
|
33
|
+
TextWidth:
|
34
|
+
enabled: true
|
35
|
+
on_warn: fail
|
36
|
+
|
37
|
+
TrailingPeriod:
|
38
|
+
enabled: true
|
39
|
+
on_warn: fail
|
40
|
+
#PreCommit:
|
41
|
+
# RuboCop:
|
42
|
+
# enabled: true
|
43
|
+
# on_warn: fail # Treat all warnings as failures
|
44
|
+
#
|
45
|
+
# TrailingWhitespace:
|
46
|
+
# enabled: true
|
47
|
+
# exclude:
|
48
|
+
# - '**/db/structure.sql' # Ignore trailing whitespace in generated files
|
49
|
+
#
|
50
|
+
#PostCheckout:
|
51
|
+
# ALL: # Special hook name that customizes all hooks of this type
|
52
|
+
# quiet: true # Change all post-checkout hooks to only display output on failure
|
53
|
+
#
|
54
|
+
# IndexTags:
|
55
|
+
# enabled: true # Generate a tags file with `ctags` each time HEAD changes
|