rubicure 1.0.4 → 1.0.5

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
  SHA1:
3
- metadata.gz: e8025de1d4aa7b46a7132e3d039e68abb737a7ac
4
- data.tar.gz: ed8c85c5bf7705b08c13f671b1e01e3452ea063c
3
+ metadata.gz: 525259f45ecb0438358c5c50a4ea6f04b7ef8bbd
4
+ data.tar.gz: f9561a76ca57af207a99d8e077602e1095e8e3b7
5
5
  SHA512:
6
- metadata.gz: 014dd72f5f96699ddecbf3d98ed234164e2197db1d8b1be2566eb3cabbbcb3015394803e98c573b28b63979f4e2c771a3c850ee0bd4e61a406c1746f5fa86a12
7
- data.tar.gz: 3ec224988089d0c12e683be41c1edef13193845983f9bb428a6e50242d192513bdc1e7e52b2859267be8e6a92c31bf89dec3d9dabed3b954326934ee0a1a26a2
6
+ metadata.gz: 490b54aa5d429a07a1dc3f0e6bbe74ab3088d28f64b9ae9ba653044e032b0d3681db40bee243980aa6bf771a5bc44d79a7fb4b5ca072f36d1cd52dd08dd62b50
7
+ data.tar.gz: 7ef98cc0ea1820a510664f39a072f89f4ee072805ec89082cbd14526edcc6ca69e960b6449b28ad5761234162d34dbe33a8109261f7ad9cc2f1633a4226da48c
@@ -1,4 +1,14 @@
1
- inherit_from: ".onkcop.yml"
1
+ inherit_gem:
2
+ onkcop:
3
+ - "config/rubocop.yml"
4
+ - "config/rspec.yml"
2
5
 
3
- Metrics/ClassLength:
4
- Max: 120
6
+ AllCops:
7
+ TargetRubyVersion: 2.2
8
+
9
+ RSpec/NestedGroups:
10
+ Enabled: false
11
+
12
+ # TODO: Remove when drop support ruby 2.2
13
+ Layout/IndentHeredoc:
14
+ Enabled: false
@@ -16,6 +16,7 @@ script:
16
16
  - bundle exec rspec
17
17
  - bundle exec codeclimate-test-reporter
18
18
  - bundle exec ruby examples/all.rb
19
+ - bundle exec rubocop
19
20
  branches:
20
21
  only:
21
22
  - master
@@ -1,5 +1,12 @@
1
1
  ## master
2
- [full changelog](http://github.com/sue445/rubicure/compare/v1.0.4...master)
2
+ [full changelog](http://github.com/sue445/rubicure/compare/v1.0.5...master)
3
+
4
+ ## v1.0.5
5
+ [full changelog](http://github.com/sue445/rubicure/compare/v1.0.4...v1.0.5)
6
+
7
+ * Support `did_you_mean`
8
+ * https://github.com/sue445/rubicure/pull/150
9
+ * https://github.com/sue445/rubicure/issues/147
3
10
 
4
11
  ## v1.0.4
5
12
  [full changelog](http://github.com/sue445/rubicure/compare/v1.0.3...v1.0.4)
data/README.md CHANGED
@@ -213,7 +213,7 @@ yayoi.attack!
213
213
 
214
214
  プリキュア!ピースサンダー!!
215
215
 
216
- # 2st transform
216
+ # 2nd transform
217
217
  yayoi.transform!
218
218
  yayoi.name
219
219
  #=> "プリンセスピース"
@@ -258,13 +258,12 @@ Cure.black.dual_aurora_wave!
258
258
  闇の力のしもべ達よ!
259
259
  とっととお家に帰りなさい!
260
260
 
261
- Cure.luminous.luminous_shining_stream!
261
+ Cure.luminous.shining_stream!
262
262
  ルミナス・シャイニングストリーム!
263
263
  輝く命、シャイニールミナス!
264
264
  光の心と光の意志、すべてを一つにするために!
265
265
 
266
- Cure.bloom.dual_spilitual_power!
267
- Cure.bloom.dual_spilitual_power!
266
+ Cure.bloom.dual_spiritual_power!
268
267
  デュアル・スピリチュアル・パワー!
269
268
  花開け大地に!
270
269
  輝く金の花! キュアブルーム!
@@ -12,18 +12,12 @@ require "rubicure/errors"
12
12
 
13
13
  begin
14
14
  require "backport_dig"
15
- rescue LoadError
16
- end
17
-
18
- module Rubicure
19
- def self.core
20
- Rubicure::Core.instance
21
- end
15
+ rescue LoadError # rubocop:disable Lint/HandleExceptions
22
16
  end
23
17
 
24
18
  module Precure
25
- def self.method_missing(name, *args, &block)
26
- Rubicure.core.send(name, *args, &block)
19
+ def self.method_missing(name, *args, &block) # rubocop:disable Style/MethodMissing
20
+ Rubicure::Core.instance.send(name, *args, &block)
27
21
  end
28
22
  end
29
23
 
@@ -7,18 +7,27 @@ module Rubicure
7
7
  include Enumerable
8
8
  include Rubicure::Concerns::Util
9
9
 
10
+ Rubicure::Series.names.each do |series_name|
11
+ define_method series_name do
12
+ Rubicure::Series.find(series_name)
13
+ end
14
+ end
15
+
10
16
  def method_missing(name, *args)
11
17
  unmarked_precure = Rubicure::Series.find(:unmarked)
12
18
 
13
- if Rubicure::Series.valid?(name)
14
- Rubicure::Series.find(name)
15
- elsif unmarked_precure.respond_to?(name)
19
+ if unmarked_precure.respond_to?(name)
16
20
  unmarked_precure.send(name, *args)
17
21
  else
18
22
  super
19
23
  end
20
24
  end
21
25
 
26
+ def respond_to_missing?(name, _include_private)
27
+ unmarked_precure = Rubicure::Series.find(:unmarked)
28
+ unmarked_precure.respond_to?(name)
29
+ end
30
+
22
31
  # @return [Series] current precure
23
32
  # @raise not onair!
24
33
  def now
@@ -1,9 +1,7 @@
1
1
  module Cure
2
- def self.method_missing(name, *args)
3
- if Rubicure::Girl.valid?(name)
4
- Rubicure::Girl.find(name)
5
- else
6
- super
2
+ Rubicure::Girl.names.each do |girl_name|
3
+ define_singleton_method girl_name do
4
+ Rubicure::Girl.find(girl_name)
7
5
  end
8
6
  end
9
7
 
@@ -14,7 +12,7 @@ module Cure
14
12
  (["チョキ"] * 14) +
15
13
  (["パー"] * 15) +
16
14
  ["グッチョッパー"]
17
- MESSAGE = <<EOF
15
+ MESSAGE = <<EOF.freeze
18
16
  ピカピカピカリン
19
17
  ジャンケンポン!
20
18
  (%s)
@@ -34,9 +32,7 @@ EOF
34
32
  humanize!
35
33
  @another_human_name ||= @__another_human_name
36
34
 
37
- # rubocop:disable Style/ParallelAssignment
38
35
  self[:human_name], @another_human_name = @another_human_name, self[:human_name]
39
- # rubocop:enable Style/ParallelAssignment
40
36
 
41
37
  self
42
38
  end
@@ -4,7 +4,7 @@ module Rubicure
4
4
  # Precure girl (ex. Cure Peace, Cure Rosetta, Cure Honey)
5
5
  #
6
6
  # this is record of "config/girls/*.yml"
7
- class Girl < Hash
7
+ class Girl < Hash # rubocop:disable Metrics/ClassLength
8
8
  include Hashie::Extensions::MethodAccess
9
9
 
10
10
  ATTRIBUTES = [
@@ -199,16 +199,20 @@ module Rubicure
199
199
  end
200
200
 
201
201
  def method_missing(method_name, *args)
202
+ return super unless respond_to_missing?(method_name, false)
203
+
204
+ transform!(*args)
205
+ end
206
+
207
+ def respond_to_missing?(method_name, _include_private)
202
208
  # call Hashie::Extensions::MethodAccess#method_missing
203
- return super if has_key?(method_name)
209
+ return false if has_key?(method_name)
204
210
 
205
211
  shortened_name = method_name.to_s.
206
- sub(/\Aprecure_|_precure\z/, "").
207
- sub(/!\z/, "")
208
-
209
- return transform!(*args) if transform_calls.include?(shortened_name)
212
+ sub(/\Aprecure_|_precure\z/, "").
213
+ sub(/!\z/, "")
210
214
 
211
- super
215
+ transform_calls.include?(shortened_name)
212
216
  end
213
217
  end
214
218
  end
@@ -25,24 +25,23 @@ module Rubicure
25
25
  # @param [Time,Date,String] arg Time, Date or date like String (ex. "2013-12-16")
26
26
  def on_air?(arg)
27
27
  date = to_date(arg)
28
- if respond_to?(:started_date)
29
- if respond_to?(:ended_date)
30
- # ended title
31
- return (started_date..ended_date).cover?(date)
32
- else
33
- # on air title
34
- return started_date <= date
35
- end
36
- end
37
28
 
38
- false
29
+ return false unless respond_to?(:started_date)
30
+
31
+ if respond_to?(:ended_date)
32
+ # ended title
33
+ (started_date..ended_date).cover?(date)
34
+ else
35
+ # on air title
36
+ started_date <= date
37
+ end
39
38
  end
40
39
 
41
40
  # @return [Array<Rubicure::Girl>]
42
41
  def girls
43
42
  unless @girls
44
43
  @girls = []
45
- if key?(:girls)
44
+ if has_key?(:girls)
46
45
  fetch(:girls).each do |girl_name|
47
46
  @girls << Rubicure::Girl.find(girl_name.to_sym)
48
47
  end
@@ -1,3 +1,3 @@
1
1
  module Rubicure
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5".freeze
3
3
  end
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path("../lib", __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require "rubicure/version"
@@ -15,9 +16,9 @@ Gem::Specification.new do |spec|
15
16
 
16
17
  spec.required_ruby_version = ">= 2.2.2"
17
18
 
18
- spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
19
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
19
20
 
20
- %w(examples/).each do |exclude_dir|
21
+ %w[examples/].each do |exclude_dir|
21
22
  spec.files.reject! { |filename| filename.start_with?(exclude_dir) }
22
23
  end
23
24
 
@@ -34,12 +35,13 @@ Gem::Specification.new do |spec|
34
35
  spec.add_development_dependency "coveralls"
35
36
  spec.add_development_dependency "delorean"
36
37
  spec.add_development_dependency "pry-byebug"
38
+ spec.add_development_dependency "onkcop", "0.49.1.0"
37
39
  spec.add_development_dependency "rake"
38
40
  spec.add_development_dependency "rspec"
39
41
  spec.add_development_dependency "rspec-collection_matchers"
40
42
  spec.add_development_dependency "rspec-its"
41
43
  spec.add_development_dependency "rspec-parameterized", ">= 0.3.2"
42
- spec.add_development_dependency "rubocop", "0.35.1"
44
+ spec.add_development_dependency "rubocop", "0.49.1"
43
45
  spec.add_development_dependency "simplecov"
44
46
  spec.add_development_dependency "yard"
45
47
  end
@@ -1,4 +1,4 @@
1
- describe "girls_checker" do
1
+ describe "girls_checker" do # rubocop:disable RSpec/DescribeClass
2
2
  config_files = Pathname.glob("#{spec_dir}/../config/girls/*.yml")
3
3
 
4
4
  config_files.each do |config_file|
@@ -14,7 +14,7 @@ describe "girls_checker" do
14
14
  end
15
15
 
16
16
  describe "#attack_messages" do
17
- it "should not all end with(\\n)" do
17
+ it "does not all end with(\\n)" do
18
18
  aggregate_failures do
19
19
  Array(girl["attack_messages"]).each do |attack_message|
20
20
  # NOTE: `expect().not_to all( matcher )` is not supported.
@@ -1,4 +1,4 @@
1
- describe "Cure" do
1
+ describe "Cure" do # rubocop:disable RSpec/DescribeClass
2
2
  describe ".peace" do
3
3
  describe "#pikarin_janken" do
4
4
  subject { girl.pikarin_janken }
@@ -9,11 +9,13 @@ describe "Cure" do
9
9
 
10
10
  context "When peace" do
11
11
  let(:girl) { Cure.peace }
12
+
12
13
  it_behaves_like :do_janken
13
14
  end
14
15
 
15
16
  context "When cure_peace" do
16
17
  let(:girl) { Cure.cure_peace }
18
+
17
19
  it_behaves_like :do_janken
18
20
  end
19
21
  end
@@ -22,7 +22,7 @@ describe Rubicure::Girl do
22
22
  let(:precure_name) { "キュアピース" }
23
23
  let(:cast_name) { "金元寿子" }
24
24
  let(:created_date) { "2012-02-19" }
25
- let(:extra_names) { %w(プリンセスピース ウルトラピース) }
25
+ let(:extra_names) { %w[プリンセスピース ウルトラピース] }
26
26
  let(:color) { "yellow" }
27
27
  let(:transform_message) do
28
28
  <<EOF
@@ -37,7 +37,7 @@ EOF
37
37
  "プリキュアピースサンダーハリケーン!",
38
38
  ]
39
39
  end
40
- let(:transform_calls) { %w(smile_charge) }
40
+ let(:transform_calls) { %w[smile_charge] }
41
41
 
42
42
  describe "#name" do
43
43
  context "when before transform" do
@@ -150,11 +150,13 @@ EOF
150
150
 
151
151
  context "same object" do
152
152
  let(:other_girl) { girl }
153
+
153
154
  it { should be true }
154
155
  end
155
156
 
156
157
  context "copied object" do
157
158
  let(:other_girl) { girl.dup }
159
+
158
160
  it { should be true }
159
161
  end
160
162
 
@@ -168,6 +170,7 @@ EOF
168
170
 
169
171
  context "other precure" do
170
172
  let(:other_girl) { Rubicure::Girl.find(:passion) }
173
+
171
174
  it { should be false }
172
175
  end
173
176
  end
@@ -217,12 +220,14 @@ EOF
217
220
  context "When Cure Lemonade calls metamorphose" do
218
221
  let(:girl) { Cure.lemonade }
219
222
  let(:transform_call) { "metamorphose" }
223
+
220
224
  it { expect { subject }.not_to raise_error }
221
225
  end
222
226
 
223
227
  context "When Milkey Rose calls sky_rose_translate!" do
224
228
  let(:girl) { Milky.rose }
225
229
  let(:transform_call) { "sky_rose_translate!" }
230
+
226
231
  it { expect { subject }.not_to raise_error }
227
232
  end
228
233
 
@@ -263,7 +268,7 @@ EOF
263
268
  subject { Rubicure::Girl.colors }
264
269
 
265
270
  let(:expected) do
266
- %i(
271
+ %i[
267
272
  black
268
273
  blue
269
274
  green
@@ -272,7 +277,7 @@ EOF
272
277
  red
273
278
  white
274
279
  yellow
275
- )
280
+ ]
276
281
  end
277
282
 
278
283
  it { should contain_exactly(*expected) }
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Rubicure do
4
- it "should have a version number" do
4
+ it "has a version number" do
5
5
  expect(Rubicure::VERSION).not_to be_nil
6
6
  end
7
7
 
@@ -41,7 +41,7 @@ describe Rubicure::Series do
41
41
 
42
42
  let(:series) do
43
43
  Rubicure::Series[
44
- girls: %w(cure_happy cure_sunny cure_peace cure_march cure_beauty)
44
+ girls: %w[cure_happy cure_sunny cure_peace cure_march cure_beauty]
45
45
  ]
46
46
  end
47
47
 
@@ -83,6 +83,7 @@ describe Rubicure::Series do
83
83
  context "other series" do
84
84
  let(:other_series) { Rubicure::Series.find(:dokidoki) }
85
85
  let(:other_girl) { Rubicure::Girl.find(:passion) }
86
+
86
87
  it { expect(series === other_series).to be false }
87
88
  it { expect(series === other_girl).to be false }
88
89
  end
@@ -143,13 +144,11 @@ describe Rubicure::Series do
143
144
  let(:series) { Rubicure::Series.find(series_name) }
144
145
  let(:series_name) { :splash_star }
145
146
 
146
- # rubocop:disable Metrics/LineLength
147
147
  let(:json) do
148
148
  <<-JSON
149
149
  {\"series_name\":\"splash_star\",\"title\":\"ふたりはプリキュア Splash☆Star\",\"started_date\":\"2006-02-05\",\"ended_date\":\"2007-01-28\",\"girls\":[\"cure_bloom\",\"cure_egret\"]}
150
150
  JSON
151
151
  end
152
- # rubocop:enable Metrics/LineLength
153
152
 
154
153
  it { should eq json.squish }
155
154
  end
@@ -21,7 +21,7 @@ if ENV["CI"]
21
21
 
22
22
  SimpleCov.formatter = Coveralls::SimpleCov::Formatter
23
23
  SimpleCov.start do
24
- %w(spec).each do |ignore_path|
24
+ %w[spec].each do |ignore_path|
25
25
  add_filter(ignore_path)
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubicure
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - sue445
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-11 00:00:00.000000000 Z
11
+ date: 2017-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: onkcop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 0.49.1.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 0.49.1.0
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rake
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -198,14 +212,14 @@ dependencies:
198
212
  requirements:
199
213
  - - '='
200
214
  - !ruby/object:Gem::Version
201
- version: 0.35.1
215
+ version: 0.49.1
202
216
  type: :development
203
217
  prerelease: false
204
218
  version_requirements: !ruby/object:Gem::Requirement
205
219
  requirements:
206
220
  - - '='
207
221
  - !ruby/object:Gem::Version
208
- version: 0.35.1
222
+ version: 0.49.1
209
223
  - !ruby/object:Gem::Dependency
210
224
  name: simplecov
211
225
  requirement: !ruby/object:Gem::Requirement
@@ -243,8 +257,6 @@ extra_rdoc_files: []
243
257
  files:
244
258
  - ".coveralls.yml"
245
259
  - ".gitignore"
246
- - ".hound.yml"
247
- - ".onkcop.yml"
248
260
  - ".rspec"
249
261
  - ".rubocop.yml"
250
262
  - ".tachikoma.yml"
@@ -284,12 +296,12 @@ files:
284
296
  - lib/ubicure.rb
285
297
  - rubicure.gemspec
286
298
  - spec/config/girls_checker_spec.rb
287
- - spec/core_spec.rb
288
- - spec/cure_spec.rb
289
- - spec/girl_spec.rb
290
- - spec/movie_spec.rb
291
- - spec/rubicure_spec.rb
292
- - spec/series_spec.rb
299
+ - spec/rubicure/core_spec.rb
300
+ - spec/rubicure/cure_spec.rb
301
+ - spec/rubicure/girl_spec.rb
302
+ - spec/rubicure/movie_spec.rb
303
+ - spec/rubicure/rubicure_spec.rb
304
+ - spec/rubicure/series_spec.rb
293
305
  - spec/spec_helper.rb
294
306
  - spec/support/util/test_util.rb
295
307
  homepage: https://github.com/sue445/rubicure
@@ -318,11 +330,11 @@ specification_version: 4
318
330
  summary: All about Japanese battle heroine "Pretty Cure (Precure)".
319
331
  test_files:
320
332
  - spec/config/girls_checker_spec.rb
321
- - spec/core_spec.rb
322
- - spec/cure_spec.rb
323
- - spec/girl_spec.rb
324
- - spec/movie_spec.rb
325
- - spec/rubicure_spec.rb
326
- - spec/series_spec.rb
333
+ - spec/rubicure/core_spec.rb
334
+ - spec/rubicure/cure_spec.rb
335
+ - spec/rubicure/girl_spec.rb
336
+ - spec/rubicure/movie_spec.rb
337
+ - spec/rubicure/rubicure_spec.rb
338
+ - spec/rubicure/series_spec.rb
327
339
  - spec/spec_helper.rb
328
340
  - spec/support/util/test_util.rb
data/.hound.yml DELETED
@@ -1,3 +0,0 @@
1
- ruby:
2
- enabled: true
3
- config_file: .rubocop.yml
@@ -1,214 +0,0 @@
1
- # target_version:
2
- # rubocop v0.35.1
3
-
4
- # 自動生成されるものはチェック対象から除外する
5
- AllCops:
6
- Exclude:
7
- - "vendor/**/*" # rubocop config/default.yml
8
- - "db/schema.rb"
9
- DisplayCopNames: true
10
-
11
- ##################### Style ##################################
12
-
13
- # redirect_to xxx and return のイディオムを維持したい
14
- Style/AndOr:
15
- EnforcedStyle: conditionals
16
-
17
- # 日本語のコメントを許可する
18
- Style/AsciiComments:
19
- Enabled: false
20
-
21
- # do .. end から更にメソッドチェーンすると見づらいので
22
- # auto-correct せず、自分で修正する
23
- # spec 内は見た目が綺麗になるので許可
24
- Style/BlockDelimiters:
25
- AutoCorrect: false
26
- Exclude:
27
- - "spec/**/*"
28
-
29
- # option 等、明示的にハッシュにした方が分かりやすい場合もある
30
- Style/BracesAroundHashParameters:
31
- Enabled: false
32
-
33
- # Style/CollectionMethods 自体は無効になっているのだが、
34
- # https://github.com/bbatsov/rubocop/issues/1084
35
- # https://github.com/bbatsov/rubocop/issues/1334
36
- # Performance/Detect がこの設定値を見るので PreferredMethods だけ変更しておく。
37
- #
38
- # デフォルト値から変えたのは
39
- # find -> detect
40
- # ActiveRecord の find と間違えやすいため
41
- # reduce -> inject
42
- # detect, reject, select と並べたときに韻を踏んでいるため。
43
- # collect -> map を維持しているのは文字数が圧倒的に少ないため。
44
- Style/CollectionMethods:
45
- PreferredMethods:
46
- detect: "detect"
47
- find: "detect"
48
- inject: "inject"
49
- reduce: "inject"
50
-
51
- # Hash#has_key? は許可したい
52
- Style/DeprecatedHashMethods:
53
- Enabled: false
54
-
55
- # ドキュメントの無い public class を許可する
56
- Style/Documentation:
57
- Enabled: false
58
-
59
- # !! のイディオムは積極的に使う
60
- Style/DoubleNegation:
61
- Enabled: false
62
-
63
- # メソッドチェーンの改行は末尾に . を入れる
64
- # REPL に貼り付けた際の暴発を防ぐため
65
- Style/DotPosition:
66
- EnforcedStyle: trailing
67
-
68
- # 明示的に else で nil を返すのは分かりやすいので許可する
69
- Style/EmptyElse:
70
- EnforcedStyle: empty
71
-
72
- # 桁揃えが綺麗にならないことが多いので migration は除外
73
- Style/ExtraSpacing:
74
- Exclude:
75
- - "db/migrate/*.rb"
76
-
77
- # いずれかに揃えるのならば `sprintf` や `format` より String#% が好きです
78
- Style/FormatString:
79
- EnforcedStyle: percent
80
-
81
- # if 文の中に 3 行程度のブロックを書くぐらいは許容した方が現実的
82
- Style/GuardClause:
83
- MinBodyLength: 5
84
-
85
- # rake タスクの順序の hash は rocket を許可する
86
- Style/HashSyntax:
87
- Exclude:
88
- - "**/*.rake"
89
- - "Rakefile"
90
-
91
- # 条件式の方を意識させたい場合には後置の if/unless を使わない方が分かりやすい
92
- Style/IfUnlessModifier:
93
- Enabled: false
94
-
95
- # ({ と hash を開始した場合に ( の位置にインデントさせる
96
- # そもそも {} が必要ない可能性が高いが Style/BracesAroundHashParameters はチェックしないことにしたので
97
- Style/IndentHash:
98
- EnforcedStyle: consistent
99
-
100
- # private/protected は一段深くインデントする
101
- Style/IndentationConsistency:
102
- EnforcedStyle: rails
103
-
104
- # scope 等は複数行でも lambda ではなく ->{} で揃えた方が見た目が綺麗
105
- Style/Lambda:
106
- Enabled: false
107
-
108
- # 1_000_000 と区切り文字が 2 個以上必要になる場合のみ _ 区切りを必須にする
109
- Style/NumericLiterals:
110
- MinDigits: 7
111
-
112
- # 正規表現にマッチさせた時の特殊変数の置き換えは Regex.last_match ではなく
113
- # 名前付きキャプチャを使って参照したいので auto-correct しない
114
- Style/PerlBackrefs:
115
- AutoCorrect: false
116
-
117
- # has_ から始まるメソッドは許可する
118
- Style/PredicateName:
119
- NamePrefixBlacklist:
120
- - "is_"
121
- - "have_"
122
- NamePrefix:
123
- - "is_"
124
- - "have_"
125
-
126
- # 特に model 内において、ローカル変数とメソッド呼び出しの区別をつけた方が分かりやすい場合が多い
127
- Style/RedundantSelf:
128
- Enabled: false
129
-
130
- # 受け取り側で multiple assignment しろというのを明示
131
- Style/RedundantReturn:
132
- AllowMultipleReturnValues: true
133
-
134
- # spec 内は見た目が綺麗になるので許可
135
- Style/Semicolon:
136
- Exclude:
137
- - "spec/**/*"
138
-
139
- # fail と使い分ける必要ナシ
140
- Style/SignalException:
141
- EnforcedStyle: only_raise
142
-
143
- # `||` も align に使うことがあるので追加する
144
- Style/SpaceAroundOperators:
145
- MultiSpaceAllowedForOperators:
146
- - "="
147
- - "=>"
148
- - "||"
149
-
150
- # * 式展開したい場合に書き換えるのが面倒
151
- # * 文章ではダブルクォートよりもシングルクォートの方が頻出する
152
- # ことから EnforcedStyle: double_quotes 推奨
153
- Style/StringLiterals:
154
- EnforcedStyle: double_quotes
155
-
156
- # auto-correct 時に Style/StringLiterals とカニバって無限ループになる (v0.28.0)
157
- Style/StringLiteralsInInterpolation:
158
- Enabled: false
159
-
160
- # いくらなんでも inject { |a, e| } は短すぎるので分かりやすい名前をつけたい
161
- Style/SingleLineBlockParams:
162
- Enabled: false
163
-
164
- # * migrate
165
- # * jbuilder
166
- # * model の association
167
- # * controller の callback
168
- # 辺りの桁揃えで引っかかるので全体的にチェックしない
169
- Style/SingleSpaceBeforeFirstArg:
170
- Enabled: false
171
-
172
- # 複数行の場合はケツカンマを入れる
173
- Style/TrailingComma:
174
- EnforcedStyleForMultiline: comma
175
-
176
- ##################### Lint ##################################
177
-
178
- # * 同名のメソッドがある場合にローカル変数に `_` を付ける
179
- # * 一時変数として `_` を付ける
180
- # というテクニックは頻出する
181
- Lint/UnderscorePrefixedVariableName:
182
- Enabled: false
183
-
184
- # 子クラスで実装させるつもりのメソッドで引っかかるので
185
- Lint/UnusedMethodArgument:
186
- Enabled: false
187
-
188
- ##################### Metrics ##################################
189
-
190
- # 30 まではギリギリ許せる範囲だった
191
- Metrics/AbcSize:
192
- Max: 30
193
-
194
- # 6 は強すぎるので緩める
195
- Metrics/CyclomaticComplexity:
196
- Max: 10
197
-
198
- # * 警告 120文字
199
- # * 禁止 160文字
200
- # のイメージ
201
- Metrics/LineLength:
202
- Max: 160
203
- Exclude:
204
- - "db/migrate/*.rb"
205
-
206
- # 20 行超えるのは migration ファイル以外滅多に無い
207
- Metrics/MethodLength:
208
- Max: 20
209
- Exclude:
210
- - "db/migrate/*.rb"
211
-
212
- # 分岐の数。ガード句を多用しているとデフォルト 7 だと厳しい
213
- Metrics/PerceivedComplexity:
214
- Max: 8