rubocop_rules 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +9 -0
- data/.rubocop.yml +17 -5
- data/.rubocop_common.yml +11 -17
- data/.travis.yml +1 -1
- data/CHANGELOG.md +16 -5
- data/README.md +85 -7
- data/lib/rubocop_rules/cli.rb +37 -10
- data/lib/rubocop_rules/version.rb +1 -1
- data/rubocop-rules.gemspec +1 -0
- data/templates/.rubocop.yml +19 -0
- data/templates/.rubosync.yml +2 -0
- metadata +19 -3
- data/.rubocop_todo.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e0bd546785d9a1d9df847bf044ae292ec66c401
|
4
|
+
data.tar.gz: 2f00f916b40b00a277af380347d70dd3239e4906
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2fa4ec3bfb6745389f50cc0c924629651552ddc0d269a8ba015efb7ad2bffc14c621e336c815dede00b092ef0b63babcaa0489e638f99eabde9efcc201db43e
|
7
|
+
data.tar.gz: afc0abcc63f6d213da68b9ecabd65aa588a146fc6c3ca41b8c03559a3f2450c3d081ff44721ba1c82ac8aa1a643b179dcbd44f01725ca71d1dcdd41dc753b847
|
data/.editorconfig
ADDED
data/.rubocop.yml
CHANGED
@@ -12,8 +12,20 @@
|
|
12
12
|
inherit_from:
|
13
13
|
- .rubocop_common.yml
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
AllCops:
|
16
|
+
Exclude:
|
17
|
+
- db/**/*
|
18
|
+
|
19
|
+
Rails:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Style/SymbolArray:
|
23
|
+
EnforcedStyle: brackets
|
24
|
+
|
25
|
+
Metrics/LineLength:
|
26
|
+
Max: 100
|
27
|
+
|
28
|
+
Metrics/BlockLength:
|
29
|
+
Exclude:
|
30
|
+
- '*.gemspec'
|
31
|
+
- 'spec/**/*.rb'
|
data/.rubocop_common.yml
CHANGED
@@ -1,19 +1,13 @@
|
|
1
1
|
##############
|
2
2
|
# Global rules
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
Max: 100
|
15
|
-
|
16
|
-
Metrics/BlockLength:
|
17
|
-
Exclude:
|
18
|
-
- '*.gemspec'
|
19
|
-
- 'spec/**/*.rb'
|
3
|
+
#
|
4
|
+
# This file is meant to be shared across all projects belonging to a specific team.
|
5
|
+
# Check this file in to a dedicated repo, and link to it .rubosync.yml config file.
|
6
|
+
# Evolve it over time and use rubocop-rules update to apply it.
|
7
|
+
#
|
8
|
+
|
9
|
+
# Example:
|
10
|
+
# ========
|
11
|
+
# AllCops:
|
12
|
+
# Exclude:
|
13
|
+
# - db/**/*
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,16 +1,27 @@
|
|
1
1
|
# Changelog
|
2
|
+
|
2
3
|
All notable changes to this project will be documented in this file.
|
3
4
|
|
4
|
-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
|
-
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project
|
6
|
+
adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
7
|
|
7
8
|
## [Unreleased]
|
8
9
|
|
10
|
+
## [1.1.0] - 2017-11-28
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
* Sync .rubocop_common.yml from external git repo
|
15
|
+
|
9
16
|
## [1.0.2] - 2017-11-09
|
17
|
+
|
10
18
|
### Changed
|
11
|
-
|
19
|
+
|
20
|
+
* spec/lint_spec.rb was not packaged
|
12
21
|
|
13
22
|
## [1.0.1] - 2017-11-09
|
23
|
+
|
14
24
|
### Added
|
15
|
-
|
16
|
-
|
25
|
+
|
26
|
+
* rubocop-rules init
|
27
|
+
* rubocop-rules update
|
data/README.md
CHANGED
@@ -1,7 +1,18 @@
|
|
1
|
-
|
1
|
+
[![Build Status](https://travis-ci.org/klippx/rubocop_rules.svg?branch=master)](https://travis-ci.org/klippx/rubocop_rules)
|
2
|
+
|
3
|
+
# Rubocop Rules
|
2
4
|
|
3
5
|
A common place to house rubocop rule enforcement across projects.
|
4
6
|
|
7
|
+
When you or your team have a large number of repos, with different Rubocop Rules spread all over the
|
8
|
+
place, it gets hard to maintain and sync all "shared" config together with project specific
|
9
|
+
"tweaks", as well as todos that are more like todonts...
|
10
|
+
|
11
|
+
This is where this tool can be quite handy. It enables you to put all SHARED stuff in one single
|
12
|
+
place, and you and your team can develop this file gradually over time. This tool downloads the
|
13
|
+
latest version and applies it to your project, leaving you with clean rubocop_todo files and still
|
14
|
+
allowing you to have project specific overrides.
|
15
|
+
|
5
16
|
## Installation
|
6
17
|
|
7
18
|
Add this line to your application's Gemfile:
|
@@ -24,17 +35,84 @@ After installing the gem, you need to initialize your project using the provided
|
|
24
35
|
|
25
36
|
### Initializing a project
|
26
37
|
|
27
|
-
Initialize your project with the cli: `rubocop-rules init
|
38
|
+
Initialize your project with the cli: `rubocop-rules init`, sample output:
|
39
|
+
|
40
|
+
```shell
|
41
|
+
$ bundle exec rubocop-rules init
|
42
|
+
Copying config...
|
43
|
+
create .rubosync.yml
|
44
|
+
create .rubocop.yml
|
45
|
+
create spec/lint_spec.rb
|
46
|
+
Downloading latest configuration from git://github.com/klippx/rubocop_rules.git...
|
47
|
+
create .rubocop_common.yml
|
48
|
+
Autocorrecting your code... 28 files inspected, 59 offenses detected
|
49
|
+
Generating rubocop_todo... Run `rubocop --config .rubocop_todo.yml`, or add `inherit_from: .rubocop_todo.yml` in a .rubocop.yml file.
|
50
|
+
Adding rubocop_todo to configuration...
|
51
|
+
insert .rubocop.yml
|
52
|
+
```
|
53
|
+
|
54
|
+
This will create a few files:
|
28
55
|
|
29
|
-
|
30
|
-
|
56
|
+
* `.rubosync.yml` is the configuration object for this micro-framework. Use this to configure your
|
57
|
+
git remote hosting the shared rubocop configuration. By default it will use this repo, which is
|
58
|
+
empty. The idea is to customize this.
|
59
|
+
* `.rubocop.yml` will source the required rubocop yml files
|
60
|
+
* `rubucop_common.yml` is downloaded from git remote specified in `.rubosync.yml`. Note that it
|
61
|
+
expects the `rubucop_common.yml` in the root of this git repo.
|
31
62
|
|
32
|
-
|
63
|
+
The script it will then run `rubucop -a` to automatically fix what can be fixed for you. In addition
|
64
|
+
to this it will create `rubucop_todo.yml` to put what cannot be fixed in quarantine for you to fix
|
65
|
+
later.
|
66
|
+
|
67
|
+
Finally, a linter spec `spec/lint_spec.rb` is added to make sure your code is following the common
|
68
|
+
conventions.
|
33
69
|
|
34
70
|
### Updating a project
|
35
71
|
|
36
|
-
Whenever a new version of the gem is deployed, you may update your project configuration using the
|
37
|
-
will
|
72
|
+
Whenever a new version of the gem is deployed, you may update your project configuration using the
|
73
|
+
command: `rubocop-rules update`. This command will download a fresh copy of `rubucop_common.yml`, it
|
74
|
+
will run autofixes and regenerate a new `rubucop_todo.yml` for you!
|
75
|
+
|
76
|
+
Sample output:
|
77
|
+
|
78
|
+
```shell
|
79
|
+
$ bundle exec rubocop-rules update
|
80
|
+
Recreating configuration...
|
81
|
+
remove .rubocop_common.yml
|
82
|
+
Downloading latest configuration from ssh://git@stash.int.klarna.net:7999/klapp/rubocop_common.git...
|
83
|
+
create .rubocop_common.yml
|
84
|
+
Regenerating rubocop_todo...
|
85
|
+
remove .rubocop_todo.yml
|
86
|
+
gsub .rubocop.yml
|
87
|
+
gsub .rubocop.yml
|
88
|
+
```
|
89
|
+
|
90
|
+
## Best practices
|
91
|
+
|
92
|
+
### .rubosync.yml
|
93
|
+
|
94
|
+
Only configured once per repo, point it to the correct remote.
|
95
|
+
|
96
|
+
### .rubocop_common.yml
|
97
|
+
|
98
|
+
Never update `.rubocop_common.yml` directly. Allow this tool take care of this for you.
|
99
|
+
|
100
|
+
If you feel that you need to update the config in `.rubocop_common.yml`, update it on the shared git
|
101
|
+
repo housing this file instead, and then reissue the `rubocop-rules update` command.
|
102
|
+
|
103
|
+
### .rubocop_todo.yml
|
104
|
+
|
105
|
+
Never update `.rubocop_todo.yml` directly. Allow this tool take care of this for you.
|
106
|
+
|
107
|
+
If you feel that you need to update the config in `.rubocop_todo.yml`, fix the actual source code
|
108
|
+
and then reissue the `rubocop-rules update` command.
|
109
|
+
|
110
|
+
### .rubocop.yml
|
111
|
+
|
112
|
+
Update `.rubocop.yml` for project specific overrides. Could be a project with a very large Rake task
|
113
|
+
that is pending removal rather than refactoring.
|
114
|
+
|
115
|
+
Keep this to a minimum and always consider if it belongs in .rubocop_common.yml or not.
|
38
116
|
|
39
117
|
## Development
|
40
118
|
|
data/lib/rubocop_rules/cli.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'open3'
|
3
|
+
require 'git'
|
4
|
+
require 'yaml'
|
3
5
|
|
4
6
|
module RubocopRules
|
5
7
|
module CLI
|
@@ -22,15 +24,15 @@ module RubocopRules
|
|
22
24
|
desc 'init', 'Initialize RubocopRules in your project'
|
23
25
|
def init
|
24
26
|
puts 'Copying config... '
|
25
|
-
copy_file '.
|
26
|
-
copy_file '
|
27
|
+
copy_file 'templates/.rubosync.yml', '.rubosync.yml'
|
28
|
+
copy_file 'templates/.rubocop.yml', '.rubocop.yml'
|
27
29
|
copy_file 'spec/lint_spec.rb', 'spec/lint_spec.rb'
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
+
ensure_rubosync_config
|
32
|
+
rubosync_common
|
31
33
|
|
32
|
-
print 'Generating rubocop_todo...
|
33
|
-
|
34
|
+
print 'Generating rubocop_todo...'
|
35
|
+
generate_todo
|
34
36
|
|
35
37
|
puts 'Adding rubocop_todo to configuration... '
|
36
38
|
insert_into_file '.rubocop.yml', ' - .rubocop_todo.yml', after: " - .rubocop_common.yml\n"
|
@@ -39,19 +41,44 @@ module RubocopRules
|
|
39
41
|
desc 'update', 'Regenerate RubocopRules configuration in your project'
|
40
42
|
def update
|
41
43
|
puts 'Recreating configuration...'
|
44
|
+
ensure_rubosync_config
|
42
45
|
remove_file '.rubocop_common.yml'
|
43
|
-
|
46
|
+
rubosync_common
|
44
47
|
|
45
|
-
puts 'Regenerating rubocop_todo...
|
48
|
+
puts 'Regenerating rubocop_todo...'
|
46
49
|
remove_file '.rubocop_todo.yml'
|
47
50
|
comment_lines '.rubocop.yml', /\.rubocop_todo\.yml/
|
48
|
-
|
49
|
-
run_process(command: 'rubocop --auto-gen-config', silent: true)
|
51
|
+
generate_todo(silent: true)
|
50
52
|
uncomment_lines '.rubocop.yml', /\.rubocop_todo\.yml/
|
51
53
|
end
|
52
54
|
|
53
55
|
private
|
54
56
|
|
57
|
+
def generate_todo(silent: false)
|
58
|
+
run_process(command: 'rubocop -a', silent: silent)
|
59
|
+
run_process(command: 'rubocop --auto-gen-config', silent: silent)
|
60
|
+
end
|
61
|
+
|
62
|
+
def ensure_rubosync_config
|
63
|
+
unless File.exist?('.rubosync.yml')
|
64
|
+
raise 'Missing configuration file! Please add and configure .rubosync.yml'
|
65
|
+
end
|
66
|
+
@config = YAML.safe_load(ERB.new(File.read('.rubosync.yml')).result, [], [], true)
|
67
|
+
end
|
68
|
+
|
69
|
+
def rubosync_common
|
70
|
+
unless @config && @config['git'] && @config['git']['repo']
|
71
|
+
raise 'Missing git repo in configuration! Please configure .rubosync.yml'
|
72
|
+
end
|
73
|
+
repo = @config['git']['repo']
|
74
|
+
|
75
|
+
puts "Downloading latest configuration from #{repo}..."
|
76
|
+
Git.clone(repo, 'common')
|
77
|
+
copy_file Dir.pwd + '/common/.rubocop_common.yml', '.rubocop_common.yml'
|
78
|
+
ensure
|
79
|
+
FileUtils.rm_rf('./common')
|
80
|
+
end
|
81
|
+
|
55
82
|
def run_process(command:, silent: false)
|
56
83
|
output = ''
|
57
84
|
Open3.popen2(command) do |stdin, stdout_stderr, wait_thr|
|
data/rubocop-rules.gemspec
CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.bindir = 'bin'
|
33
33
|
spec.executables = spec.files.grep(%r{^bin/rubocop-rules}) { |f| File.basename(f) }
|
34
34
|
spec.require_paths = ['lib']
|
35
|
+
spec.add_dependency 'git'
|
35
36
|
spec.add_dependency 'rubocop', '~> 0.51.0'
|
36
37
|
spec.add_dependency 'thor'
|
37
38
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
###########################
|
2
|
+
# Configuration for rubocop
|
3
|
+
# in .rubocop.yml
|
4
|
+
|
5
|
+
##############
|
6
|
+
# Global rules
|
7
|
+
# see .rubocop_common.yml
|
8
|
+
|
9
|
+
##############
|
10
|
+
# Inherit default rules first, and then override those rules with
|
11
|
+
# our violation whitelist.
|
12
|
+
inherit_from:
|
13
|
+
- .rubocop_common.yml
|
14
|
+
|
15
|
+
##############
|
16
|
+
# Project specific overrides here, example:
|
17
|
+
# Metrics/BlockLength:
|
18
|
+
# Exclude:
|
19
|
+
# - 'tasks/the_huge_task.rake'
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop_rules
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathias Klippinge
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: git
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rubocop
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,11 +118,11 @@ executables:
|
|
104
118
|
extensions: []
|
105
119
|
extra_rdoc_files: []
|
106
120
|
files:
|
121
|
+
- ".editorconfig"
|
107
122
|
- ".gitignore"
|
108
123
|
- ".rspec"
|
109
124
|
- ".rubocop.yml"
|
110
125
|
- ".rubocop_common.yml"
|
111
|
-
- ".rubocop_todo.yml"
|
112
126
|
- ".travis.yml"
|
113
127
|
- CHANGELOG.md
|
114
128
|
- Gemfile
|
@@ -123,6 +137,8 @@ files:
|
|
123
137
|
- lib/rubocop_rules/version.rb
|
124
138
|
- rubocop-rules.gemspec
|
125
139
|
- spec/lint_spec.rb
|
140
|
+
- templates/.rubocop.yml
|
141
|
+
- templates/.rubosync.yml
|
126
142
|
homepage:
|
127
143
|
licenses: []
|
128
144
|
metadata:
|
data/.rubocop_todo.yml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on 2017-11-09 14:30:10 +0100 using RuboCop version 0.51.0.
|
4
|
-
# The point is for the user to remove these configuration records
|
5
|
-
# one by one as the offenses are removed from the code base.
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|