best_practice_project 0.0.1 → 0.0.2
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/Gemfile +6 -4
- data/Gemfile.lock +3 -57
- data/VERSION +1 -1
- data/best_practice_project.gemspec +8 -16
- data/lib/best_practice_project.rb +68 -76
- data/lib/best_practice_project/rubocop_handler.rb +97 -0
- data/{config → lib/config}/rubocop.yml +4 -0
- data/lib/tasks/best_practice_project.rake +2 -2
- metadata +9 -50
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7476699c6b4511029adeecf0d84827384f943a9b
|
|
4
|
+
data.tar.gz: d21a33dcb8e43f164cdc06446d061c299da1bedf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e7a57f1f55926c87e7a2b11741b6c5b1bf8b88d85b9caf66f7c2b6f3d8c005b623232003dc014abd0d88cade9e8a100c027a24ce3927ad24db950ee54a4ef7d1
|
|
7
|
+
data.tar.gz: 412447dde027d00e4d9fecfd4d9994ad709c5eb93dc1354a9dcf4c780762951fe8597c75925d88cf9986feeaa9cbdd41e1d432971542869eeca26b36b6db5412
|
data/Gemfile
CHANGED
|
@@ -3,10 +3,12 @@ source "http://rubygems.org"
|
|
|
3
3
|
# Example:
|
|
4
4
|
# gem "activesupport", ">= 2.3.5"
|
|
5
5
|
|
|
6
|
-
gem "rubocop", "0.35.0", require: false
|
|
7
|
-
gem "coffeelint", "1.11.0", require: false
|
|
8
|
-
gem "scss_lint", require: false
|
|
9
|
-
gem "rails_best_practices", require: false
|
|
6
|
+
#gem "rubocop", "~> 0.35.0", require: false
|
|
7
|
+
#gem "coffeelint", "~> 1.11.0", require: false
|
|
8
|
+
#gem "scss_lint", "~> 0.42.2", require: false
|
|
9
|
+
#gem "rails_best_practices", "~> 1.15.7", require: false
|
|
10
|
+
|
|
11
|
+
gem "psych", "~> 2.0.0", require: false
|
|
10
12
|
|
|
11
13
|
# Add dependencies to develop your gem here.
|
|
12
14
|
# Include everything needed to run rake, tests, features, etc.
|
data/Gemfile.lock
CHANGED
|
@@ -1,34 +1,12 @@
|
|
|
1
1
|
GEM
|
|
2
2
|
remote: http://rubygems.org/
|
|
3
3
|
specs:
|
|
4
|
-
activesupport (4.2.4)
|
|
5
|
-
i18n (~> 0.7)
|
|
6
|
-
json (~> 1.7, >= 1.7.7)
|
|
7
|
-
minitest (~> 5.1)
|
|
8
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
|
9
|
-
tzinfo (~> 1.1)
|
|
10
4
|
addressable (2.3.8)
|
|
11
|
-
ast (2.1.0)
|
|
12
|
-
astrolabe (1.3.1)
|
|
13
|
-
parser (~> 2.2)
|
|
14
5
|
builder (3.2.2)
|
|
15
|
-
code_analyzer (0.4.5)
|
|
16
|
-
sexp_processor
|
|
17
|
-
coffee-script (2.4.1)
|
|
18
|
-
coffee-script-source
|
|
19
|
-
execjs
|
|
20
|
-
coffee-script-source (1.9.1.1)
|
|
21
|
-
coffeelint (1.11.0)
|
|
22
|
-
coffee-script
|
|
23
|
-
execjs
|
|
24
|
-
json
|
|
25
|
-
colored (1.2)
|
|
26
6
|
descendants_tracker (0.0.4)
|
|
27
7
|
thread_safe (~> 0.3, >= 0.3.1)
|
|
28
8
|
diff-lcs (1.1.3)
|
|
29
9
|
docile (1.1.5)
|
|
30
|
-
erubis (2.7.0)
|
|
31
|
-
execjs (2.6.0)
|
|
32
10
|
faraday (0.9.2)
|
|
33
11
|
multipart-post (>= 1.2, < 3)
|
|
34
12
|
git (1.2.9.1)
|
|
@@ -42,7 +20,6 @@ GEM
|
|
|
42
20
|
oauth2
|
|
43
21
|
hashie (3.4.3)
|
|
44
22
|
highline (1.7.8)
|
|
45
|
-
i18n (0.7.0)
|
|
46
23
|
jeweler (2.0.1)
|
|
47
24
|
builder
|
|
48
25
|
bundler (>= 1.0)
|
|
@@ -55,7 +32,6 @@ GEM
|
|
|
55
32
|
json (1.8.3)
|
|
56
33
|
jwt (1.5.2)
|
|
57
34
|
mini_portile (0.6.2)
|
|
58
|
-
minitest (5.8.2)
|
|
59
35
|
multi_json (1.11.2)
|
|
60
36
|
multi_xml (0.5.5)
|
|
61
37
|
multipart-post (2.0.0)
|
|
@@ -67,24 +43,11 @@ GEM
|
|
|
67
43
|
multi_json (~> 1.3)
|
|
68
44
|
multi_xml (~> 0.5)
|
|
69
45
|
rack (~> 1.2)
|
|
70
|
-
|
|
71
|
-
ast (>= 1.1, < 3.0)
|
|
72
|
-
powerpack (0.1.1)
|
|
46
|
+
psych (2.0.5)
|
|
73
47
|
rack (1.6.4)
|
|
74
|
-
rails_best_practices (1.15.7)
|
|
75
|
-
activesupport
|
|
76
|
-
code_analyzer (>= 0.4.3)
|
|
77
|
-
colored
|
|
78
|
-
erubis
|
|
79
|
-
i18n
|
|
80
|
-
json
|
|
81
|
-
require_all
|
|
82
|
-
ruby-progressbar
|
|
83
|
-
rainbow (2.0.0)
|
|
84
48
|
rake (10.4.2)
|
|
85
49
|
rdoc (3.12.2)
|
|
86
50
|
json (~> 1.4)
|
|
87
|
-
require_all (1.3.3)
|
|
88
51
|
rspec (2.8.0)
|
|
89
52
|
rspec-core (~> 2.8.0)
|
|
90
53
|
rspec-expectations (~> 2.8.0)
|
|
@@ -93,40 +56,23 @@ GEM
|
|
|
93
56
|
rspec-expectations (2.8.0)
|
|
94
57
|
diff-lcs (~> 1.1.2)
|
|
95
58
|
rspec-mocks (2.8.0)
|
|
96
|
-
rubocop (0.35.0)
|
|
97
|
-
astrolabe (~> 1.3)
|
|
98
|
-
parser (>= 2.2.3.0, < 3.0)
|
|
99
|
-
powerpack (~> 0.1)
|
|
100
|
-
rainbow (>= 1.99.1, < 3.0)
|
|
101
|
-
ruby-progressbar (~> 1.7)
|
|
102
|
-
ruby-progressbar (1.7.5)
|
|
103
|
-
sass (3.4.19)
|
|
104
|
-
scss_lint (0.42.2)
|
|
105
|
-
rainbow (~> 2.0)
|
|
106
|
-
sass (~> 3.4.15)
|
|
107
|
-
sexp_processor (4.6.0)
|
|
108
59
|
simplecov (0.10.0)
|
|
109
60
|
docile (~> 1.1.0)
|
|
110
61
|
json (~> 1.8)
|
|
111
62
|
simplecov-html (~> 0.10.0)
|
|
112
63
|
simplecov-html (0.10.0)
|
|
113
64
|
thread_safe (0.3.5)
|
|
114
|
-
tzinfo (1.2.2)
|
|
115
|
-
thread_safe (~> 0.1)
|
|
116
65
|
|
|
117
66
|
PLATFORMS
|
|
118
67
|
ruby
|
|
119
68
|
|
|
120
69
|
DEPENDENCIES
|
|
121
70
|
bundler (~> 1.0)
|
|
122
|
-
coffeelint (= 1.11.0)
|
|
123
71
|
jeweler (~> 2.0.1)
|
|
124
|
-
|
|
72
|
+
psych (~> 2.0.0)
|
|
125
73
|
rdoc (~> 3.12)
|
|
126
74
|
rspec (~> 2.8.0)
|
|
127
|
-
rubocop (= 0.35.0)
|
|
128
|
-
scss_lint
|
|
129
75
|
simplecov
|
|
130
76
|
|
|
131
77
|
BUNDLED WITH
|
|
132
|
-
1.10.
|
|
78
|
+
1.10.6
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.2
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
|
-
# stub: best_practice_project 0.0.
|
|
5
|
+
# stub: best_practice_project 0.0.2 ruby lib
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
8
|
s.name = "best_practice_project"
|
|
9
|
-
s.version = "0.0.
|
|
9
|
+
s.version = "0.0.2"
|
|
10
10
|
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
12
12
|
s.require_paths = ["lib"]
|
|
13
13
|
s.authors = ["kaspernj"]
|
|
14
|
-
s.date = "2015-11-
|
|
14
|
+
s.date = "2015-11-25"
|
|
15
15
|
s.description = "A bundle of various linters and code inspection tools"
|
|
16
16
|
s.email = "k@spernj.org"
|
|
17
17
|
s.extra_rdoc_files = [
|
|
@@ -28,8 +28,9 @@ Gem::Specification.new do |s|
|
|
|
28
28
|
"Rakefile",
|
|
29
29
|
"VERSION",
|
|
30
30
|
"best_practice_project.gemspec",
|
|
31
|
-
"config/rubocop.yml",
|
|
32
31
|
"lib/best_practice_project.rb",
|
|
32
|
+
"lib/best_practice_project/rubocop_handler.rb",
|
|
33
|
+
"lib/config/rubocop.yml",
|
|
33
34
|
"lib/tasks/best_practice_project.rake",
|
|
34
35
|
"shippable.yml",
|
|
35
36
|
"spec/best_practice_project_spec.rb",
|
|
@@ -44,20 +45,14 @@ Gem::Specification.new do |s|
|
|
|
44
45
|
s.specification_version = 4
|
|
45
46
|
|
|
46
47
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
47
|
-
s.add_runtime_dependency(%q<
|
|
48
|
-
s.add_runtime_dependency(%q<coffeelint>, ["= 1.11.0"])
|
|
49
|
-
s.add_runtime_dependency(%q<scss_lint>, [">= 0"])
|
|
50
|
-
s.add_runtime_dependency(%q<rails_best_practices>, [">= 0"])
|
|
48
|
+
s.add_runtime_dependency(%q<psych>, ["~> 2.0.0"])
|
|
51
49
|
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
|
52
50
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
|
53
51
|
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
|
54
52
|
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
|
55
53
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
|
56
54
|
else
|
|
57
|
-
s.add_dependency(%q<
|
|
58
|
-
s.add_dependency(%q<coffeelint>, ["= 1.11.0"])
|
|
59
|
-
s.add_dependency(%q<scss_lint>, [">= 0"])
|
|
60
|
-
s.add_dependency(%q<rails_best_practices>, [">= 0"])
|
|
55
|
+
s.add_dependency(%q<psych>, ["~> 2.0.0"])
|
|
61
56
|
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
|
62
57
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
|
63
58
|
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
|
@@ -65,10 +60,7 @@ Gem::Specification.new do |s|
|
|
|
65
60
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
|
66
61
|
end
|
|
67
62
|
else
|
|
68
|
-
s.add_dependency(%q<
|
|
69
|
-
s.add_dependency(%q<coffeelint>, ["= 1.11.0"])
|
|
70
|
-
s.add_dependency(%q<scss_lint>, [">= 0"])
|
|
71
|
-
s.add_dependency(%q<rails_best_practices>, [">= 0"])
|
|
63
|
+
s.add_dependency(%q<psych>, ["~> 2.0.0"])
|
|
72
64
|
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
|
73
65
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
|
74
66
|
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
require "yaml"
|
|
2
|
+
|
|
1
3
|
class BestPracticeProject
|
|
2
|
-
|
|
4
|
+
path = "#{File.dirname(__FILE__)}/best_practice_project"
|
|
5
|
+
|
|
6
|
+
autoload :RubocopHandler, "#{path}/rubocop_handler"
|
|
7
|
+
|
|
8
|
+
attr_reader :rails, :rubocop_handler
|
|
3
9
|
alias_method :rails?, :rails
|
|
4
10
|
|
|
5
11
|
def self.load_tasks
|
|
@@ -7,38 +13,41 @@ class BestPracticeProject
|
|
|
7
13
|
end
|
|
8
14
|
|
|
9
15
|
def initialize
|
|
10
|
-
@
|
|
16
|
+
@rubocop_handler = BestPracticeProject::RubocopHandler.new(best_practice_project: self) if rubocop_installed?
|
|
11
17
|
|
|
12
|
-
if
|
|
13
|
-
@
|
|
14
|
-
|
|
15
|
-
@rubocop_config_path = Rails.root.join("config", "rubocop.yml").to_s
|
|
16
|
-
@scss_config_path = Rails.root.join("config", "scss-lint.yml").to_s
|
|
17
|
-
@coffee_lint_config_path = Rails.root.join("config", "coffeelint.json").to_s
|
|
18
|
-
else
|
|
19
|
-
@rails = false
|
|
20
|
-
|
|
21
|
-
@rubocop_config_path = "config/rubocop.yml"
|
|
18
|
+
if rails?
|
|
19
|
+
@scss_config_path = Rails.root.join("config", "scss-lint.yml").to_s if scss_installed?
|
|
20
|
+
@coffee_lint_config_path = Rails.root.join("config", "coffeelint.json").to_s if coffee_lint_installed?
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
@commands = []
|
|
25
24
|
|
|
26
25
|
if rails?
|
|
27
|
-
@commands << scss_lint_command
|
|
28
|
-
@commands << coffee_lint_command
|
|
29
|
-
@commands << rails_best_practices_command
|
|
26
|
+
@commands << scss_lint_command if scss_installed?
|
|
27
|
+
@commands << coffee_lint_command if coffee_lint_installed?
|
|
28
|
+
@commands << rails_best_practices_command if rails_best_practices_installed?
|
|
30
29
|
end
|
|
31
30
|
|
|
32
|
-
@commands <<
|
|
31
|
+
@commands << proc { @rubocop_handler.execute }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def rails?
|
|
35
|
+
@rails = Object.const_defined?(:Rails) if @rails == nil
|
|
36
|
+
@rails
|
|
33
37
|
end
|
|
34
38
|
|
|
35
39
|
def execute
|
|
36
40
|
process_status = true
|
|
37
41
|
|
|
38
42
|
@commands.each do |command|
|
|
39
|
-
|
|
43
|
+
if command.is_a?(Proc)
|
|
44
|
+
puts "Executing: #{@rubocop_handler.command}"
|
|
45
|
+
status = command.call unless status
|
|
46
|
+
else
|
|
47
|
+
puts "Executing: #{command}"
|
|
48
|
+
status = system(command)
|
|
49
|
+
end
|
|
40
50
|
|
|
41
|
-
status = system(command)
|
|
42
51
|
process_status = status unless status
|
|
43
52
|
end
|
|
44
53
|
|
|
@@ -46,20 +55,9 @@ class BestPracticeProject
|
|
|
46
55
|
end
|
|
47
56
|
|
|
48
57
|
def generate_configs
|
|
49
|
-
|
|
50
|
-
generate_scss_config
|
|
51
|
-
generate_coffee_lint_config
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def rubocop_command
|
|
55
|
-
command = "bundle exec rubocop --display-cop-names"
|
|
56
|
-
command << " --rails" if rails?
|
|
57
|
-
|
|
58
|
-
if File.exist?(@rubocop_config_path)
|
|
59
|
-
command << " \"--config=#{@rubocop_config_path}\""
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
command
|
|
58
|
+
@rubocop_handler.generate_config if rubocop_installed?
|
|
59
|
+
generate_scss_config if scss_lint_installed?
|
|
60
|
+
generate_coffee_lint_config if coffee_lint_installed?
|
|
63
61
|
end
|
|
64
62
|
|
|
65
63
|
def scss_lint_command
|
|
@@ -76,13 +74,51 @@ class BestPracticeProject
|
|
|
76
74
|
|
|
77
75
|
private
|
|
78
76
|
|
|
77
|
+
def rubocop_installed?
|
|
78
|
+
begin
|
|
79
|
+
require "rubocop"
|
|
80
|
+
true
|
|
81
|
+
rescue LoadError
|
|
82
|
+
false
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def scss_lint_installed?
|
|
87
|
+
begin
|
|
88
|
+
require "scss_lint"
|
|
89
|
+
true
|
|
90
|
+
rescue LoadError
|
|
91
|
+
false
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def coffee_lint_installed?
|
|
96
|
+
begin
|
|
97
|
+
require "coffeelint"
|
|
98
|
+
true
|
|
99
|
+
rescue LoadError
|
|
100
|
+
false
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def rails_best_practices_installed?
|
|
105
|
+
begin
|
|
106
|
+
require "rails_best_practices"
|
|
107
|
+
true
|
|
108
|
+
rescue LoadError
|
|
109
|
+
false
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
79
113
|
def generate_coffee_lint_config
|
|
114
|
+
return unless @coffee_lint_config_path
|
|
80
115
|
return puts "Coffee-Lint config already exists in #{@coffee_lint_config_path}" if File.exist?(@coffee_lint_config_path)
|
|
81
116
|
|
|
82
117
|
puts "FIXME: Generate Coffee-Lint configuration!"
|
|
83
118
|
end
|
|
84
119
|
|
|
85
120
|
def generate_scss_config
|
|
121
|
+
return unless @scss_config_path
|
|
86
122
|
return puts "SCSS-Lint config already exists in #{@scss_config_path}" if File.exist?(@scss_config_path)
|
|
87
123
|
|
|
88
124
|
config = `bundle exec scss-lint --format=Config`
|
|
@@ -93,48 +129,4 @@ private
|
|
|
93
129
|
|
|
94
130
|
puts "Generated SCSS-Lint config in #{@scss_config_path}"
|
|
95
131
|
end
|
|
96
|
-
|
|
97
|
-
def generate_rubocop_config
|
|
98
|
-
return puts "Rubocop config already exists in #{@rubocop_config_path}" if File.exist?(@rubocop_config_path)
|
|
99
|
-
|
|
100
|
-
project_todo_path = Rails.root.join("config", "rubocop_todo.yml").to_s
|
|
101
|
-
|
|
102
|
-
generated_todo_config = {}
|
|
103
|
-
generated_todo_config["inherit_from"] = @rubocop_actual_config_path
|
|
104
|
-
generated_todo_config.merge!(generate_rubocop_todo_config)
|
|
105
|
-
|
|
106
|
-
File.open(project_todo_path, "w") do |fp|
|
|
107
|
-
fp.write(YAML.dump(generated_todo_config))
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
puts "Generated Rubocop todo config in #{project_todo_path}"
|
|
111
|
-
|
|
112
|
-
generated_config = {}
|
|
113
|
-
generated_config["inherit_from"] = "rubocop_todo.yml"
|
|
114
|
-
|
|
115
|
-
File.open(@rubocop_config_path, "w") do |fp|
|
|
116
|
-
fp.write(YAML.dump(generated_config))
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
puts "Generated Rubocop config in #{@rubocop_config_path}"
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def generate_rubocop_todo_config
|
|
123
|
-
todo_file_path = Rails.root.join(".rubocop_todo.yml").to_s
|
|
124
|
-
todo_backup_file_path = Rails.root.join(".rubocop_todo_backup.yml").to_s
|
|
125
|
-
|
|
126
|
-
if File.exist?(todo_file_path)
|
|
127
|
-
File.rename(todo_file_path, todo_backup_file_path)
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
system("rubocop --rails --display-cop-names --auto-gen-config --config=#{@rubocop_actual_config_path}")
|
|
131
|
-
|
|
132
|
-
raise "Todo-file was not generated" unless File.exist?(todo_file_path)
|
|
133
|
-
|
|
134
|
-
todo_config = YAML.load_file(todo_file_path)
|
|
135
|
-
File.unlink(todo_file_path)
|
|
136
|
-
File.rename(todo_backup_file_path, todo_file_path) if File.exist?(todo_backup_file_path)
|
|
137
|
-
|
|
138
|
-
todo_config
|
|
139
|
-
end
|
|
140
132
|
end
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
class BestPracticeProject::RubocopHandler
|
|
2
|
+
def initialize(args)
|
|
3
|
+
@bpp = args.fetch(:best_practice_project)
|
|
4
|
+
@actual_config_path = File.realpath("#{File.dirname(__FILE__)}/../../config/rubocop.yml")
|
|
5
|
+
|
|
6
|
+
if rails?
|
|
7
|
+
@config_path = Rails.root.join("config", "rubocop.yml").to_s
|
|
8
|
+
@todo_path = Rails.root.join("config", "rubocop_todo.yml").to_s
|
|
9
|
+
else
|
|
10
|
+
@config_path = "config/rubocop.yml"
|
|
11
|
+
@todo_path = "config/rubocop_todo.yml"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def rails?
|
|
16
|
+
@bpp.rails?
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def update_best_practice_path
|
|
20
|
+
self.inherit_from_to = @actual_config_path
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def reset_best_practice_path
|
|
24
|
+
self.inherit_from_to = "$$$best_practice_project_config_path$$$"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def command
|
|
28
|
+
command = "bundle exec rubocop --display-cop-names"
|
|
29
|
+
command << " --rails" if rails?
|
|
30
|
+
command << " \"--config=#{@config_path}\"" if File.exist?(@config_path)
|
|
31
|
+
command
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def generate_config
|
|
35
|
+
return puts "Rubocop config already exists in #{@config_path}" if File.exist?(@config_path)
|
|
36
|
+
|
|
37
|
+
File.open(@todo_path, "w") do |fp|
|
|
38
|
+
fp.write(generate_todo_config)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
puts "Generated Rubocop todo config in #{@todo_path}"
|
|
42
|
+
|
|
43
|
+
generated_config = {}
|
|
44
|
+
generated_config["inherit_from"] = "rubocop_todo.yml"
|
|
45
|
+
|
|
46
|
+
File.open(@config_path, "w") do |fp|
|
|
47
|
+
fp.write(YAML.dump(generated_config))
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
puts "Generated Rubocop config in #{@config_path}"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def generate_todo_config
|
|
54
|
+
if rails?
|
|
55
|
+
todo_file_path = Rails.root.join(".rubocop_todo.yml").to_s
|
|
56
|
+
todo_backup_file_path = Rails.root.join(".rubocop_todo_backup.yml").to_s
|
|
57
|
+
else
|
|
58
|
+
todo_file_path = ".rubocop_todo.yml"
|
|
59
|
+
todo_backup_file_path = ".rubocop_todo_backup.yml"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
if File.exist?(todo_file_path)
|
|
63
|
+
File.rename(todo_file_path, todo_backup_file_path)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
system("rubocop --rails --display-cop-names --auto-gen-config --config=#{@actual_config_path}")
|
|
67
|
+
|
|
68
|
+
raise "Todo-file was not generated" unless File.exist?(todo_file_path)
|
|
69
|
+
|
|
70
|
+
todo_config = File.read(todo_file_path)
|
|
71
|
+
File.unlink(todo_file_path)
|
|
72
|
+
File.rename(todo_backup_file_path, todo_file_path) if File.exist?(todo_backup_file_path)
|
|
73
|
+
|
|
74
|
+
todo_config
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def execute
|
|
78
|
+
update_best_practice_path
|
|
79
|
+
|
|
80
|
+
begin
|
|
81
|
+
system(command)
|
|
82
|
+
ensure
|
|
83
|
+
reset_best_practice_path
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
private
|
|
88
|
+
|
|
89
|
+
def inherit_from_to=(new_inherit_from)
|
|
90
|
+
todo_config = File.read(@todo_path)
|
|
91
|
+
todo_config.gsub!(/^inherit_from: (.+)$/, "inherit_from: \"#{new_inherit_from}\"")
|
|
92
|
+
|
|
93
|
+
File.open(@todo_path, "w") do |fp|
|
|
94
|
+
fp.write(todo_config)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
AllCops:
|
|
2
2
|
Exclude:
|
|
3
3
|
- db/schema.rb
|
|
4
|
+
- spec/dummy/db/schema.rb
|
|
4
5
|
|
|
5
6
|
Metrics/LineLength:
|
|
6
7
|
Max: 160
|
|
@@ -11,6 +12,9 @@ Metrics/MethodLength:
|
|
|
11
12
|
Metrics/AbcSize:
|
|
12
13
|
Max: 25
|
|
13
14
|
|
|
15
|
+
Metrics/ClassLength:
|
|
16
|
+
Max: 250
|
|
17
|
+
|
|
14
18
|
Style/AccessModifierIndentation:
|
|
15
19
|
EnforcedStyle: outdent
|
|
16
20
|
|
|
@@ -6,8 +6,8 @@ namespace "best_practice_project" do
|
|
|
6
6
|
task "run_rubocop" do
|
|
7
7
|
best_practice_project = BestPracticeProject.new
|
|
8
8
|
|
|
9
|
-
puts "Executing: #{best_practice_project.
|
|
10
|
-
|
|
9
|
+
puts "Executing: #{best_practice_project.rubocop_handler.command}"
|
|
10
|
+
best_practice_project.rubocop_handler.execute
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
task "run_scss_lint" do
|
metadata
CHANGED
|
@@ -1,71 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: best_practice_project
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- kaspernj
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-11-
|
|
11
|
+
date: 2015-11-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: psych
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- -
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.35.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.35.0
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: coffeelint
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - '='
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: 1.11.0
|
|
34
|
-
type: :runtime
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - '='
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: 1.11.0
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: scss_lint
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - ">="
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0'
|
|
48
|
-
type: :runtime
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - ">="
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: rails_best_practices
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - ">="
|
|
17
|
+
- - "~>"
|
|
60
18
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
19
|
+
version: 2.0.0
|
|
62
20
|
type: :runtime
|
|
63
21
|
prerelease: false
|
|
64
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
23
|
requirements:
|
|
66
|
-
- - "
|
|
24
|
+
- - "~>"
|
|
67
25
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
26
|
+
version: 2.0.0
|
|
69
27
|
- !ruby/object:Gem::Dependency
|
|
70
28
|
name: rspec
|
|
71
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -153,8 +111,9 @@ files:
|
|
|
153
111
|
- Rakefile
|
|
154
112
|
- VERSION
|
|
155
113
|
- best_practice_project.gemspec
|
|
156
|
-
- config/rubocop.yml
|
|
157
114
|
- lib/best_practice_project.rb
|
|
115
|
+
- lib/best_practice_project/rubocop_handler.rb
|
|
116
|
+
- lib/config/rubocop.yml
|
|
158
117
|
- lib/tasks/best_practice_project.rake
|
|
159
118
|
- shippable.yml
|
|
160
119
|
- spec/best_practice_project_spec.rb
|