fincop 0.51.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a200d31d7ab6efa63be995fb22a61fe61ee49e46
4
+ data.tar.gz: 388406f8ad3be2f93f874edef956eeb1b5d96c58
5
+ SHA512:
6
+ metadata.gz: 7d530c53c56dc3ab1724d3fc367d3c1b78046d877da7e225fb4f18b85c02a45176e5ade560f2f1d046c3c56c47a0c1c8beeec12c5a56f5b435af6498cc1d0fd9
7
+ data.tar.gz: 5dc2d387318df7fc36c66160f7b9d6d4dd5c5f614cb90d2c81904b8b11eed613e7e5f81a126e0e08c030214cb638bd3c39d88b618b33fcc3364cd9913185a2cc
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,2 @@
1
+ inherit_from:
2
+ - 'config/rubocop.yml'
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.13.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fincop.gemspec
4
+ gemspec
@@ -0,0 +1,43 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017-present, FiNC, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ The MIT License (MIT)
24
+
25
+ Copyright (c) 2015 Takafumi ONAKA
26
+
27
+ Permission is hereby granted, free of charge, to any person obtaining a copy
28
+ of this software and associated documentation files (the "Software"), to deal
29
+ in the Software without restriction, including without limitation the rights
30
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
31
+ copies of the Software, and to permit persons to whom the Software is
32
+ furnished to do so, subject to the following conditions:
33
+
34
+ The above copyright notice and this permission notice shall be included in
35
+ all copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
42
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
43
+ THE SOFTWARE.
@@ -0,0 +1,77 @@
1
+ # FinCop
2
+ FinCop is a rubocop configration gem inspired by [onkcop](https://github.com/onk/onkcop)
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'fincop'
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ Setup .rubocop.yml
15
+
16
+ ```sh
17
+ bundle exec fincop init
18
+ ```
19
+
20
+ `init` generate the following directive to your `.rubocop.yml`:
21
+
22
+ ```yaml
23
+ inherit_gem:
24
+ fincop:
25
+ - 'config/rails.yml'
26
+ - 'config/rspec.yml'
27
+ - 'config/rubocop.yml'
28
+ # If you are using Rails 4, activate this cop.
29
+ # - 'config/disabled_for_rails_4.yml'
30
+
31
+ AllCops:
32
+ TargetRubyVersion: 2.4
33
+
34
+ DisplayStyleGuide: true
35
+ ```
36
+
37
+ If you use Rails 4, uncomment and activate `'config/disabled_for_rails_4.yml'`.
38
+
39
+ ```sh
40
+ bundle exec rubocop <options...>
41
+ ```
42
+
43
+ You still can override some rules yourself. First, add setting file (for example, `config/rubocop/.enabled.yml`) and write rules.
44
+
45
+ ```yaml
46
+ Rails/Delegate:
47
+ EnforceForPrefixed: false
48
+ ```
49
+
50
+ Then, add `inherit_from` to your .rubocop.yml like below.
51
+
52
+ ```yaml
53
+ inherit_gem:
54
+ fincop:
55
+ - 'config/rails.yml'
56
+ - 'config/rspec.yml'
57
+ - 'config/rubocop.yml'
58
+
59
+ inherit_from:
60
+ - 'config/rubocop/.enabled.yml'
61
+ ```
62
+
63
+ ## Development
64
+
65
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
66
+
67
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
68
+
69
+ ## Contributing
70
+
71
+ Bug reports and pull requests are welcome on GitHub at https://github.com/FiNCDeveloper/fincop.
72
+
73
+
74
+ ## License
75
+
76
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
77
+
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'fincop'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ # these cops support only rails 5.
2
+
3
+ Rails/HttpPositionalArguments:
4
+ Enabled: false
5
+
6
+ Rails/ApplicationRecord:
7
+ Enabled: false
@@ -0,0 +1,28 @@
1
+ # Based on onk/onkcop
2
+ # https://github.com/onk/onkcop
3
+
4
+ Rails:
5
+ Enabled: true
6
+
7
+ # slug とか created_by とか、NOT NULL だが create_table 時に
8
+ # default 値を定義できないカラムは存在する。
9
+ Rails/NotNullColumn:
10
+ Enabled: false
11
+
12
+ # method_missing を隠したい場合は respond_to? を使うべき
13
+ Rails/SafeNavigation:
14
+ ConvertTry: true
15
+
16
+ # valid? チェックし忘れを防ぎたい
17
+ Rails/SaveBang:
18
+ Enabled: true
19
+
20
+ Rails/TimeZone:
21
+ Enabled: false
22
+
23
+ Rails/UnknownEnv:
24
+ Environments:
25
+ - development
26
+ - test
27
+ - production
28
+ - staging
@@ -0,0 +1,40 @@
1
+ # Based on onk/onkcop
2
+ # https://github.com/onk/onkcop
3
+
4
+ require: "rubocop-rspec"
5
+
6
+ # subject はコピペ可搬性よりもそのまま USAGE であって欲しい
7
+ RSpec/DescribedClass:
8
+ EnforcedStyle: explicit
9
+
10
+ # it が一つしか無いような context では空行を開ける方が読みづらい
11
+ # context "when foo is bar" do
12
+ # let(:foo) { bar }
13
+ # it { is_expected.to do_something }
14
+ # end
15
+ RSpec/EmptyLineAfterFinalLet:
16
+ Enabled: false
17
+
18
+ RSpec/ExampleLength:
19
+ Max: 100
20
+
21
+ # one-liner の should は書きやすいし意味が通りやすいし副作用も無いので撥ねる必要がない。
22
+ # ただ expect 派に対して強制するほどでもないので統一はしない。
23
+ RSpec/ImplicitExpect:
24
+ Enabled: false
25
+
26
+ # let を使うのは context 間で条件が違うものが存在する時だけにしたい。
27
+ # before の方が事前条件を整えていることが分かりやすい。
28
+ RSpec/InstanceVariable:
29
+ Enabled: false
30
+
31
+ RSpec/MultipleExpectations:
32
+ Enabled: false
33
+
34
+ # 変に名前つけて呼ぶ方が分かりづらい。
35
+ # テスト対象メソッドを呼ぶだけの subject 以外を書かないようにする方が効く。
36
+ RSpec/NamedSubject:
37
+ Enabled: false
38
+
39
+ RSpec/NestedGroups:
40
+ Enabled: false
@@ -0,0 +1,357 @@
1
+ # Based on onk/onkcop
2
+ # https://github.com/onk/onkcop
3
+
4
+ # 自動生成されるものはチェック対象から除外する
5
+ AllCops:
6
+ Exclude:
7
+ - "vendor/**/*" # rubocop config/default.yml
8
+ - "db/schema.rb"
9
+ - "node_modules/**/*"
10
+ DisplayCopNames: true
11
+
12
+ #################### Layout ################################
13
+
14
+ # メソッドチェーンの改行は末尾に . を入れる
15
+ # REPL に貼り付けた際の暴発を防ぐため
16
+ Layout/DotPosition:
17
+ EnforcedStyle: trailing
18
+
19
+ # 桁揃えが綺麗にならないことが多いので migration は除外
20
+ Layout/ExtraSpacing:
21
+ Exclude:
22
+ - "db/migrate/*.rb"
23
+
24
+ # special_inside_parentheses (default) と比べて
25
+ # * 横に長くなりづらい
26
+ # * メソッド名の長さが変わったときに diff が少ない
27
+ Layout/IndentArray:
28
+ EnforcedStyle: consistent
29
+
30
+ # ({ と hash を開始した場合に ( の位置にインデントさせる
31
+ # そもそも {} が必要ない可能性が高いが Style/BracesAroundHashParameters はチェックしないことにしたので
32
+ Layout/IndentHash:
33
+ EnforcedStyle: consistent
34
+
35
+ # private/protected は一段深くインデントする
36
+ Layout/IndentationConsistency:
37
+ EnforcedStyle: rails
38
+
39
+ # メソッドチェーン感がより感じられるインデントにする
40
+ Layout/MultilineMethodCallIndentation:
41
+ EnforcedStyle: indented_relative_to_receiver
42
+
43
+
44
+ #################### Style #################################
45
+
46
+ # レキシカルスコープの扱いが alias_method の方が自然。
47
+ # https://ernie.io/2014/10/23/in-defense-of-alias/ のように
48
+ # 問題になる場合は自分で緩める。
49
+ Style/Alias:
50
+ EnforcedStyle: prefer_alias_method
51
+
52
+ # redirect_to xxx and return のイディオムを維持したい
53
+ Style/AndOr:
54
+ EnforcedStyle: conditionals
55
+
56
+ # 日本語のコメントを許可する
57
+ Style/AsciiComments:
58
+ Enabled: false
59
+
60
+ # do .. end から更にメソッドチェーンすると見づらいので
61
+ # auto-correct せず、自分で修正する
62
+ # spec 内は見た目が綺麗になるので許可
63
+ Style/BlockDelimiters:
64
+ AutoCorrect: false
65
+ Exclude:
66
+ - "spec/**/*"
67
+
68
+ # option 等、明示的にハッシュにした方が分かりやすい場合もある
69
+ Style/BracesAroundHashParameters:
70
+ Enabled: false
71
+
72
+ # scope が違うとか親 module の存在確認が必要とかデメリットはあるが、
73
+ # namespace 付きのクラスはかなり頻繁に作るので簡単に書きたい。
74
+ Style/ClassAndModuleChildren:
75
+ Enabled: false
76
+
77
+ # Style/CollectionMethods 自体は無効になっているのだが、
78
+ # https://github.com/bbatsov/rubocop/issues/1084
79
+ # https://github.com/bbatsov/rubocop/issues/1334
80
+ # Performance/Detect がこの設定値を見るので PreferredMethods だけ変更しておく。
81
+ #
82
+ # デフォルト値から変えたのは
83
+ # find -> detect
84
+ # ActiveRecord の find と間違えやすいため
85
+ # reduce -> inject
86
+ # detect, reject, select と並べたときに韻を踏んでいるため。
87
+ # collect -> map を維持しているのは文字数が圧倒的に少ないため。
88
+ Style/CollectionMethods:
89
+ PreferredMethods:
90
+ detect: "detect"
91
+ find: "detect"
92
+ inject: "inject"
93
+ reduce: "inject"
94
+
95
+ # ドキュメントの無い public class を許可する
96
+ Style/Documentation:
97
+ Enabled: false
98
+
99
+ # !! のイディオムは積極的に使う
100
+ Style/DoubleNegation:
101
+ Enabled: false
102
+
103
+ # case
104
+ # when ios?
105
+ # when android?
106
+ # end
107
+ # のようなものは case の方が網羅の表現力が高い
108
+ Style/EmptyCaseCondition:
109
+ Enabled: false
110
+
111
+ # 明示的に else で nil を返すのは分かりやすいので許可する
112
+ Style/EmptyElse:
113
+ EnforcedStyle: empty
114
+
115
+ # 空メソッドの場合だけ1行で書かなければいけない理由が無い
116
+ # 「セミコロンは使わない」に寄せた方がルールがシンプル
117
+ Style/EmptyMethod:
118
+ EnforcedStyle: expanded
119
+
120
+ # いずれかに揃えるのならば `sprintf` や `format` より String#% が好きです
121
+ Style/FormatString:
122
+ EnforcedStyle: percent
123
+
124
+ # まだ対応するには早い
125
+ Style/FrozenStringLiteralComment:
126
+ Enabled: false
127
+
128
+ # if 文の中に 3 行程度のブロックを書くぐらいは許容した方が現実的
129
+ # NOTE: https://github.com/bbatsov/rubocop/commit/29945958034db13af9e8ff385ec58cb9eb464596
130
+ # の影響で、if 文の中身が 1 行の場合に警告されるようになっている。
131
+ # Style/IfUnlessModifier の設定見てくれないかなぁ? (v0.36.0)
132
+ Style/GuardClause:
133
+ MinBodyLength: 5
134
+
135
+ # rake タスクの順序の hash は rocket を許可する
136
+ Style/HashSyntax:
137
+ Exclude:
138
+ - "**/*.rake"
139
+ - "Rakefile"
140
+
141
+ # 平たくしてしまうと条件のグルーピングが脳内モデルとズレやすい
142
+ Style/IfInsideElse:
143
+ Enabled: false
144
+
145
+ # 条件式の方を意識させたい場合には後置の if/unless を使わない方が分かりやすい
146
+ Style/IfUnlessModifier:
147
+ Enabled: false
148
+
149
+ # scope 等は複数行でも lambda ではなく ->{} で揃えた方が見た目が綺麗
150
+ Style/Lambda:
151
+ EnforcedStyle: literal
152
+
153
+ # end.some_method とチェインするのはダサい
154
+ # Style/BlockDelimiters と相性が悪いけど、頑張ってコードを修正してください
155
+ Style/MethodCalledOnDoEndBlock:
156
+ Enabled: true
157
+
158
+ Layout/MultilineMethodCallBraceLayout:
159
+ EnforcedStyle: symmetrical
160
+
161
+ # 1_000_000 と区切り文字が 2 個以上必要になる場合のみ _ 区切りを必須にする
162
+ # 10_000_00 は許可しない。(これは例えば 10000 ドルをセント単位にする時に便利だが
163
+ # 頻出しないので foolproof に振る
164
+ Style/NumericLiterals:
165
+ MinDigits: 7
166
+ Strict: true
167
+
168
+ # foo.positive? は foo > 0 に比べて意味が曖昧になる
169
+ # foo.zero? は許可したいけどメソッドごとに指定できないので一括で disable に
170
+ Style/NumericPredicate:
171
+ Enabled: false
172
+
173
+ # 正規表現にマッチさせた時の特殊変数の置き換えは Regex.last_match ではなく
174
+ # 名前付きキャプチャを使って参照したいので auto-correct しない
175
+ Style/PerlBackrefs:
176
+ AutoCorrect: false
177
+
178
+ # has_ から始まるメソッドは許可する
179
+ Naming/PredicateName:
180
+ NamePrefixBlacklist:
181
+ - "is_"
182
+ - "have_"
183
+ NamePrefix:
184
+ - "is_"
185
+ - "have_"
186
+
187
+ # Hash#has_key? の方が key? よりも意味が通る
188
+ Style/PreferredHashMethods:
189
+ EnforcedStyle: verbose
190
+
191
+ # 受け取り側で multiple assignment しろというのを明示
192
+ Style/RedundantReturn:
193
+ AllowMultipleReturnValues: true
194
+
195
+ # 特に model 内において、ローカル変数とメソッド呼び出しの区別をつけた方が分かりやすい場合が多い
196
+ Style/RedundantSelf:
197
+ Enabled: false
198
+
199
+ # 無理して使うモンじゃない
200
+ Style/SafeNavigation:
201
+ Enabled: false
202
+
203
+ # spec 内は見た目が綺麗になるので許可
204
+ Style/Semicolon:
205
+ Exclude:
206
+ - "spec/**/*"
207
+
208
+ Style/StringLiterals:
209
+ EnforcedStyle: single_quotes
210
+
211
+ # 式展開中でもダブルクォートを使う
212
+ # 普段の文字列リテラルがダブルクォートなので使い分けるのが面倒
213
+ Style/StringLiteralsInInterpolation:
214
+ EnforcedStyle: double_quotes
215
+
216
+ # String#intern は ruby の内部表現すぎるので String#to_sym を使う
217
+ Style/StringMethods:
218
+ Enabled: true
219
+
220
+ # %w() と %i() が見分けづらいので Style/WordArray と合わせて無効に。
221
+ # 書き手に委ねるという意味で、Enabled: false にしています。使っても良い。
222
+ Style/SymbolArray:
223
+ Enabled: false
224
+
225
+ # 三項演算子は分かりやすく使いたい。
226
+ # () を外さない方が条件式が何なのか読み取りやすいと感じる。
227
+ Style/TernaryParentheses:
228
+ EnforcedStyle: require_parentheses_when_complex
229
+
230
+ # 複数行の場合はケツカンマを入れる(引数)
231
+ # Ruby は関数の引数もカンマを許容しているので
232
+ # * 単行は常にケツカンマ無し
233
+ # * 複数行は常にケツカンマ有り
234
+ # に統一したい。
235
+ # 見た目がアレだが、ES2017 でも関数引数のケツカンマが許容されるので
236
+ # 世界はそちらに向かっている。
237
+ Style/TrailingCommaInArguments:
238
+ EnforcedStyleForMultiline: comma
239
+
240
+ Style/TrailingCommaInLiteral:
241
+ Enabled: false
242
+
243
+ Naming/VariableNumber:
244
+ EnforcedStyle: normalcase
245
+
246
+ # 0 <= foo && foo < 5 のように数直線上に並べるのは
247
+ # コードを読みやすくするテクニック。
248
+ # また、self == other, __FILE__ == $0 はイディオムなので許可。
249
+ Style/YodaCondition:
250
+ Enabled: false
251
+
252
+ # %w() と %i() が見分けづらいので Style/SymbolArray と合わせて無効に。
253
+ # 書き手に委ねるという意味で、Enabled: false にしています。使っても良い。
254
+ Style/WordArray:
255
+ Enabled: false
256
+
257
+ # 条件式で arr.size > 0 が使われた時に
258
+ # if !arr.empty?
259
+ # else
260
+ # end
261
+ # に修正されるのが嫌。
262
+ # 中身を入れ替えて否定外しても良いんだけど、どちらが例外的な処理なのかが分かりづらくなる。
263
+ Style/ZeroLengthPredicate:
264
+ Enabled: false
265
+
266
+ #################### Lint ##################################
267
+
268
+ # spec 内では
269
+ # expect { subject }.to change { foo }
270
+ # という書き方をよく行うので () を省略したい。
271
+ # { foo } は明らかに change に紐付く。
272
+ Lint/AmbiguousBlockAssociation:
273
+ Exclude:
274
+ - "spec/**/*"
275
+
276
+ # Style/EmptyCaseCondition と同じく網羅の表現力が empty when を認めた方が高いし、
277
+ # 頻出する対象を最初の when で撥ねるのはパフォーマンス向上で頻出する。
278
+ # また、
279
+ # case foo
280
+ # when 42
281
+ # # nop
282
+ # when 1..100
283
+ # ...
284
+ # end
285
+ # と、下の when がキャッチしてしまう場合等に対応していない。
286
+ # See. http://tech.sideci.com/entry/2016/11/01/105900
287
+ Lint/EmptyWhen:
288
+ Enabled: false
289
+
290
+ # RuntimeError は「特定の Error を定義できない場合」なので、
291
+ # 定義できるエラーは RuntimeError ではなく StandardError を継承する。
292
+ Lint/InheritException:
293
+ EnforcedStyle: standard_error
294
+
295
+ # * 同名のメソッドがある場合にローカル変数に `_` を付ける
296
+ # * 一時変数として `_` を付ける
297
+ # というテクニックは頻出する
298
+ Lint/UnderscorePrefixedVariableName:
299
+ Enabled: false
300
+
301
+ # 子クラスで実装させるつもりのメソッドで引っかかるので
302
+ Lint/UnusedMethodArgument:
303
+ Enabled: false
304
+
305
+ #################### Metrics ###############################
306
+
307
+ # 30 まではギリギリ許せる範囲だったけど
308
+ # リリースごとに 3 ずつぐらい下げていきます。20 まで下げたい。
309
+ Metrics/AbcSize:
310
+ Max: 24
311
+
312
+ # Gemfile, Guardfile は DSL 的で基本的に複雑にはならないので除外
313
+ # rake, rspec, routes は巨大な block 不可避なので除外
314
+ # TODO: ExcludedMethods の精査
315
+ Metrics/BlockLength:
316
+ Exclude:
317
+ - "Rakefile"
318
+ - "**/*.rake"
319
+ - "spec/**/*.rb"
320
+ - "Gemfile"
321
+ - "Guardfile"
322
+ - "config/routes.rb"
323
+ - "config/routes/**/*.rb"
324
+ - "*.gemspec"
325
+ - "config/environments/*.rb"
326
+
327
+ # 6 は強すぎるので緩める
328
+ Metrics/CyclomaticComplexity:
329
+ Max: 10
330
+
331
+ # * 警告 120文字
332
+ # * 禁止 160文字
333
+ # のイメージ
334
+ Metrics/LineLength:
335
+ Max: 160
336
+ Exclude:
337
+ - "db/migrate/*.rb"
338
+
339
+ # 20 行超えるのは migration ファイル以外滅多に無い
340
+ Metrics/MethodLength:
341
+ Max: 20
342
+ Exclude:
343
+ - "db/migrate/*.rb"
344
+
345
+ Metrics/ParameterLists:
346
+ Max: 5
347
+ CountKeywordArgs: true
348
+
349
+ # 分岐の数。ガード句を多用しているとデフォルト 7 だと厳しい
350
+ Metrics/PerceivedComplexity:
351
+ Max: 8
352
+
353
+ #################### Security ##############################
354
+
355
+ # 毎回 YAML.safe_load(yaml_str, [Date, Time]) するのは面倒で。。
356
+ Security/YAMLLoad:
357
+ Enabled: false
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
4
+
5
+ # Exit cleanly from an early interrupt
6
+ Signal.trap('INT') { exit 1 }
7
+
8
+ require 'fincop'
9
+
10
+ Fincop::CLI.start(ARGV)
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fincop/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'fincop'
8
+ spec.version = Fincop::VERSION
9
+ spec.authors = ['FiNC, Inc']
10
+ spec.email = ['finc@finc.com']
11
+
12
+ spec.summary = 'FinCop is a RuboCop configuration gem.'
13
+ spec.description = 'FinCop is a RuboCop configuration gem.'
14
+ spec.homepage = 'https://github.com/FiNCDeveloper/fincop'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'rubocop', '>= 0.51.0'
25
+ spec.add_dependency 'rubocop-rspec', '>= 1.19.0'
26
+ spec.add_development_dependency 'bundler', '~> 1.13'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
+ end
@@ -0,0 +1,6 @@
1
+ require 'fincop/cli'
2
+ require 'fincop/version'
3
+
4
+ module Fincop
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,43 @@
1
+ require 'fileutils'
2
+ module Fincop
3
+ class CLI
4
+ def self.start(args)
5
+ action_name = retrieve_command_name(args)
6
+ unless action_name
7
+ print_help
8
+ exit
9
+ end
10
+
11
+ instance = self.new
12
+ if instance.public_methods(false).include?(action_name.to_sym)
13
+ instance.__send__(action_name, args)
14
+ exit
15
+ end
16
+
17
+ puts "Could not find command #{action_name}."
18
+ print_help
19
+ exit(1)
20
+ rescue => e
21
+ puts e.message
22
+ exit(1)
23
+ end
24
+
25
+ def self.retrieve_command_name(args)
26
+ meth = args.first.to_s unless args.empty?
27
+ args.shift if meth && (meth !~ /^\-/)
28
+ end
29
+
30
+ def self.print_help
31
+ puts 'fincop commands:'
32
+ puts ' init - Setup .rubocop.yml'
33
+ end
34
+
35
+ CONFIG_FILE_NAME = '.rubocop.yml'.freeze
36
+ def init(args)
37
+ raise 'usage: fincop init' unless args.empty?
38
+ template_path = File.expand_path('../../templates', __dir__)
39
+ puts "#{File.exist?(CONFIG_FILE_NAME) ? "overwrite" : "create"} #{CONFIG_FILE_NAME}"
40
+ FileUtils.copy_file(File.join(template_path, CONFIG_FILE_NAME), CONFIG_FILE_NAME)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ module Fincop
2
+ VERSION = '0.51.0.2'.freeze
3
+ end
@@ -0,0 +1,12 @@
1
+ inherit_gem:
2
+ fincop:
3
+ - 'config/rails.yml'
4
+ - 'config/rspec.yml'
5
+ - 'config/rubocop.yml'
6
+ # If you are using Rails 4, activate this cop.
7
+ # - 'config/disabled_for_rails_4.yml'
8
+
9
+ AllCops:
10
+ TargetRubyVersion: 2.4
11
+
12
+ DisplayStyleGuide: true
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fincop
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.51.0.2
5
+ platform: ruby
6
+ authors:
7
+ - FiNC, Inc
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-12-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubocop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.51.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.51.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop-rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.19.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.19.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.13'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: FinCop is a RuboCop configuration gem.
84
+ email:
85
+ - finc@finc.com
86
+ executables:
87
+ - fincop
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".rubocop.yml"
94
+ - ".travis.yml"
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - config/disabled_for_rails_4.yml
102
+ - config/rails.yml
103
+ - config/rspec.yml
104
+ - config/rubocop.yml
105
+ - exe/fincop
106
+ - fincop.gemspec
107
+ - lib/fincop.rb
108
+ - lib/fincop/cli.rb
109
+ - lib/fincop/version.rb
110
+ - templates/.rubocop.yml
111
+ homepage: https://github.com/FiNCDeveloper/fincop
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.6.13
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: FinCop is a RuboCop configuration gem.
135
+ test_files: []