salsify_rubocop 0.47.1.rc0 → 0.47.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
  SHA1:
3
- metadata.gz: 5dcbe21b6de7a233cf330a202722885b87a49a91
4
- data.tar.gz: 2da2ae030c4cd422fecab9b16846759800b7e289
3
+ metadata.gz: a235a0d2d7c100c09da10c768f5a7e8384d30b8c
4
+ data.tar.gz: f1c310ca03dea3a45efc6b0c104a5b8411a827ae
5
5
  SHA512:
6
- metadata.gz: b12655ea2c8447a16bf5036f7576929b896fdff422d3b77b4274978edea6dd1042cde48da63502860735839642fb69f6fb4646ef00a0ed6ce740263cd6436c40
7
- data.tar.gz: c9d2e1785dfded5b97b815456d6fd76a1f7f1edb68827cad7bb5ef7e9b59df1e1dd72379625426597756f8747384155dbf1c00708cb2f027d815642471c97b2f
6
+ metadata.gz: 9c788c146e8be102a39e8340c22c1b391a2fbaef4e6cfae70c93142414af839dd69625e4cdd9f897846d43e1fa602c866e4351f624124f2ba4dab31ed193ccfd
7
+ data.tar.gz: d445a00088b9745687e1a2f1670e91d3b736d927b96081dfc23d3721cf75c731fbb587d09cc11b98a3cd4013e94d064e69442bd64dc96b4d9a758be5fc502f6b
data/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## v0.47.1
4
4
  - Add `Salsify/StyleDig` cop to recommend using `#dig` for deeply nested access.
5
+ - Add `Salsify/RailsApplicationRecord` cop.
6
+ - Add new `rubocop_rails50` configuration for use with Rails 5.0 apps.
5
7
 
6
8
  ## v0.47.0
7
9
  - Update to `rubocop` v0.47.1 and `rubocop-rspec` v1.10.0.
@@ -0,0 +1,8 @@
1
+ inherit_from:
2
+ - ../conf/rubocop_rails.yml
3
+
4
+ Rails/HttpPositionalArguments:
5
+ Enabled: true
6
+
7
+ Salsify/RailsApplicationRecord:
8
+ Enabled: true
data/config/default.yml CHANGED
@@ -1,3 +1,7 @@
1
+ Salsify/RailsApplicationRecord:
2
+ Description: 'Models must subclass ApplicationRecord.'
3
+ Enabled: false
4
+
1
5
  Salsify/RspecDocString:
2
6
  Description: 'Check that RSpec doc strings use the correct quoting.'
3
7
  Enabled: true
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+ require 'rubocop'
3
+ module RuboCop
4
+ module Cop
5
+ module Salsify
6
+ # Check that models subclass ApplicationRecord with Rails 5.0
7
+ #
8
+ # @example
9
+ #
10
+ # # good
11
+ # class Tesla < ApplicationRecord
12
+ # ...
13
+ # end
14
+ #
15
+ # # bad
16
+ # class Yugo < ActiveRecord::Base
17
+ # ...
18
+ # end
19
+ class RailsApplicationRecord < Cop
20
+
21
+ MSG = 'Models must subclass ApplicationRecord'.freeze
22
+ APPLICATION_RECORD = 'ApplicationRecord'.freeze
23
+ ACTIVE_RECORD_BASE_PATTERN = '(const (const nil :ActiveRecord) :Base)'.freeze
24
+
25
+ def_node_matcher :model_class_definition, <<-PATTERN
26
+ (class (const _ !:ApplicationRecord) #{ACTIVE_RECORD_BASE_PATTERN} ...)
27
+ PATTERN
28
+
29
+ def_node_matcher :class_new_definition, <<-PATTERN
30
+ [!^(casgn nil :ApplicationRecord ...) (send (const nil :Class) :new #{ACTIVE_RECORD_BASE_PATTERN})]
31
+ PATTERN
32
+
33
+ def on_class(node)
34
+ model_class_definition(node) do
35
+ add_offense(node.children[1], :expression, MSG)
36
+ end
37
+ end
38
+
39
+ def on_send(node)
40
+ class_new_definition(node) do
41
+ add_offense(node.children.last, :expression, MSG)
42
+ end
43
+ end
44
+
45
+ def autocorrect(node)
46
+ lambda do |corrector|
47
+ corrector.replace(node.source_range, APPLICATION_RECORD)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -13,6 +13,7 @@ config = RuboCop::ConfigLoader.merge_with_default(config, path)
13
13
  RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
14
14
 
15
15
  # cops
16
+ require 'rubocop/cop/salsify/rails_application_record'
16
17
  require 'rubocop/cop/salsify/rspec_doc_string'
17
18
  require 'rubocop/cop/salsify/rspec_string_literals'
18
19
  require 'rubocop/cop/salsify/style_dig'
@@ -1,3 +1,3 @@
1
1
  module SalsifyRubocop
2
- VERSION = '0.47.1.rc0'.freeze
2
+ VERSION = '0.47.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: salsify_rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.47.1.rc0
4
+ version: 0.47.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salsify, Inc
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-04 00:00:00.000000000 Z
11
+ date: 2017-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,8 +100,10 @@ files:
100
100
  - bin/setup
101
101
  - conf/rubocop.yml
102
102
  - conf/rubocop_rails.yml
103
+ - conf/rubocop_rails50.yml
103
104
  - conf/rubocop_without_rspec.yml
104
105
  - config/default.yml
106
+ - lib/rubocop/cop/salsify/rails_application_record.rb
105
107
  - lib/rubocop/cop/salsify/rspec_doc_string.rb
106
108
  - lib/rubocop/cop/salsify/rspec_string_literals.rb
107
109
  - lib/rubocop/cop/salsify/style_dig.rb
@@ -125,9 +127,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
127
  version: '0'
126
128
  required_rubygems_version: !ruby/object:Gem::Requirement
127
129
  requirements:
128
- - - ">"
130
+ - - ">="
129
131
  - !ruby/object:Gem::Version
130
- version: 1.3.1
132
+ version: '0'
131
133
  requirements: []
132
134
  rubyforge_project:
133
135
  rubygems_version: 2.6.10