rubocop-grape 0.2.0 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e2ad9ec7a76a877cde28f025cccbff00e561a5ce9678892cb36d84583f4cdb7
4
- data.tar.gz: 0ddb3542ef0b046ff88328c2813626c19749541b5b760161d6df6d3c985fece3
3
+ metadata.gz: '02479172353db2e2fea8b532d01cf2dde616c7751e0d81a4a550227789128fc7'
4
+ data.tar.gz: 83cc6fcfe0f01e021e4bedd257a5e2162f4a20c4f35aad28e5dcf04f2364706d
5
5
  SHA512:
6
- metadata.gz: 0cc9262ee02e74a134f7e0917ef9ba6fea99fe09c397b65ebb9d8c94c1f138a1cc44aef6d6995aee82689f791faca506c54f53a414618494298adb684b837252
7
- data.tar.gz: 3d997bee7403959125be792b5e496d7280fdfad2273aafa5f55c3ce2e0554841aeac5e6de7841a6f88bcddcb44b574ad85e73dc8d507038a4c92ccf37bfd4588
6
+ metadata.gz: 46c7d251b5e0882e72a76d1aa77271f04386141a172a5b4d054ff079957b4a43f2ffe1cfdba7d993ed83aa868bcaac6366db9cbfb2882c6b01acbe6f9631ba49
7
+ data.tar.gz: bd9bb8ca47a1c2cca8eaf6b08ec39ea9d80d69e59ecb32225909b1da83ee38a516c1cf8e65e7a14d2c8e322ea5a8b0a356a5bad2a1243623263b40c4381b070a
data/config/default.yml CHANGED
@@ -1,3 +1,6 @@
1
+ AllCops:
2
+ GrapeDir: 'app/api'
3
+
1
4
  Grape/RouteParamType:
2
5
  Enabled: true
3
6
  Safe: false
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Grape
6
+ # This is a monkey patch for RuboCop
7
+ # which makes rubocop-grape cops adapted only for grape files.
8
+ module GrapeFile
9
+ DEFAULT_GRAPE_DIR = 'app/api'
10
+
11
+ def grape_dir
12
+ @grape_dir ||= load_grape_file_from_config || DEFAULT_GRAPE_DIR
13
+ end
14
+
15
+ def grape_files
16
+ @grape_files ||= Dir.glob('**/*.rb', base: grape_dir).map do |relative_path|
17
+ File.absolute_path(relative_path, grape_dir)
18
+ end
19
+ end
20
+
21
+ Team.prepend self
22
+
23
+ private
24
+
25
+ def load_grape_file_from_config
26
+ @config.for_all_cops['GrapeDir']
27
+ end
28
+
29
+ def roundup_relevant_cops(filename)
30
+ super.select do |cop|
31
+ next true unless cop.class.name.match?(/RuboCop::Cop::Grape::.+$/)
32
+
33
+ grape_files.include?(filename)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Grape
5
- VERSION = '0.2.0'
5
+ VERSION = '0.2.1'
6
6
  end
7
7
  end
data/lib/rubocop-grape.rb CHANGED
@@ -8,4 +8,6 @@ require_relative 'rubocop/grape/inject'
8
8
 
9
9
  RuboCop::Grape::Inject.defaults!
10
10
 
11
+ require_relative 'rubocop/grape/grape_files'
12
+
11
13
  require_relative 'rubocop/cop/grape_cops'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-grape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akito Hikasa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-13 00:00:00.000000000 Z
11
+ date: 2023-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -49,6 +49,7 @@ files:
49
49
  - lib/rubocop/cop/grape/route_param_type.rb
50
50
  - lib/rubocop/cop/grape_cops.rb
51
51
  - lib/rubocop/grape.rb
52
+ - lib/rubocop/grape/grape_files.rb
52
53
  - lib/rubocop/grape/inject.rb
53
54
  - lib/rubocop/grape/version.rb
54
55
  homepage: https://github.com/kakubin/rubocop-grape