retrieva-cop 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8e818a721e09f9a3139b1fc097f794682a71e70e
4
+ data.tar.gz: 86125f726503eac7723be849012ae0ac5ff031a6
5
+ SHA512:
6
+ metadata.gz: 0dd2acef70b76353a1563f8b4a12d6e7b5118502db45d8d56b1a50f0c2d747604e05437eb9b91a95ed317eca47784b8675fd47efaf64aca23651204028001067
7
+ data.tar.gz: a27c16d72e9cea119b6d9ddbefc321310e355120cf7a117a933c365d5383a5372854f9f9339233b2ab163f142c5b73b6882a9a9cd0f71731818510ed16dfdaf5
data/.gitignore ADDED
@@ -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/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in retrieva-cop.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Retrieva, 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 all
13
+ 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 THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # Retrieva::Cop
2
+
3
+ Retrieva::Cop is a RuboCop configuration gem for Retrieva, inc.
4
+ Highly inspiered by [onkcop](https://github.com/onk/onkcop/) and [deka_eiwakun](https://github.com/esminc/deka_eiwakun/)
5
+
6
+ ## Usage
7
+
8
+ TODO: Write usage instructions here
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ group :development do
16
+ gem "retrieva-cop", require: false
17
+ end
18
+ ```
19
+
20
+ ## Contributing
21
+
22
+ Bug reports and pull requests are welcome on GitHub at https://github.com/retrieva/retrieva-cop.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "retrieva/cop"
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(__FILE__)
data/bin/setup ADDED
@@ -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
data/config/rails.yml ADDED
@@ -0,0 +1,8 @@
1
+ Rails:
2
+ Enabled: true
3
+
4
+ # slug とか created_by とか、NOT NULL だが create_table 時に
5
+ # default 値を定義できないカラムは存在する。
6
+ Rails/NotNullColumn:
7
+ Enabled: false
8
+
data/config/rspec.yml ADDED
@@ -0,0 +1,42 @@
1
+ require: "rubocop-rspec"
2
+
3
+ # 短い subject は一行で書いて良い
4
+ RSpec/EmptyLineAfterSubject:
5
+ Enabled: false
6
+
7
+ # it が一つしか無いような context では空行を開ける方が読みづらい
8
+ # context "when foo is bar" do
9
+ # let(:foo) { bar }
10
+ # it { is_expected.to do_something }
11
+ # end
12
+ RSpec/EmptyLineAfterFinalLet:
13
+ Enabled: false
14
+
15
+ # each で回したり aggregate_failures 使ってたりすると厳しい。
16
+ # feature spec は exclude でも良いかもしれない。
17
+ # ヒアドキュメント使うと一瞬で超えるので disable も検討。
18
+ RSpec/ExampleLength:
19
+ Max: 8
20
+
21
+ # 変に名前つけて呼ぶ方が分かりづらい。
22
+ # テスト対象メソッドを呼ぶだけの subject 以外を書かないようにする方が効く。
23
+ RSpec/NamedSubject:
24
+ Enabled: false
25
+
26
+ # 強く 1 example 1 assertion の立場は取らないが、多すぎてもツラいので。
27
+ RSpec/MultipleExpectations:
28
+ Max: 3
29
+
30
+
31
+ # Model
32
+ # `- #method
33
+ # |- 頻出ケースのテスト 1
34
+ # |- 頻出ケースのテスト 2
35
+ # `- レアケース
36
+ # |- レアケースのテスト 1
37
+ # `- レアケースのテスト 2
38
+ # のように括り出すと、レアケースのテストを読み飛ばせるようになり
39
+ # テストを読む人にやさしくなる。
40
+ # デフォルトの 3 より少し緩めてもヨサソウ。
41
+ RSpec/NestedGroups:
42
+ Max: 4
@@ -0,0 +1,159 @@
1
+ # Highly inspired by github.com/onk/onkcop
2
+
3
+ # 自動生成されるものはチェック対象から除外する
4
+ AllCops:
5
+ Exclude:
6
+ - "vendor/**/*" # rubocop config/default.yml
7
+ - "db/schema.rb"
8
+ - "node_modules/**/*"
9
+ DisplayCopNames: true
10
+
11
+ #################### Layout ################################
12
+
13
+ # メソッドチェーンの改行は末尾に . を入れる
14
+ # REPL に貼り付けた際の暴発を防ぐため
15
+ Layout/DotPosition:
16
+ EnforcedStyle: trailing
17
+
18
+ # 桁揃えが綺麗にならないことが多いので migration は除外
19
+ Layout/ExtraSpacing:
20
+ Exclude:
21
+ - "db/migrate/*.rb"
22
+
23
+ # メソッドチェーン感がより感じられるインデントにする
24
+ Layout/MultilineMethodCallIndentation:
25
+ EnforcedStyle: indented_relative_to_receiver
26
+
27
+ #################### Lint ##################################
28
+
29
+ # Style/EmptyCaseCondition と同じく網羅の表現力が empty when を認めた方が高いし、
30
+ # 頻出する対象を最初の when で撥ねるのはパフォーマンス向上で頻出する。
31
+ # また、
32
+ # case foo
33
+ # when 42
34
+ # # nop
35
+ # when 1..100
36
+ # ...
37
+ # end
38
+ # と、下の when がキャッチしてしまう場合等に対応していない。
39
+ # See. http://tech.sideci.com/entry/2016/11/01/105900
40
+ Lint/EmptyWhen:
41
+ Enabled: false
42
+
43
+ #################### Metrics ###############################
44
+
45
+ # 30 まではギリギリ許せる範囲だったけど
46
+ # リリースごとに 3 ずつぐらい下げていきます。20 まで下げたい。
47
+ Metrics/AbcSize:
48
+ Max: 24
49
+
50
+ # Gemfile, Guardfile は DSL 的で基本的に複雑にはならないので除外
51
+ # rake, rspec, environments, routes は巨大な block 不可避なので除外
52
+ # TODO: ExcludedMethods の精査
53
+ Metrics/BlockLength:
54
+ Exclude:
55
+ - "Rakefile"
56
+ - "**/*.rake"
57
+ - "spec/**/*.rb"
58
+ - "Gemfile"
59
+ - "Guardfile"
60
+ - "config/environments/*.rb"
61
+ - "config/routes.rb"
62
+ - "config/routes/**/*.rb"
63
+ - "*.gemspec"
64
+
65
+ # 6 は強すぎるので緩める
66
+ Metrics/CyclomaticComplexity:
67
+ Max: 10
68
+
69
+ # * 警告 120文字
70
+ # * 禁止 160文字
71
+ # のイメージ
72
+ Metrics/LineLength:
73
+ Max: 160
74
+
75
+ # 20 行超えるのは migration ファイル以外滅多に無い
76
+ Metrics/MethodLength:
77
+ Max: 20
78
+ Exclude:
79
+ - "db/migrate/*.rb"
80
+
81
+ #################### Style #################################
82
+
83
+ # 日本語のコメントを許可する
84
+ Style/AsciiComments:
85
+ Enabled: false
86
+
87
+ # do .. end から更にメソッドチェーンすると見づらいので
88
+ # auto-correct せず、自分で修正する
89
+ # spec 内は見た目が綺麗になるので許可
90
+ Style/BlockDelimiters:
91
+ AutoCorrect: false
92
+ Exclude:
93
+ - "spec/**/*"
94
+
95
+ # scope が違うとか親 module の存在確認が必要とかデメリットはあるが、
96
+ # namespace 付きのクラスはかなり頻繁に作るので簡単に書きたい。
97
+ Style/ClassAndModuleChildren:
98
+ Enabled: false
99
+
100
+ # ドキュメントの無い public class を許可する
101
+ Style/Documentation:
102
+ Enabled: false
103
+
104
+ # !! のイディオムは積極的に使う
105
+ Style/DoubleNegation:
106
+ Enabled: false
107
+
108
+ # まだ対応するには早い
109
+ Style/FrozenStringLiteralComment:
110
+ Enabled: false
111
+
112
+ # rake タスクの順序の hash は rocket を許可する
113
+ Style/HashSyntax:
114
+ Exclude:
115
+ - "**/*.rake"
116
+ - "Rakefile"
117
+
118
+ # 特に model 内において、ローカル変数とメソッド呼び出しの区別をつけた方が分かりやすい場合が多い
119
+ Style/RedundantSelf:
120
+ Enabled: false
121
+
122
+ # Rubocop は %w[] を押すが、%w() で問題ないとする
123
+ Style/PercentLiteralDelimiters:
124
+ PreferredDelimiters:
125
+ '%w': '()'
126
+ '%i': '()'
127
+
128
+ # 1_000_000 と区切り文字が 2 個以上必要になる場合のみ _ 区切りを必須にする
129
+ # 10_000_00 は許可しない。(これは例えば 10000 ドルをセント単位にする時に便利だが
130
+ # 頻出しないので foolproof に振る
131
+ Style/NumericLiterals:
132
+ MinDigits: 7
133
+ Strict: true
134
+
135
+ # foo.positive? は foo > 0 に比べて意味が曖昧になる
136
+ # foo.zero? は許可したいけどメソッドごとに指定できないので一括で disable に
137
+ Style/NumericPredicate:
138
+ Enabled: false
139
+
140
+ # spec 内は見た目が綺麗になるので許可
141
+ Style/Semicolon:
142
+ Exclude:
143
+ - "spec/**/*"
144
+
145
+ # * 式展開したい場合に書き換えるのが面倒
146
+ # * 文章ではダブルクォートよりもシングルクォートの方が頻出する
147
+ # ことから EnforcedStyle: double_quotes 推奨
148
+ Style/StringLiterals:
149
+ Exclude:
150
+ - "db/migrate/*"
151
+
152
+ # 条件式で arr.size > 0 が使われた時に
153
+ # if !arr.empty?
154
+ # else
155
+ # end
156
+ # に修正されるのが嫌。
157
+ # 中身を入れ替えて否定外しても良いんだけど、どちらが例外的な処理なのかが分かりづらくなる。
158
+ Style/ZeroLengthPredicate:
159
+ Enabled: false
@@ -0,0 +1,7 @@
1
+ require "retrieva/cop/version"
2
+
3
+ module Retrieva
4
+ module Cop
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Retrieva
2
+ module Cop
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "retrieva/cop/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "retrieva-cop"
8
+ spec.version = Retrieva::Cop::VERSION
9
+ spec.authors = ["Kei Shiratsuchi"]
10
+ spec.email = ["kei.shiratsuchi@retrieva.jp"]
11
+
12
+ spec.summary = %q{RetrievaCop is a RuboCop configuration gem.}
13
+ spec.description = %q{RetrievaCop is a RuboCop configuration gem.}
14
+ spec.homepage = "https://github.com/retrieva/retrieva-cop"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "rubocop", "~> 0.50.0"
24
+ spec.add_dependency "rubocop-rspec", ">= 1.18.0"
25
+ spec.add_development_dependency "bundler"
26
+ spec.add_development_dependency "rake"
27
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: retrieva-cop
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kei Shiratsuchi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-10-06 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.50.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.50.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.18.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.18.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: '0'
48
+ type: :development
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: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: RetrievaCop is a RuboCop configuration gem.
70
+ email:
71
+ - kei.shiratsuchi@retrieva.jp
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - bin/console
82
+ - bin/setup
83
+ - config/rails.yml
84
+ - config/rspec.yml
85
+ - config/rubocop.yml
86
+ - lib/retrieva/cop.rb
87
+ - lib/retrieva/cop/version.rb
88
+ - retrieva-cop.gemspec
89
+ homepage: https://github.com/retrieva/retrieva-cop
90
+ licenses: []
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.6.11
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: RetrievaCop is a RuboCop configuration gem.
112
+ test_files: []