manageiq-style 1.0.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87713f5170c0b2e2264839443cd86efd7e0a2e0cf7350520c40bf3cad60a569d
4
- data.tar.gz: 954625f619b519fe56af127ad53ba885e2c53b8accf191dcbd6bde88dbaca507
3
+ metadata.gz: 8840f6c593105a9a76b6b2f765e2789a9448d623c5cf67737fa0bb032ba7106f
4
+ data.tar.gz: b593378d58deaf202a70bad993bf9316b671d7eda9519400eeb2ad0f86158591
5
5
  SHA512:
6
- metadata.gz: a4609edf44018bd8c3b0f315fbde1b8a36dceb41b19002f518a77186adaad012c1bdfa115af1c9b4ea9159eb7482700309809d04d13eada0c443e85d67b56b1c
7
- data.tar.gz: 7a6712cd6fe92ec007c80990e96cecac67f39353b435c2e35514cf7c10dc2d6686a956c035d326a0455bb07f486b3bb9296a5e6362f479275df4f6a48378b480
6
+ metadata.gz: f7fbd6bbbc966d1caf340007040012503dcfa83ae4ee4b4394d6ad589953cb4bff8f7639506b5473227897e0ff4ed7018eafa0eaf0f6fbe6bfc131e5eb1909df
7
+ data.tar.gz: 7d13f41a40b884feca8310d68ffc735f037ccf0cda87d9d752ca85f9b02e6cddf204cf8f77fbb2852ebceddeebd6bb6f556eed9a95589063e964f3366e404cce
@@ -0,0 +1,16 @@
1
+ prepare:
2
+ fetch:
3
+ - url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_base.yml
4
+ path: ".rubocop_base.yml"
5
+ - url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_cc_base.yml
6
+ path: ".rubocop_cc_base.yml"
7
+ - url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/styles/base.yml
8
+ path: styles/base.yml
9
+ - url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/styles/cc_base.yml
10
+ path: styles/cc_base.yml
11
+ plugins:
12
+ rubocop:
13
+ enabled: true
14
+ config: ".rubocop_cc.yml"
15
+ channel: rubocop-0-82
16
+ version: '2'
@@ -1,4 +1,4 @@
1
1
  inherit_from:
2
- - .rubocop_base.yml
3
- # put all local rubocop config into .rubocop_local.yml as it will be loaded by .rubocop_cc.yml as well
4
- - .rubocop_local.yml
2
+ - ".rubocop_local.yml"
3
+ inherit_gem:
4
+ manageiq-style: ".rubocop_base.yml"
@@ -1,292 +1,2 @@
1
- require:
2
- - rubocop-rails
3
- - rubocop-performance
4
-
5
- AllCops:
6
- NewCops: disable
7
- Exclude:
8
- - spec/manageiq/**/*
9
- - vendor/**/*
10
- TargetRubyVersion: 2.5
11
- Layout/HashAlignment:
12
- EnforcedHashRocketStyle: table
13
- EnforcedColonStyle: table
14
- Layout/DefEndAlignment:
15
- AutoCorrect: true
16
- Layout/EndAlignment:
17
- AutoCorrect: true
18
- Layout/ExtraSpacing:
19
- AutoCorrect: true
20
- Layout/LineLength:
21
- Enabled: false
22
- Layout/SpaceAroundMethodCallOperator:
23
- Enabled: true
24
- Layout/SpaceBeforeFirstArg:
25
- Enabled: false
26
- Layout/SpaceInsideHashLiteralBraces:
27
- EnforcedStyle: no_space
28
- Lint/RaiseException:
29
- Enabled: true
30
- Lint/StructNewOverride:
31
- Enabled: true
32
- Metrics/AbcSize:
33
- Enabled: false
34
- Metrics/BlockLength:
35
- Enabled: false
36
- Metrics/BlockNesting:
37
- Enabled: false
38
- Metrics/ClassLength:
39
- Enabled: false
40
- Metrics/CyclomaticComplexity:
41
- Enabled: false
42
- Metrics/MethodLength:
43
- Enabled: false
44
- Metrics/ModuleLength:
45
- Enabled: false
46
- Metrics/ParameterLists:
47
- Enabled: false
48
- Metrics/PerceivedComplexity:
49
- Enabled: false
50
- Naming/MethodParameterName:
51
- AllowedNames:
52
- - vm
53
- - dc
54
- Naming/RescuedExceptionsVariableName:
55
- Enabled: false
56
- Performance/Casecmp:
57
- Enabled: false
58
- Rails:
59
- Enabled: true
60
- Rails/FindEach:
61
- Enabled: false
62
- Rails/HttpStatus:
63
- Enabled: true
64
- EnforcedStyle: numeric
65
- Rails/ReadWriteAttribute:
66
- AutoCorrect: false
67
- Style/AccessModifierDeclarations:
68
- Enabled: false
69
- Style/ClassAndModuleChildren:
70
- Enabled: false
71
- Style/ClassCheck:
72
- EnforcedStyle: kind_of?
73
- Style/CollectionMethods:
74
- PreferredMethods:
75
- find: detect
76
- find_all: select
77
- map: collect
78
- reduce: inject
79
- Style/Documentation:
80
- Enabled: false
81
- Style/DoubleNegation:
82
- Enabled: false
83
- Style/EmptyMethod:
84
- Enabled: false
85
- Style/Encoding:
86
- Enabled: false
87
- Style/ExponentialNotation:
88
- Enabled: true
89
- Style/FormatString:
90
- EnforcedStyle: percent
91
- Style/FormatStringToken:
92
- EnforcedStyle: template
93
- Style/FrozenStringLiteralComment:
94
- Enabled: false
95
- Style/GuardClause:
96
- Enabled: false
97
- Style/HashEachMethods:
98
- Enabled: true
99
- Style/HashSyntax:
100
- EnforcedStyle: hash_rockets
101
- Exclude:
102
- - db/schema.rb
103
- Style/HashTransformKeys:
104
- Enabled: true
105
- Style/HashTransformValues:
106
- Enabled: true
107
- Style/IfUnlessModifier:
108
- Enabled: false
109
- Style/MethodCallWithArgsParentheses:
110
- Exclude:
111
- - Gemfile
112
- - config/routes.rb
113
- - lib/generators/**/*
114
- - lib/resource_feeder/**/*
115
- - lib/tasks/**/*
116
- - spec/**/*
117
- Enabled: true
118
- IgnoredMethods:
119
- # Ruby
120
- - add_dependency
121
- - add_development_dependency
122
- - add_runtime_dependency
123
- - alias_method
124
- - attr_accessor
125
- - attr_reader
126
- - attr_writer
127
- - exit
128
- - extend
129
- - gem
130
- - include
131
- - load
132
- - module_function
133
- - pp
134
- - prepend
135
- - print
136
- - private
137
- - private_class_method
138
- - private_constant
139
- - puts
140
- - raise
141
- - require
142
- - sleep
143
- - throw
144
- - warn
145
- - yield
146
- # Rails
147
- - accepts_nested_attributes_for
148
- - add_column
149
- - add_index
150
- - add_reference
151
- - after_action
152
- - after_commit
153
- - after_create
154
- - after_create_commit
155
- - after_destroy
156
- - after_destroy
157
- - after_destroy_commit
158
- - after_initialize
159
- - after_save
160
- - after_save
161
- - after_update
162
- - after_update_commit
163
- - alias_attribute
164
- - around_destroy
165
- - autoload
166
- - before_action
167
- - before_create
168
- - before_destroy
169
- - before_save
170
- - before_update
171
- - before_validation
172
- - belongs_to
173
- - bigint
174
- - boolean
175
- - cattr_accessor
176
- - cattr_reader
177
- - cattr_writer
178
- - change_column
179
- - change_column_comment
180
- - change_column_null
181
- - change_table_comment
182
- - class_attribute
183
- - create_table
184
- - datetime
185
- - decimal
186
- - delegate
187
- - drop_table
188
- - float
189
- - has_and_belongs_to_many
190
- - has_many
191
- - has_one
192
- - head
193
- - identified_by
194
- - index
195
- - integer
196
- - jsonb
197
- - mattr_accessor
198
- - references
199
- - remove_column
200
- - remove_index
201
- - remove_reference
202
- - rename_column
203
- - render
204
- - require_dependency
205
- - require_relative
206
- - respond_to
207
- - scope
208
- - serialize
209
- - skip_before_action
210
- - string
211
- - text
212
- - uuid
213
- - validate
214
- - validates
215
- # ActsAsTree Gem
216
- - acts_as_tree
217
- # Ancestry Gem
218
- - has_ancestry
219
- # DefaultValue Gem
220
- - default_value_for
221
- - default_values
222
- # Optimist Gem
223
- - banner
224
- - die
225
- - opt
226
- # MIQ
227
- - add_trigger
228
- - alias_with_relationship_type
229
- - api_relay_method
230
- - attr_accessor_that_yamls
231
- - deprecate_attribute
232
- - drop_trigger
233
- - encrypt_column
234
- - include_concern
235
- - require_nested
236
- - signal
237
- - supports
238
- - supports_not
239
- - virtual_aggregate
240
- - virtual_attribute
241
- - virtual_belongs_to
242
- - virtual_belongs_to
243
- - virtual_column
244
- - virtual_delegate
245
- - virtual_has_many
246
- - virtual_has_one
247
- - virtual_total
248
- # Rake
249
- - desc
250
- - task
251
- Style/NumericLiterals:
252
- AutoCorrect: false
253
- Style/NumericPredicate:
254
- Enabled: false
255
- Style/PerlBackrefs:
256
- Enabled: false
257
- Style/ParallelAssignment:
258
- Enabled: false
259
- Style/RedundantReturn:
260
- AllowMultipleReturnValues: true
261
- Style/RegexpLiteral:
262
- Enabled: false
263
- Style/RescueModifier:
264
- AutoCorrect: false
265
- Style/RescueStandardError:
266
- EnforcedStyle: implicit
267
- Style/SignalException:
268
- EnforcedStyle: only_raise
269
- Style/SingleLineBlockParams:
270
- Enabled: false
271
- Style/SingleLineMethods:
272
- AllowIfMethodIsEmpty: false
273
- Style/SpecialGlobalVars:
274
- AutoCorrect: false
275
- Style/StringLiterals:
276
- Enabled: false
277
- Style/StringLiteralsInInterpolation:
278
- Enabled: false
279
- Style/SymbolArray:
280
- Enabled: false
281
- Style/TrailingCommaInArrayLiteral:
282
- Enabled: false
283
- Style/TrailingCommaInHashLiteral:
284
- Enabled: false
285
- Style/TrailingUnderscoreVariable:
286
- Enabled: false
287
- Style/TrivialAccessors:
288
- AllowPredicates: true
289
- Style/WhileUntilModifier:
290
- Enabled: false
291
- Style/WordArray:
292
- Enabled: false
1
+ inherit_from:
2
+ - styles/base.yml
@@ -0,0 +1,4 @@
1
+ inherit_from:
2
+ - ".rubocop_base.yml"
3
+ - ".rubocop_cc_base.yml"
4
+ - ".rubocop_local.yml"
@@ -1,47 +1,2 @@
1
- #
2
- # THIS FILE IS AUTOGENERATED. DO NOT MODIFY MANUALLY.
3
- # For changes, please modify scripts/process_rubocop_yamls.rb
4
- #
5
- ---
6
- AllCops:
7
- TargetRubyVersion: 2.4
8
- Bundler:
9
- Enabled: true
10
- Gemspec:
11
- Enabled: true
12
- Layout:
13
- Enabled: false
14
- Lint:
15
- Enabled: true
16
- Naming:
17
- Enabled: false
18
- Performance:
19
- Enabled: true
20
- Rails:
21
- Enabled: false
22
- Security:
23
- Enabled: true
24
- Style:
25
- Enabled: false
26
- Metrics/AbcSize:
27
- Enabled: false
28
- Metrics/BlockLength:
29
- Enabled: false
30
- Metrics/BlockNesting:
31
- Enabled: true
32
- Metrics/ClassLength:
33
- Enabled: false
34
- Metrics/CyclomaticComplexity:
35
- Enabled: true
36
- Max: 11
37
- Metrics/LineLength:
38
- Enabled: false
39
- Metrics/MethodLength:
40
- Enabled: false
41
- Metrics/ModuleLength:
42
- Enabled: false
43
- Metrics/ParameterLists:
44
- Enabled: true
45
- Metrics/PerceivedComplexity:
46
- Enabled: false
47
-
1
+ inherit_from:
2
+ - styles/cc_base.yml
@@ -0,0 +1 @@
1
+
@@ -2,5 +2,6 @@
2
2
  language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
- - 2.5.7
6
- before_install: gem install bundler -v 2.1.4
5
+ - 2.5.8
6
+ - 2.6.6
7
+ before_install: gem install bundler
data/Gemfile CHANGED
@@ -2,6 +2,3 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in manageiq-style.gemspec
4
4
  gemspec
5
-
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Manageiq::Style
1
+ # manageiq-style
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/manageiq/style`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Style and linting configuration for ManageIQ projects.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,7 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ In the root of the repo that needs configuring, run `bundle exec manageiq-style -i` to install or update the rubocop and codeclimate configuration files.
26
24
 
27
25
  ## Development
28
26
 
@@ -32,9 +30,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
30
 
33
31
  ## Contributing
34
32
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/manageiq-style. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/manageiq-style/blob/master/CODE_OF_CONDUCT.md).
36
-
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ManageIQ/manageiq-style. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ManageIQ/.github/blob/master/CODE_OF_CONDUCT.md).
37
34
 
38
35
  ## Code of Conduct
39
36
 
40
- Everyone interacting in the Manageiq::Style project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ManageIQ/.github/blob/master/CODE_OF_CONDUCT.md).
37
+ Everyone interacting in the manageiq-style project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ManageIQ/.github/blob/master/CODE_OF_CONDUCT.md).
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "manageiq/style"
4
+ require "manageiq-style"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH << File.expand_path("../lib", __dir__)
4
+
5
+ require 'bundler/setup'
6
+ require 'manageiq-style'
7
+
8
+ ManageIQ::Style::CLI.run
@@ -0,0 +1 @@
1
+ require "manageiq/style"
@@ -1,6 +1,7 @@
1
1
  require "manageiq/style/version"
2
+ require "manageiq/style/cli"
2
3
 
3
- module Manageiq
4
+ module ManageIQ
4
5
  module Style
5
6
  class Error < StandardError; end
6
7
  # Your code goes here...
@@ -0,0 +1,247 @@
1
+ module ManageIQ
2
+ module Style
3
+ class CLI
4
+ def self.run
5
+ new.run
6
+ end
7
+
8
+ def initialize(options = parse_cli_options)
9
+ @opts = options
10
+ end
11
+
12
+ def parse_cli_options
13
+ require 'optimist'
14
+
15
+ Optimist.options do
16
+ usage "[OPTIONS]"
17
+ synopsis "\nThe ManageIQ community's style configuration utility."
18
+ version "v#{ManageIQ::Style::VERSION}\n"
19
+
20
+ opt :install, "Install or update the style configurations", :default => false, :required => true
21
+ end
22
+ end
23
+
24
+ def run
25
+ install if @opts[:install]
26
+ end
27
+
28
+ def install
29
+ require 'yaml'
30
+ require 'more_core_extensions/all'
31
+
32
+ check_for_codeclimate_channel
33
+ update_rubocop_yml
34
+ write_rubocop_cc_yml
35
+ ensure_rubocop_local_yml_exists
36
+ update_codeclimate_yml
37
+ update_generator
38
+ update_gem_source
39
+ end
40
+
41
+ private
42
+
43
+ def check_for_codeclimate_channel
44
+ begin
45
+ require 'open-uri'
46
+ URI::HTTPS.build(
47
+ :host => "raw.githubusercontent.com",
48
+ :path => File.join("/codeclimate", "codeclimate-rubocop", "channel", cc_rubocop_channel, "Gemfile")
49
+ ).open
50
+ rescue OpenURI::HTTPError
51
+ puts "RuboCop version #{rubocop_version.version} is not supported by CodeClimate."
52
+ exit 1
53
+ end
54
+ end
55
+
56
+ def update_rubocop_yml(file = ".rubocop.yml")
57
+ data = begin
58
+ YAML.load_file(file)
59
+ rescue Errno::ENOENT
60
+ {}
61
+ end
62
+
63
+ data.store_path("inherit_gem", "manageiq-style", ".rubocop_base.yml")
64
+ data["inherit_from"] = [".rubocop_local.yml"]
65
+
66
+ File.write(".rubocop.yml", data.to_yaml.sub("---\n", ""))
67
+ end
68
+
69
+ def write_rubocop_cc_yml(file = ".rubocop_cc.yml")
70
+ data = {
71
+ "inherit_from" => [
72
+ ".rubocop_base.yml",
73
+ ".rubocop_cc_base.yml",
74
+ ".rubocop_local.yml"
75
+ ]
76
+ }
77
+
78
+ File.write(file, data.to_yaml.sub("---\n", ""))
79
+ end
80
+
81
+ def ensure_rubocop_local_yml_exists(file = ".rubocop_local.yml")
82
+ require 'fileutils'
83
+ FileUtils.touch(file)
84
+ end
85
+
86
+ def update_codeclimate_yml(file = ".codeclimate.yml")
87
+ data = begin
88
+ YAML.load_file(file)
89
+ rescue Errno::ENOENT
90
+ {}
91
+ end
92
+
93
+ data["prepare"] = {
94
+ "fetch" => [
95
+ {"url" => "https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_base.yml", "path" => ".rubocop_base.yml"},
96
+ {"url" => "https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_cc_base.yml", "path" => ".rubocop_cc_base.yml"},
97
+ {"url" => "https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/styles/base.yml", "path" => "styles/base.yml"},
98
+ {"url" => "https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/styles/cc_base.yml", "path" => "styles/cc_base.yml"},
99
+ ]
100
+ }
101
+
102
+ data.delete_path("engines", "rubocop")
103
+
104
+ data["plugins"] ||= {}
105
+ data["plugins"]["rubocop"] = {
106
+ "enabled" => true,
107
+ "config" => ".rubocop_cc.yml",
108
+ "channel" => cc_rubocop_channel,
109
+ }
110
+ data["engines"]&.each do |engine, config|
111
+ data["plugins"][engine] = config
112
+ end
113
+
114
+ data.delete("engines") # moved to plugins
115
+ data.delete("ratings") # deprecated
116
+
117
+ exclude_paths = data.delete("exclude_paths") # renamed
118
+ data["exclude_patterns"] = exclude_paths if exclude_paths
119
+
120
+ data["version"] ||= "2"
121
+
122
+ File.write(".codeclimate.yml", data.to_yaml.sub("---\n", ""))
123
+ end
124
+
125
+ def update_gem_source
126
+ if (gemspec = Dir.glob("*.gemspec").first)
127
+ update_gemspec(gemspec)
128
+ elsif File.exist?("Gemfile")
129
+ update_gemfile
130
+ end
131
+ end
132
+
133
+ def update_gemspec(gemspec)
134
+ contents = File.read(gemspec)
135
+ return if contents.include?("manageiq-style")
136
+
137
+ lines = contents.lines
138
+
139
+ obj = $1 if lines.detect { |l| l =~ /^\s+(\w+)\.name\s+=/ }
140
+ raise "couldn't find spec object name" if obj.nil?
141
+
142
+ new_line = "#{obj}.add_development_dependency \"manageiq-style\"\n"
143
+
144
+ dev_lines = lines.select { |l| l.include?("add_development_dependency") }
145
+ if dev_lines.any?
146
+ # Add manageiq-style and remove all direct rubocop references
147
+ dev_lines << new_line
148
+ dev_lines.reject! { |l| l.include?("rubocop") }
149
+
150
+ # Prepare the lines in a nice format
151
+ format_gem_source_lines!(dev_lines)
152
+ dev_lines.sort_by!(&:downcase)
153
+
154
+ # Remove the old dev lines and add the new ones
155
+ insert_at = lines.index { |l| l.include?("add_development_dependency") }
156
+ lines.delete_if { |l| l.include?("add_development_dependency") }
157
+ lines.insert(insert_at, dev_lines)
158
+ else
159
+ insert_at = -1
160
+ insert_at -= 1 until lines[insert_at].strip != "end"
161
+ lines.insert(insert_at, new_line)
162
+ end
163
+
164
+ File.write(gemspec, lines.join)
165
+ end
166
+
167
+ def update_gemfile
168
+ contents = File.read("Gemfile")
169
+ return if contents.include?("manageiq-style")
170
+
171
+ lines = contents.lines
172
+
173
+ new_line = "gem \"manageiq-style\", :require => false\n"
174
+
175
+ group_index = lines.index { |l| l.match?(/group\(?\s*:development/) }
176
+ if group_index
177
+ # Determine the group range
178
+ group_index += 1
179
+ group_end = group_index
180
+ group_end += 1 until lines[group_end].strip == "end"
181
+ group_range = (group_index..group_end - 1)
182
+
183
+ # Split lines into "gem" units including their preceding comments or blank lines
184
+ gem_units = lines[group_range].slice_after { |l| l.match?(/^\s*gem/) }.to_a
185
+
186
+ # Add manageiq-style and remove all direct rubocop references
187
+ gem_units << [new_line]
188
+ gem_units.reject! { |u| u.last.include?("rubocop") }
189
+
190
+ # Prepare the lines in a nice format
191
+ gem_lines = gem_units.map(&:last)
192
+ format_gem_source_lines!(gem_lines)
193
+ gem_units.each_with_index { |u, i| u[-1] = gem_lines[i] }
194
+ gem_units.sort_by! { |u| u.last.downcase }
195
+ gem_units.flatten!
196
+
197
+ # Remove the old group lines and add the new ones
198
+ lines.slice!(group_range)
199
+ lines.insert(group_index, gem_units)
200
+ else
201
+ lines << <<~RUBY
202
+
203
+ group :development do
204
+ #{new_line}
205
+ end
206
+ RUBY
207
+ end
208
+
209
+ File.write("Gemfile", lines.join)
210
+ end
211
+
212
+ def format_gem_source_lines!(lines)
213
+ indent = lines.first.match(/^\s+/).to_s
214
+
215
+ lines.map! { |l| l.strip.gsub(/[()]/, " ").split(" ", 3) } # Split to [prefix, gem, versions]
216
+ lines.each { |parts| parts[1].tr!("'", "\"")} # Ensure double quoted gem name
217
+ max_width = lines.map { |parts| parts[1].size }.max # Determine the widest gem name
218
+ lines.each { |parts| parts[1] = parts[1].ljust(max_width, " ") } # Apply the width
219
+ lines.map! { |parts| parts.join(" ").strip.insert(0, indent) << "\n" } # Back to strings
220
+
221
+ lines
222
+ end
223
+
224
+ def update_generator
225
+ plugin_dir = "lib/generators/manageiq/plugin/templates"
226
+
227
+ return unless File.directory?(plugin_dir)
228
+
229
+ update_rubocop_yml(File.join(plugin_dir, ".rubocop.yml"))
230
+ write_rubocop_cc_yml(File.join(plugin_dir, ".rubocop_cc.yml"))
231
+ ensure_rubocop_local_yml_exists(File.join(plugin_dir, ".rubocop_local.yml"))
232
+ update_codeclimate_yml(File.join(plugin_dir, ".codeclimate.yml"))
233
+ end
234
+
235
+ def cc_rubocop_channel
236
+ @cc_rubocop_channel ||= "rubocop-#{rubocop_version.segments[0]}-#{rubocop_version.segments[1]}"
237
+ end
238
+
239
+ def rubocop_version
240
+ @rubocop_version ||= begin
241
+ require 'rubocop'
242
+ Gem::Version.new(RuboCop::Version.version)
243
+ end
244
+ end
245
+ end
246
+ end
247
+ end
@@ -1,5 +1,5 @@
1
- module Manageiq
1
+ module ManageIQ
2
2
  module Style
3
- VERSION = "1.0.1"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -2,15 +2,14 @@ require_relative 'lib/manageiq/style/version'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "manageiq-style"
5
- spec.version = Manageiq::Style::VERSION
6
- spec.authors = ["Brandon Dunne"]
7
- spec.email = ["brandondunne@hotmail.com"]
5
+ spec.version = ManageIQ::Style::VERSION
6
+ spec.authors = ["ManageIQ Authors"]
8
7
 
9
8
  spec.summary = "Style and linting configuration for ManageIQ projects."
10
- spec.description = "Style and linting configuration for ManageIQ projects."
9
+ spec.description = spec.summary
11
10
  spec.homepage = "https://github.com/ManageIQ/manageiq-style"
12
11
  spec.license = "MIT"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.0.0")
14
13
 
15
14
  spec.metadata["homepage_uri"] = spec.homepage
16
15
  spec.metadata["source_code_uri"] = spec.homepage
@@ -24,7 +23,12 @@ Gem::Specification.new do |spec|
24
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
24
  spec.require_paths = ["lib"]
26
25
 
26
+ spec.add_runtime_dependency "more_core_extensions"
27
+ spec.add_runtime_dependency "optimist"
27
28
  spec.add_runtime_dependency "rubocop", "~> 0.82.0"
28
29
  spec.add_runtime_dependency "rubocop-performance"
29
30
  spec.add_runtime_dependency "rubocop-rails"
31
+
32
+ spec.add_development_dependency "rake", "~> 12.0"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
30
34
  end
@@ -0,0 +1,292 @@
1
+ require:
2
+ - rubocop-rails
3
+ - rubocop-performance
4
+
5
+ AllCops:
6
+ NewCops: disable
7
+ Exclude:
8
+ - spec/manageiq/**/*
9
+ - vendor/**/*
10
+ TargetRubyVersion: 2.5
11
+ Layout/HashAlignment:
12
+ EnforcedHashRocketStyle: table
13
+ EnforcedColonStyle: table
14
+ Layout/DefEndAlignment:
15
+ AutoCorrect: true
16
+ Layout/EndAlignment:
17
+ AutoCorrect: true
18
+ Layout/ExtraSpacing:
19
+ AutoCorrect: true
20
+ Layout/LineLength:
21
+ Enabled: false
22
+ Layout/SpaceAroundMethodCallOperator:
23
+ Enabled: true
24
+ Layout/SpaceBeforeFirstArg:
25
+ Enabled: false
26
+ Layout/SpaceInsideHashLiteralBraces:
27
+ EnforcedStyle: no_space
28
+ Lint/RaiseException:
29
+ Enabled: true
30
+ Lint/StructNewOverride:
31
+ Enabled: true
32
+ Metrics/AbcSize:
33
+ Enabled: false
34
+ Metrics/BlockLength:
35
+ Enabled: false
36
+ Metrics/BlockNesting:
37
+ Enabled: false
38
+ Metrics/ClassLength:
39
+ Enabled: false
40
+ Metrics/CyclomaticComplexity:
41
+ Enabled: false
42
+ Metrics/MethodLength:
43
+ Enabled: false
44
+ Metrics/ModuleLength:
45
+ Enabled: false
46
+ Metrics/ParameterLists:
47
+ Enabled: false
48
+ Metrics/PerceivedComplexity:
49
+ Enabled: false
50
+ Naming/MethodParameterName:
51
+ AllowedNames:
52
+ - vm
53
+ - dc
54
+ Naming/RescuedExceptionsVariableName:
55
+ Enabled: false
56
+ Performance/Casecmp:
57
+ Enabled: false
58
+ Rails:
59
+ Enabled: true
60
+ Rails/FindEach:
61
+ Enabled: false
62
+ Rails/HttpStatus:
63
+ Enabled: true
64
+ EnforcedStyle: numeric
65
+ Rails/ReadWriteAttribute:
66
+ AutoCorrect: false
67
+ Style/AccessModifierDeclarations:
68
+ Enabled: false
69
+ Style/ClassAndModuleChildren:
70
+ Enabled: false
71
+ Style/ClassCheck:
72
+ EnforcedStyle: kind_of?
73
+ Style/CollectionMethods:
74
+ PreferredMethods:
75
+ find: detect
76
+ find_all: select
77
+ map: collect
78
+ reduce: inject
79
+ Style/Documentation:
80
+ Enabled: false
81
+ Style/DoubleNegation:
82
+ Enabled: false
83
+ Style/EmptyMethod:
84
+ Enabled: false
85
+ Style/Encoding:
86
+ Enabled: false
87
+ Style/ExponentialNotation:
88
+ Enabled: true
89
+ Style/FormatString:
90
+ EnforcedStyle: percent
91
+ Style/FormatStringToken:
92
+ EnforcedStyle: template
93
+ Style/FrozenStringLiteralComment:
94
+ Enabled: false
95
+ Style/GuardClause:
96
+ Enabled: false
97
+ Style/HashEachMethods:
98
+ Enabled: true
99
+ Style/HashSyntax:
100
+ EnforcedStyle: hash_rockets
101
+ Exclude:
102
+ - db/schema.rb
103
+ Style/HashTransformKeys:
104
+ Enabled: true
105
+ Style/HashTransformValues:
106
+ Enabled: true
107
+ Style/IfUnlessModifier:
108
+ Enabled: false
109
+ Style/MethodCallWithArgsParentheses:
110
+ Exclude:
111
+ - Gemfile
112
+ - config/routes.rb
113
+ - lib/generators/**/*
114
+ - lib/resource_feeder/**/*
115
+ - lib/tasks/**/*
116
+ - spec/**/*
117
+ Enabled: true
118
+ IgnoredMethods:
119
+ # Ruby
120
+ - add_dependency
121
+ - add_development_dependency
122
+ - add_runtime_dependency
123
+ - alias_method
124
+ - attr_accessor
125
+ - attr_reader
126
+ - attr_writer
127
+ - exit
128
+ - extend
129
+ - gem
130
+ - include
131
+ - load
132
+ - module_function
133
+ - pp
134
+ - prepend
135
+ - print
136
+ - private
137
+ - private_class_method
138
+ - private_constant
139
+ - puts
140
+ - raise
141
+ - require
142
+ - sleep
143
+ - throw
144
+ - warn
145
+ - yield
146
+ # Rails
147
+ - accepts_nested_attributes_for
148
+ - add_column
149
+ - add_index
150
+ - add_reference
151
+ - after_action
152
+ - after_commit
153
+ - after_create
154
+ - after_create_commit
155
+ - after_destroy
156
+ - after_destroy
157
+ - after_destroy_commit
158
+ - after_initialize
159
+ - after_save
160
+ - after_save
161
+ - after_update
162
+ - after_update_commit
163
+ - alias_attribute
164
+ - around_destroy
165
+ - autoload
166
+ - before_action
167
+ - before_create
168
+ - before_destroy
169
+ - before_save
170
+ - before_update
171
+ - before_validation
172
+ - belongs_to
173
+ - bigint
174
+ - boolean
175
+ - cattr_accessor
176
+ - cattr_reader
177
+ - cattr_writer
178
+ - change_column
179
+ - change_column_comment
180
+ - change_column_null
181
+ - change_table_comment
182
+ - class_attribute
183
+ - create_table
184
+ - datetime
185
+ - decimal
186
+ - delegate
187
+ - drop_table
188
+ - float
189
+ - has_and_belongs_to_many
190
+ - has_many
191
+ - has_one
192
+ - head
193
+ - identified_by
194
+ - index
195
+ - integer
196
+ - jsonb
197
+ - mattr_accessor
198
+ - references
199
+ - remove_column
200
+ - remove_index
201
+ - remove_reference
202
+ - rename_column
203
+ - render
204
+ - require_dependency
205
+ - require_relative
206
+ - respond_to
207
+ - scope
208
+ - serialize
209
+ - skip_before_action
210
+ - string
211
+ - text
212
+ - uuid
213
+ - validate
214
+ - validates
215
+ # ActsAsTree Gem
216
+ - acts_as_tree
217
+ # Ancestry Gem
218
+ - has_ancestry
219
+ # DefaultValue Gem
220
+ - default_value_for
221
+ - default_values
222
+ # Optimist Gem
223
+ - banner
224
+ - die
225
+ - opt
226
+ # MIQ
227
+ - add_trigger
228
+ - alias_with_relationship_type
229
+ - api_relay_method
230
+ - attr_accessor_that_yamls
231
+ - deprecate_attribute
232
+ - drop_trigger
233
+ - encrypt_column
234
+ - include_concern
235
+ - require_nested
236
+ - signal
237
+ - supports
238
+ - supports_not
239
+ - virtual_aggregate
240
+ - virtual_attribute
241
+ - virtual_belongs_to
242
+ - virtual_belongs_to
243
+ - virtual_column
244
+ - virtual_delegate
245
+ - virtual_has_many
246
+ - virtual_has_one
247
+ - virtual_total
248
+ # Rake
249
+ - desc
250
+ - task
251
+ Style/NumericLiterals:
252
+ AutoCorrect: false
253
+ Style/NumericPredicate:
254
+ Enabled: false
255
+ Style/PerlBackrefs:
256
+ Enabled: false
257
+ Style/ParallelAssignment:
258
+ Enabled: false
259
+ Style/RedundantReturn:
260
+ AllowMultipleReturnValues: true
261
+ Style/RegexpLiteral:
262
+ Enabled: false
263
+ Style/RescueModifier:
264
+ AutoCorrect: false
265
+ Style/RescueStandardError:
266
+ EnforcedStyle: implicit
267
+ Style/SignalException:
268
+ EnforcedStyle: only_raise
269
+ Style/SingleLineBlockParams:
270
+ Enabled: false
271
+ Style/SingleLineMethods:
272
+ AllowIfMethodIsEmpty: false
273
+ Style/SpecialGlobalVars:
274
+ AutoCorrect: false
275
+ Style/StringLiterals:
276
+ Enabled: false
277
+ Style/StringLiteralsInInterpolation:
278
+ Enabled: false
279
+ Style/SymbolArray:
280
+ Enabled: false
281
+ Style/TrailingCommaInArrayLiteral:
282
+ Enabled: false
283
+ Style/TrailingCommaInHashLiteral:
284
+ Enabled: false
285
+ Style/TrailingUnderscoreVariable:
286
+ Enabled: false
287
+ Style/TrivialAccessors:
288
+ AllowPredicates: true
289
+ Style/WhileUntilModifier:
290
+ Enabled: false
291
+ Style/WordArray:
292
+ Enabled: false
@@ -0,0 +1,47 @@
1
+ #
2
+ # THIS FILE IS AUTOGENERATED. DO NOT MODIFY MANUALLY.
3
+ # For changes, please modify scripts/process_rubocop_yamls.rb
4
+ #
5
+ ---
6
+ AllCops:
7
+ TargetRubyVersion: 2.4
8
+ Bundler:
9
+ Enabled: true
10
+ Gemspec:
11
+ Enabled: true
12
+ Layout:
13
+ Enabled: false
14
+ Lint:
15
+ Enabled: true
16
+ Naming:
17
+ Enabled: false
18
+ Performance:
19
+ Enabled: true
20
+ Rails:
21
+ Enabled: false
22
+ Security:
23
+ Enabled: true
24
+ Style:
25
+ Enabled: false
26
+ Metrics/AbcSize:
27
+ Enabled: false
28
+ Metrics/BlockLength:
29
+ Enabled: false
30
+ Metrics/BlockNesting:
31
+ Enabled: true
32
+ Metrics/ClassLength:
33
+ Enabled: false
34
+ Metrics/CyclomaticComplexity:
35
+ Enabled: true
36
+ Max: 11
37
+ Metrics/LineLength:
38
+ Enabled: false
39
+ Metrics/MethodLength:
40
+ Enabled: false
41
+ Metrics/ModuleLength:
42
+ Enabled: false
43
+ Metrics/ParameterLists:
44
+ Enabled: true
45
+ Metrics/PerceivedComplexity:
46
+ Enabled: false
47
+
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manageiq-style
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Brandon Dunne
7
+ - ManageIQ Authors
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-19 00:00:00.000000000 Z
11
+ date: 2021-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: more_core_extensions
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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: optimist
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: rubocop
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,19 +80,50 @@ dependencies:
52
80
  - - ">="
53
81
  - !ruby/object:Gem::Version
54
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '12.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '12.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
55
111
  description: Style and linting configuration for ManageIQ projects.
56
- email:
57
- - brandondunne@hotmail.com
58
- executables: []
112
+ email:
113
+ executables:
114
+ - manageiq-style
59
115
  extensions: []
60
116
  extra_rdoc_files: []
61
117
  files:
118
+ - ".codeclimate.yml"
62
119
  - ".gitignore"
63
120
  - ".haml-lint.yml"
64
121
  - ".rspec"
65
122
  - ".rubocop.yml"
66
123
  - ".rubocop_base.yml"
124
+ - ".rubocop_cc.yml"
67
125
  - ".rubocop_cc_base.yml"
126
+ - ".rubocop_local.yml"
68
127
  - ".travis.yml"
69
128
  - Gemfile
70
129
  - LICENSE.txt
@@ -72,9 +131,14 @@ files:
72
131
  - Rakefile
73
132
  - bin/console
74
133
  - bin/setup
134
+ - exe/manageiq-style
135
+ - lib/manageiq-style.rb
75
136
  - lib/manageiq/style.rb
137
+ - lib/manageiq/style/cli.rb
76
138
  - lib/manageiq/style/version.rb
77
139
  - manageiq-style.gemspec
140
+ - styles/base.yml
141
+ - styles/cc_base.yml
78
142
  homepage: https://github.com/ManageIQ/manageiq-style
79
143
  licenses:
80
144
  - MIT
@@ -89,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
153
  requirements:
90
154
  - - ">="
91
155
  - !ruby/object:Gem::Version
92
- version: 2.3.0
156
+ version: 2.0.0
93
157
  required_rubygems_version: !ruby/object:Gem::Requirement
94
158
  requirements:
95
159
  - - ">="