ut-rubocop-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: dc06be5b3cf0abc983e40e2cbfe2547860b989078dd662f9af62d4fbd1f3e287
4
+ data.tar.gz: 45ebefd346e8ddde9fbe52e3aa8d0df8967b9294be626422b8feb73f9020de9f
5
+ SHA512:
6
+ metadata.gz: a6928e080b479d5e5aa995e719a25dad86fa4c3c73aecbf269e93b296f564bd730e3b65e700a5fb4461a64e8e807bbecd4703667aa4deaa6789101868e5c4d76
7
+ data.tar.gz: a11fe3761951514841dcd6e7d10bd21b9c398f37e94cec9dbfc601d13875755a5815171dce526267f7f3e389f895a043f60b1bf0944ef8ea104f5151919b5259
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "ut/style_rails/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ut-rubocop-rails"
8
+ spec.version = UT::StyleRails::Version::VERSION
9
+ spec.authors = ["Justin Aiken"]
10
+ spec.email = ["jaiken@usertesting.com"]
11
+ spec.description = %q{UT Rubocop Rails}
12
+ spec.summary = %q{UserTesting's rubocop rules for Rails}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/).reject { |f| f.match(%r{^(spec|doc)/}) }
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rubocop", "0.82.0"
22
+ spec.add_dependency "rubocop-rails", "2.0.1"
23
+ end
@@ -0,0 +1 @@
1
+ Gemfile.lock
@@ -0,0 +1 @@
1
+ inherit_from: default.yml
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,47 @@
1
+ # UT Rubocop-Rails
2
+
3
+ This gem extends [ut-rubocop](https://github.com/usertesting/ut_rubocop) to add Rails specific cops.
4
+
5
+ ## Installation
6
+
7
+ Add the gem to your `Gemfile` in the dev/test group:
8
+
9
+ You don't need to add `rubocop` itself, this takes care of that.
10
+
11
+ ```ruby
12
+ group :test, :development do
13
+ ...
14
+ gem "ut-rubocop", require: false
15
+ gem "ut-rubocop-rails", require: false
16
+ ```
17
+
18
+ In your `.rubocop.yml` file, add these lines near the top:
19
+
20
+ ```yaml
21
+ inherit_gem:
22
+ ut-rubocop:
23
+ - default.yml
24
+ inherit_gem:
25
+ ut-rubocop-rails:
26
+ - default.yml
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ `bundle exec rubocop`
32
+
33
+ ## License
34
+
35
+ [MIT](LICENSE).
36
+
37
+ Library created by [UserTesting](https://usertesting.com)
38
+
39
+ ![UserTesting](doc/UserTesting.png)
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it ( https://github.com/usertesting/ut_rubocop_rails/fork )
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create a new Pull Request
@@ -0,0 +1,44 @@
1
+ require:
2
+ - rubocop-rails
3
+
4
+ AllCops:
5
+ DisabledByDefault: true
6
+ DisplayCopNames: true
7
+ DisplayStyleGuide: true
8
+ Exclude:
9
+ - 'app/assets/**/*'
10
+ - 'node_modules/**/*'
11
+ - 'vendor/**/*'
12
+ - 'gems/**/*'
13
+
14
+ # ------------------------------------ Rails --------------------------------------------
15
+ Rails/Exit:
16
+ Description: >-
17
+ Favor `fail`, `break`, `return`, etc. over `exit` in
18
+ application or library code outside of Rake files to avoid
19
+ exits during unit testing or running in production.
20
+ Enabled: true
21
+
22
+ Rails/Output:
23
+ Description: 'Checks for calls to puts, print, etc.'
24
+ Enabled: true
25
+ Exclude:
26
+ - db/migrate/*.rb
27
+ - lib/perform_deployment.rb
28
+ - lib/asset_manifest.rb
29
+ - lib/chores/log.rb
30
+ - lib/generators/chore/chore_generator.rb
31
+
32
+ Rails/PluralizationGrammar:
33
+ Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
34
+ Enabled: true
35
+
36
+ Rails/ScopeArgs:
37
+ Description: 'Checks the arguments of ActiveRecord scopes.'
38
+ Enabled: true
39
+
40
+ Rails/UniqBeforePluck:
41
+ Description: 'Prefer the use of uniq or distinct before pluck.'
42
+ Enabled: true
43
+
44
+ # ------------------------------------ /Rails --------------------------------------------
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module UT
6
+ class ManageAbility < ::RuboCop::Cop::Cop
7
+
8
+ MSG = "Do not use `:manage` when checking abilities"
9
+
10
+ def on_send(send_node)
11
+ return unless send_node.method?(:can?) || send_node.method?(:authorize!)
12
+ ability = send_node.first_argument
13
+ return unless ability.sym_type? && ability.source == ":manage"
14
+ add_offense send_node, location: send_node.first_argument.loc.expression
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ut/style_rails/version"
4
+ require "ut/cops/manage_ability"
5
+
6
+ module UT
7
+ module StyleRails
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UT
4
+ module StyleRails
5
+ module Version
6
+ VERSION = "0.0.1"
7
+ end
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ut-rubocop-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Justin Aiken
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-08-18 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.82.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.82.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.1
41
+ description: UT Rubocop Rails
42
+ email:
43
+ - jaiken@usertesting.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gemspec"
49
+ - ".gitignore"
50
+ - ".rubocop.yml"
51
+ - Gemfile
52
+ - README.markdown
53
+ - default.yml
54
+ - lib/ut/cops/manage_ability.rb
55
+ - lib/ut/style_rails.rb
56
+ - lib/ut/style_rails/version.rb
57
+ homepage: ''
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubygems_version: 3.0.6
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: UserTesting's rubocop rules for Rails
80
+ test_files: []