fablicop 1.1.0 → 1.1.1

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: 6b5caa1ee8828550cee968cb6207cc13bed218e6807a40411856ba69a43cb534
4
- data.tar.gz: 8cb4ecff9101a1e21e308b7bb72614c1f85311dd5a089bf8802c2d14b9907f50
3
+ metadata.gz: 6569d42b358ee7df8ca5eabfa95d57750e05dd57cb80f2994f54b9cab6658816
4
+ data.tar.gz: 36dbc034a61fe4c3d972d3b5fdfc53603cfc1fed4bdf1ae58f22c64ab3c98977
5
5
  SHA512:
6
- metadata.gz: af21d0e9d4474a040648c2163ae72555c5c10d887793a4c5cbb7337ef59039355b00eb6223bc13a2d2f24e00a02524991a63bd2ea01d00039cd7fdbac1618d0d
7
- data.tar.gz: 4c3bc61b9626a3b899e84cc6cfeedcf1971cc9d8ca048e9332d6fcd9813fc5d82fa9be4e97d3fbdac17b0a15e14c52cef252cde9a158a8de1fe00e4d57cba03d
6
+ metadata.gz: dc26ed8cebee6f4bbbe62e7d34f42a244badecafcbae9c58c63a011e50a2b612d431f51d8202351031594ca55e2e48d4d2ef8c1eb9daca52c065801f39c31204
7
+ data.tar.gz: ecb8d33f436d7b3c4e1d657b57438785952a6038d8eb055ca777a9ddf04bf091f734d7d32447364eccddcd58871363a7d24b15b16da2ebcf88d9828c6b3a4f4b
@@ -1,17 +1,36 @@
1
1
  name: Run CI
2
2
 
3
- on: push
3
+ on:
4
+ push:
5
+ branches: ["master"]
6
+ tags: ["**"]
7
+ pull_request:
4
8
 
5
9
  jobs:
6
10
  'run-ci':
7
11
  runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby: ["2.5", "2.6", "2.7", "3.0"]
8
16
  steps:
9
17
  - uses: actions/checkout@v2
10
- - name: Set up Ruby
11
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
12
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
13
- uses: ruby/setup-ruby@v1
18
+ - uses: ruby/setup-ruby@v1
14
19
  with:
15
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
16
- - name: Run rspecs
17
- run: bundle exec rspec
20
+ ruby-version: ${{ matrix.ruby }}
21
+ bundler-cache: true
22
+ - run: bundle exec rspec
23
+
24
+ lint:
25
+ runs-on: ubuntu-latest
26
+ strategy:
27
+ fail-fast: false
28
+ matrix:
29
+ ruby: ["2.5", "2.6", "2.7", "3.0"]
30
+ steps:
31
+ - uses: actions/checkout@v2
32
+ - uses: ruby/setup-ruby@v1
33
+ with:
34
+ ruby-version: ${{ matrix.ruby }}
35
+ bundler-cache: true
36
+ - run: bundle exec rubocop
data/.rubocop.yml CHANGED
@@ -1 +1,4 @@
1
1
  inherit_from: config/.base_rubocop.yml
2
+
3
+ Rails:
4
+ Enabled: false
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in fablicop.gemspec
data/README.md CHANGED
@@ -1,39 +1,51 @@
1
1
  # fablicop
2
2
 
3
3
  fablicop is a RuboCop configration gem.
4
+ It assumes your project is using Ruby on Rails, so some Cops prefixed with `Rails` are enabled out of the box.
5
+ In other words, it's not appropriate to use it with non-Rails projects.
4
6
 
5
- ## Usage
7
+ ## Installation
8
+
9
+ You can install fablicop with this command:
10
+
11
+ ```console
12
+ gem install fablicop
13
+ ```
14
+
15
+ Or, run `bundle install` after adding this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'fablicop', require: false
19
+ ```
20
+
21
+ ## Getting started
6
22
 
7
- Setup .rubocop.yml
23
+ Set up `.rubocop.yml` with the command below.
8
24
 
9
- ```sh
10
- bundle exec fablicop init
25
+ ```console
26
+ fablicop init
11
27
  ```
12
28
 
13
- `init` generate the following directive to your `.rubocop.yml`:
29
+ `init` generates the following directive to your `.rubocop.yml`:
14
30
 
15
31
  ```yaml
16
32
  inherit_gem:
17
33
  fablicop:
18
34
  - "config/.base_rubocop.yml"
19
- # uncomment if use rails cops
20
- # - "config/rails.yml"
21
- # uncomment if use rspec cops
22
- # - "config/rspec.yml"
23
35
  ```
24
36
 
25
- ```sh
26
- bundle exec rubocop <options...>
27
- ```
37
+ ## Usage
28
38
 
29
- ## Installation
39
+ After configuration, your RuboCop now sees fablicop's configuration. Just run `rubocop` as usual.
40
+
41
+ ```console
42
+ rubocop
43
+ ```
30
44
 
31
- Add this line to your application's Gemfile:
45
+ Or, prefix `bundle exec`.
32
46
 
33
- ```ruby
34
- group :development do
35
- gem "fablicop", require: false
36
- end
47
+ ```console
48
+ bundle exec rubocop
37
49
  ```
38
50
 
39
51
  ## Contributing
data/Rakefile CHANGED
@@ -1,2 +1,4 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "fablicop"
4
+ require 'bundler/setup'
5
+ require 'fablicop'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "fablicop"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start
@@ -1,10 +1,11 @@
1
1
  require:
2
2
  - rubocop-rails
3
+ - rubocop-rspec
3
4
 
4
- # 自動生成されるものやテストデータはチェック対象から除外する
5
+ # We exclude files that are generated automatically or test data.
5
6
  AllCops:
6
7
  Exclude:
7
- - "vendor/**/*" # rubocop config/default.yml
8
+ - "vendor/**/*"
8
9
  - "db/schema.rb"
9
10
  - "db/migrate/*"
10
11
  - "db/fixtures/**/*"
@@ -13,12 +14,12 @@ AllCops:
13
14
  - "spec/test_app/db/*"
14
15
 
15
16
  DisplayCopNames: true
16
- NewCops: enable # 新しい規約も随時取り入れる
17
+ NewCops: enable
17
18
 
18
19
  Rails:
19
20
  Enabled: true
20
21
 
21
- # rails >= 5 の設定のため
22
+ # For rails >= 5. TODO: This should be enabled in my opinion.
22
23
  Rails/HttpPositionalArguments:
23
24
  Enabled: false
24
25
 
@@ -38,11 +39,11 @@ Gemspec/OrderedDependencies:
38
39
 
39
40
  ##################### Style ##################################
40
41
 
41
- # 日本語のコメントを許可する
42
+ # We sometimes use non-ascii comments.
42
43
  Style/AsciiComments:
43
44
  Enabled: false
44
45
 
45
- # 複数行の場合は末尾にカンマを入れる
46
+ # We prefer trailing comma all the time.
46
47
  Style/TrailingCommaInArrayLiteral:
47
48
  EnforcedStyleForMultiline: comma
48
49
  Style/TrailingCommaInHashLiteral:
@@ -50,32 +51,22 @@ Style/TrailingCommaInHashLiteral:
50
51
  Style/TrailingCommaInArguments:
51
52
  EnforcedStyleForMultiline: comma
52
53
 
53
- # class先頭のコメントを省略する
54
+ # We sometimes omit the top-level documentation for classes/modules.
54
55
  Style/Documentation:
55
56
  Enabled: false
56
57
 
57
- # selfは省略しない
58
+ # We sometimes want to use `self` anyway.
58
59
  Style/RedundantSelf:
59
60
  Enabled: false
60
61
 
61
- # 以下の2つのあわせ技で、こういうのを許可
62
+ # We want to allow the code like this:
63
+ #
62
64
  # xs.select {
63
65
  # f x
64
66
  # }.map { |x|
65
67
  # f x
66
68
  # f x
67
69
  # }.compact
68
- # Rubocopの意図としては、おそらく
69
- # * ブロックのあとにメソッドをチェインされると読みにくい(主観)
70
- # * ブロックの終わりを`}`ではなく`end`にすることで、defとかifとかと終了を揃える
71
- # だと思うけど、むしろ一旦変数に入れて改めてメソッド適用する方がかえって読みにくいと思うし(主観)、
72
- # 返り値を使う場合はブロックの終わりをendにせず}にしないとメソッド結合順序の関係などでやばいので
73
- # Style/BlockDelimitersとStyle/MultilineBlockChainはよくないと判断。
74
- #
75
- # 「返り値を目的とするブロック引数」には{}を、「副作用を目的とするブロック引数」にはdo/endを
76
- # 使うようにすると、可読性的にもメソッドの結合順序的にも実用上便利。
77
- # これが正しく運用されてるかどうかはgrammerではなくsemanticの話なので、レビュワーの人間が
78
- # 見ることになり、それは直感的な気がする (再び主観)
79
70
  Style/BlockDelimiters:
80
71
  Enabled: false
81
72
  Style/MultilineBlockChain:
@@ -83,7 +74,7 @@ Style/MultilineBlockChain:
83
74
  Style/EmptyMethod:
84
75
  Enabled: false
85
76
 
86
- # 候補が多いときはcondみたいに使いたい
77
+ # We sometimes want to use empty case when there are many conditions.
87
78
  Style/EmptyCaseCondition:
88
79
  Enabled: false
89
80
 
@@ -99,19 +90,19 @@ Style/MethodCallWithoutArgsParentheses:
99
90
  Style/DefWithParentheses:
100
91
  Enabled: false
101
92
 
102
- # classが入れ子になった場合、テストの順番によってはエラーになりうる
93
+ # This might not be a style cop because errors happen due to the order of tests with nested classes/modules.
103
94
  Style/ClassAndModuleChildren:
104
95
  Exclude:
105
96
  - "test/**/*.rb"
106
97
  - "spec/**/*.rb"
107
98
 
108
- # 3桁ごとに_を入れるとSQLの表示方法と乖離するためfixtureは対象外
99
+ # This style differs from the expression of SQL.
109
100
  Style/NumericLiterals:
110
101
  Exclude:
111
102
  - "db/fixtures/*.rb"
112
103
 
113
104
  ##################### Layout ##################################
114
- # 引数前のスペースは複数許可
105
+ # We sometimes want to put multiple spaces before arguments.
115
106
  Layout/SpaceBeforeFirstArg:
116
107
  Enabled: false
117
108
  Layout/SpaceInLambdaLiteral:
@@ -119,7 +110,8 @@ Layout/SpaceInLambdaLiteral:
119
110
  Layout/HeredocIndentation:
120
111
  Enabled: false
121
112
 
122
- # 引数の書き方の多様性を許可
113
+ # We want to allow various expression for arguments.
114
+ #
123
115
  # foo(a,
124
116
  # b
125
117
  # )
@@ -134,7 +126,9 @@ Layout/HeredocIndentation:
134
126
  # b)
135
127
  Layout/MultilineMethodCallBraceLayout:
136
128
  Enabled: false
137
- # メソッド指定の多様性を許可
129
+
130
+ # We don't want to enforce various method calls.
131
+ #
138
132
  # while a
139
133
  # .b
140
134
  # something
@@ -153,27 +147,30 @@ Layout/MultilineMethodCallBraceLayout:
153
147
  Layout/MultilineMethodCallIndentation:
154
148
  Enabled: false
155
149
 
150
+ # Sometimes, we want to write like this:
151
+ #
156
152
  # aaa(bbb(
157
153
  # ccc
158
154
  # ))
159
- # 的なのができないのは不便すぎるのでdisable
160
155
  Layout/FirstParameterIndentation:
161
156
  Enabled: false
162
157
 
163
- # 以下の両方を許容
158
+ # We want to allow both of them:
159
+ #
164
160
  # aaa.
165
161
  # bb().
166
162
  # cc()
167
163
  # aaa
168
164
  # .bb()
169
165
  # .cc()
170
- # 前者は途中にコメントをはさむことができて実用上圧倒的に便利.
171
- # 後者はデフォルトでrubocopがおすすめしてるやつ
166
+ #
167
+ # The first one allows us to insert comments, and it would be convenient.
168
+ # The second one is the default of this Cop.
172
169
  Layout/DotPosition:
173
170
  Enabled: false
174
171
 
175
- # fixtureファイルの1 -> DBの1レコードとして記述している
176
- # 複数行にまたがると直感的でなくなるため無効化
172
+ # We want to consistently write fixture files with the rule: 1 line for 1 record.
173
+ # It's not intuitive with multiple lines.
177
174
  Layout/ClosingParenthesisIndentation:
178
175
  Exclude:
179
176
  - "db/fixtures/*.rb"
@@ -181,30 +178,27 @@ Layout/ParameterAlignment:
181
178
  Exclude:
182
179
  - "db/fixtures/*.rb"
183
180
 
184
- # * 警告 120文字
185
- # * 禁止 160文字
186
- # のイメージ
187
181
  Layout/LineLength:
188
182
  Max: 160
189
183
  Exclude:
190
184
  - "db/migrate/*.rb"
191
- - "db/fixtures/*.rb" # カラムが多い、もしくは文章が含まれるfixtureは一行が長くなってしまうため無効化
185
+ - "db/fixtures/*.rb" # Fixture files usually include long lines.
192
186
 
193
187
  ##################### Lint ##################################
194
188
 
195
- # 引数前のスペースを許容する
189
+ # We sometimes want to put spaces before arguments.
196
190
  Lint/ParenthesesAsGroupedExpression:
197
191
  Enabled: false
198
192
 
199
193
  ##################### Metrics ##################################
200
194
 
201
- # 20 行超えるのは migration ファイル以外滅多に無い
195
+ # There is something wrong with more than 20 lines aside from migration files.
202
196
  Metrics/MethodLength:
203
197
  Max: 20
204
198
  Exclude:
205
199
  - "db/migrate/*.rb"
206
200
 
207
- # キーワード引数は引数の数に含めない
201
+ # We want to measure this metrics without keyword arguments.
208
202
  Metrics/ParameterLists:
209
203
  CountKeywordArgs: false
210
204
 
data/exe/fablicop CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- $LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
4
+ $LOAD_PATH.prepend File.join(__dir__.to_s, '..', 'lib')
4
5
 
5
6
  # Exit cleanly from an early interrupt
6
- Signal.trap("INT") { exit 1 }
7
+ Signal.trap('INT') { exit 1 }
7
8
 
8
- require "fablicop"
9
+ require 'fablicop'
9
10
 
10
11
  Fablicop::CLI.start(ARGV)
data/fablicop.gemspec CHANGED
@@ -1,40 +1,43 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'fablicop/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "fablicop"
8
+ spec.name = 'fablicop'
8
9
  spec.version = Fablicop::VERSION
9
- spec.authors = ["tommy", "ujihisa", "sinamon129"]
10
- spec.email = ["kazushige_tominaga@fablic.co.jp", "tatsuhiro_ujihisa@fablic.co.jp", "shihomi_katayama@fablic.co.jp"]
10
+ spec.authors = %w[tommy ujihisa sinamon129]
11
+ spec.email = ['kazushige_tominaga@fablic.co.jp', 'tatsuhiro_ujihisa@fablic.co.jp', 'shihomi_katayama@fablic.co.jp']
11
12
 
12
- spec.summary = "fablicop is a RuboCop configration gem. "
13
- spec.description = "fablicop is a RuboCop configration gem."
14
- spec.homepage = "https://github.com/Fablic/fablicop"
15
- spec.license = "MIT"
13
+ spec.summary = 'fablicop is a RuboCop configration gem. '
14
+ spec.description = 'fablicop is a RuboCop configration gem.'
15
+ spec.homepage = 'https://github.com/Fablic/fablicop'
16
+ spec.license = 'MIT'
16
17
 
17
18
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
19
  # to allow pushing to a single host or delete this section to allow pushing to any host.
19
- #if spec.respond_to?(:metadata)
20
+ # if spec.respond_to?(:metadata)
20
21
  # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
- #else
22
+ # else
22
23
  # raise "RubyGems 2.0 or newer is required to protect against " \
23
24
  # "public gem pushes."
24
- #end
25
+ # end
25
26
 
26
27
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
28
  f.match(%r{^(test|spec|features)/})
28
29
  end
29
- spec.bindir = "exe"
30
+ spec.bindir = 'exe'
30
31
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
- spec.require_paths = ["lib"]
32
+ spec.require_paths = ['lib']
33
+
34
+ spec.required_ruby_version = '>= 2.5.0'
32
35
 
33
- spec.add_dependency "rubocop", "~> 1.14.0"
34
- spec.add_dependency "rubocop-rspec", ">= 1.15.1"
35
- spec.add_dependency "rubocop-rails"
36
- spec.add_development_dependency "bundler"
37
- spec.add_development_dependency "rspec"
38
- spec.add_development_dependency "rake"
36
+ spec.add_dependency 'rubocop', '~> 1.14.0'
37
+ spec.add_dependency 'rubocop-rspec', '>= 1.15.1'
38
+ spec.add_dependency 'rubocop-rails'
39
+ spec.add_development_dependency 'bundler'
40
+ spec.add_development_dependency 'rspec'
41
+ spec.add_development_dependency 'rake'
39
42
  spec.add_development_dependency 'byebug'
40
43
  end
data/lib/fablicop/cli.rb CHANGED
@@ -1,4 +1,7 @@
1
- require "fileutils"
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+
2
5
  module Fablicop
3
6
  class CLI
4
7
  def self.start(args)
@@ -17,26 +20,27 @@ module Fablicop
17
20
  puts "Could not find command #{action_name}."
18
21
  print_help
19
22
  exit(1)
20
- rescue => e
23
+ rescue StandardError => e
21
24
  puts e.message
22
25
  exit(1)
23
26
  end
24
27
 
25
28
  def self.retrieve_command_name(args)
26
29
  meth = args.first.to_s unless args.empty?
27
- args.shift if meth && (meth !~ /^\-/)
30
+ args.shift if meth && (meth !~ /^-/)
28
31
  end
29
32
 
30
33
  def self.print_help
31
- puts "fablicop commands:"
32
- puts " init - Setup .rubocop.yml"
34
+ puts 'fablicop commands:'
35
+ puts ' init - Setup .rubocop.yml'
33
36
  end
34
37
 
35
- CONFIG_FILE_NAME = ".rubocop.yml"
38
+ CONFIG_FILE_NAME = '.rubocop.yml'
36
39
  def init(args)
37
- raise "usage: fablicop 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
+ raise 'usage: fablicop init' unless args.empty?
41
+
42
+ template_path = File.expand_path('../../templates', __dir__)
43
+ puts "#{File.exist?(CONFIG_FILE_NAME) ? 'overwrite' : 'create'} #{CONFIG_FILE_NAME}"
40
44
  FileUtils.copy_file(File.join(template_path, CONFIG_FILE_NAME), CONFIG_FILE_NAME)
41
45
  end
42
46
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fablicop
2
- VERSION = '1.1.0'
4
+ VERSION = '1.1.1'
3
5
  end
data/lib/fablicop.rb CHANGED
@@ -1,5 +1,7 @@
1
- require "fablicop/cli"
2
- require "fablicop/version"
1
+ # frozen_string_literal: true
2
+
3
+ require 'fablicop/cli'
4
+ require 'fablicop/version'
3
5
 
4
6
  module Fablicop
5
7
  # Your code goes here...
@@ -1,7 +1,3 @@
1
1
  inherit_gem:
2
2
  fablicop:
3
3
  - "config/.base_rubocop.yml"
4
- # uncomment if use rails cops
5
- # - "config/rails.yml"
6
- # uncomment if use rspec cops
7
- # - "config/rspec.yml"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fablicop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - tommy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-07-01 00:00:00.000000000 Z
13
+ date: 2021-09-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -124,7 +124,6 @@ files:
124
124
  - ".gitignore"
125
125
  - ".rspec"
126
126
  - ".rubocop.yml"
127
- - ".ruby-version"
128
127
  - CODE_OF_CONDUCT.md
129
128
  - Gemfile
130
129
  - LICENSE.txt
@@ -151,15 +150,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
150
  requirements:
152
151
  - - ">="
153
152
  - !ruby/object:Gem::Version
154
- version: '0'
153
+ version: 2.5.0
155
154
  required_rubygems_version: !ruby/object:Gem::Requirement
156
155
  requirements:
157
156
  - - ">="
158
157
  - !ruby/object:Gem::Version
159
158
  version: '0'
160
159
  requirements: []
161
- rubyforge_project:
162
- rubygems_version: 2.7.6.2
160
+ rubygems_version: 3.2.22
163
161
  signing_key:
164
162
  specification_version: 4
165
163
  summary: fablicop is a RuboCop configration gem.
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.5.5