armitage-rubocop 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -0
- data/Rakefile +29 -14
- data/armitage-rubocop.gemspec +1 -1
- data/lib/general/layout.yml +2 -2
- data/lib/general/metrics.yml +1 -0
- data/lib/general/naming.yml +1 -1
- data/lib/general/style.yml +2 -0
- data/lib/rspec/rspec.yml +1 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf9988be221ab5c4cfdf372e5086ecdde56e6bf917948d630641d297244cbee0
|
4
|
+
data.tar.gz: b24b32fc84e143eb9452083a917649ad7ff58581e9e3c6264f2803d993d8547a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f75a43f8b08530f675a164f25e209af5e35f864238b5ca8f12f925c6a1502c6321206fb7be336afb819ed95fe864e48fba910132bd32b71653de6add6ec79178
|
7
|
+
data.tar.gz: a86dbe13e40123aa55bc2cfd41fd234118904392ccdfc10c66836d39f98adc67d0bd05fe3a73a85409f944edd1a6ffe60941208befd8a85fe7ac90215d5764c0
|
data/README.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# armitage-rubocop
|
2
2
|
|
3
|
+
- [Installation](#installation)
|
4
|
+
- [Usage](#usage)
|
5
|
+
- [Build](#build)
|
6
|
+
|
7
|
+
---
|
8
|
+
|
3
9
|
### Installation
|
4
10
|
```ruby
|
5
11
|
gem 'armitage-rubocop'
|
@@ -15,6 +21,8 @@ $ gem install 'armitage-rubocop'
|
|
15
21
|
require 'armitage-rubocop'
|
16
22
|
```
|
17
23
|
|
24
|
+
---
|
25
|
+
|
18
26
|
### Usage
|
19
27
|
|
20
28
|
- edit your `.rubocop.yml` file:
|
@@ -33,3 +41,21 @@ inheit_gem:
|
|
33
41
|
# rails-specific cops + general + rspec
|
34
42
|
armitage-rubocop: lib/rubocop.rails.yml
|
35
43
|
```
|
44
|
+
|
45
|
+
---
|
46
|
+
|
47
|
+
### Build
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
# --- full build ---
|
51
|
+
bundle exec rake armitage_rubocop:build
|
52
|
+
|
53
|
+
# --- validate code style ---
|
54
|
+
bundle exec rake rubocop
|
55
|
+
|
56
|
+
# --- validate yaml files ---
|
57
|
+
bundle exec rake armitage_rubocop:validation:valid_yamls
|
58
|
+
|
59
|
+
# --- validate rubocop cops (existence and params) ---
|
60
|
+
bundle exec rake armitage_rubocop:validation:recognizable_cops
|
61
|
+
```
|
data/Rakefile
CHANGED
@@ -2,12 +2,14 @@
|
|
2
2
|
|
3
3
|
require 'bundler/gem_tasks'
|
4
4
|
require 'rubocop/rake_task'
|
5
|
+
require 'open3'
|
5
6
|
require 'yaml'
|
6
7
|
require 'rubocop'
|
7
|
-
require '
|
8
|
+
require 'rubocop-rspec'
|
8
9
|
|
9
10
|
RuboCop::RakeTask.new(:rubocop) do |t|
|
10
11
|
t.options = %w[--config ./lib/rubocop.general.yml]
|
12
|
+
t.requires << 'rubocop-rspec'
|
11
13
|
end
|
12
14
|
|
13
15
|
namespace :armitage_rubocop do
|
@@ -26,7 +28,7 @@ namespace :armitage_rubocop do
|
|
26
28
|
# NOTE: results structure { type => exit_code }
|
27
29
|
results = {}.tap do |result_data|
|
28
30
|
build_processes.each_pair do |build_type, build_process|
|
29
|
-
# NOTE: build_process => [stdin, stdout, stderr,
|
31
|
+
# NOTE: build_process => [stdin, stdout, stderr, wtr]
|
30
32
|
build_result = build_process[3].value.exitstatus
|
31
33
|
result_data[build_type] = build_result
|
32
34
|
end
|
@@ -53,13 +55,7 @@ namespace :armitage_rubocop do
|
|
53
55
|
|
54
56
|
# NOTE: try to load without Psych exceptions
|
55
57
|
invalid_yamls = yamls.each_with_object([]) do |file_name, invalid_files|
|
56
|
-
|
57
|
-
begin
|
58
|
-
YAML.load(File.read(file_name))
|
59
|
-
rescue StandardError
|
60
|
-
invalid_files << "- \e[33m#{file_name}\e[0m"
|
61
|
-
end
|
62
|
-
# rubocop:enable Style/RedundantBegin
|
58
|
+
YAML.load(File.read(file_name)) rescue (invalid_files << "- \e[33m#{file_name}\e[0m")
|
63
59
|
end
|
64
60
|
|
65
61
|
if invalid_yamls.empty?
|
@@ -74,7 +70,7 @@ namespace :armitage_rubocop do
|
|
74
70
|
desc 'Checks that all defined cops can be used'
|
75
71
|
task :recognizable_cops do
|
76
72
|
yamls = Dir[Pathname.new(__FILE__).join('../lib/**/*.yml')]
|
77
|
-
invalid_cops =
|
73
|
+
invalid_cops = Hash.new { |h, k| h[k] = +'' }
|
78
74
|
|
79
75
|
# NOTE: strongly rubocop-related realization
|
80
76
|
# - see https://github.com/rubocop-hq/rubocop/blob/master/lib/rubocop/config.rb
|
@@ -86,19 +82,38 @@ namespace :armitage_rubocop do
|
|
86
82
|
yamls.each do |yaml_file|
|
87
83
|
rubocop_config = RuboCop::ConfigLoader.load_file(yaml_file)
|
88
84
|
|
89
|
-
|
85
|
+
# NOTE: validate cop existence
|
86
|
+
rubocop_config.keys.each do |cop|
|
90
87
|
next if RuboCop::ConfigLoader.default_configuration.key?(cop)
|
91
88
|
next if RuboCop::Cop::Cop.registry.contains_cop_matching?([cop])
|
92
89
|
next if cop == 'inherit_mode'
|
93
|
-
invalid_cops << "
|
90
|
+
invalid_cops[cop] << "\e[31mBAD COP\e[0m"
|
91
|
+
end
|
92
|
+
|
93
|
+
# NOTE: validate cop params
|
94
|
+
rubocop_config.keys.each do |cop|
|
95
|
+
next if invalid_cops.key?(cop)
|
96
|
+
invalid_params = []
|
97
|
+
|
98
|
+
rubocop_config[cop].each_key do |cop_param|
|
99
|
+
next if RuboCop::Config::COMMON_PARAMS.include?(cop_param)
|
100
|
+
next if RuboCop::ConfigLoader.default_configuration[cop].key?(cop_param)
|
101
|
+
invalid_params << "\e[35m#{cop_param}\e[0m"
|
102
|
+
end
|
103
|
+
|
104
|
+
next if invalid_params.empty?
|
105
|
+
invalid_cops[cop] = "\e[31mBAD PARAMS\e[0m: #{invalid_params.join(', ')}"
|
94
106
|
end
|
95
107
|
end
|
96
108
|
|
97
109
|
if invalid_cops.empty?
|
98
110
|
puts "[\e[32mCOP RECOGNITION CHECK\e[0m] => \e[1;33mall cops are recognizable!\e[0m"
|
99
111
|
else
|
100
|
-
invalid_cops_message = invalid_cops.
|
101
|
-
|
112
|
+
invalid_cops_message = invalid_cops.each_pair.map do |cop, message|
|
113
|
+
"[\e[32m#{cop}\e[0m]\t- #{message}"
|
114
|
+
end.join("\n")
|
115
|
+
|
116
|
+
abort "[\e[31mCOP RECOGNITION CHECK\e[0m] => some cops can not be fully recognized:\n" \
|
102
117
|
"#{invalid_cops_message}"
|
103
118
|
end
|
104
119
|
end
|
data/armitage-rubocop.gemspec
CHANGED
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = 'armitage-rubocop'
|
9
|
-
spec.version = '0.
|
9
|
+
spec.version = '0.2.0'
|
10
10
|
spec.license = 'MIT'
|
11
11
|
spec.authors = ['Rustam Ibragimov']
|
12
12
|
spec.email = ['iamdaiver@icloud.com']
|
data/lib/general/layout.yml
CHANGED
data/lib/general/metrics.yml
CHANGED
data/lib/general/naming.yml
CHANGED
data/lib/general/style.yml
CHANGED
data/lib/rspec/rspec.yml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: armitage-rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Ibragimov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|