salsify_rubocop 0.48.0 → 0.48.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: 5e07cf5240f0567f82de5841b7918aced03bbcd1
4
- data.tar.gz: 5cf9381c581f64eabf2c9bd1fe5d1dfd08c2e191
3
+ metadata.gz: 1168006be538d22e3437ab541c048e7b6d16502e
4
+ data.tar.gz: 1f27eaee901f052080f61c69d6fe10f00e6908e9
5
5
  SHA512:
6
- metadata.gz: f1f8d75e6ae82ce709e174d327b0008520182f7f9af9ac5d79c1e2fa6df9604c1eeca592ad83502e658ffcffde33d47c77c531f8129c98dbda5e3bb6863f35f0
7
- data.tar.gz: 0c093a80290aedf6bee8ba31858b32744b440f7d52d6b4487e0b2734a9ec0f3aeb6414dbdeb6fdc27a23052545e5f5b4fc2bb2d909d72f8cf6c770742b53f67a
6
+ metadata.gz: b0c8afbcf2b7ff19fa513446155e97bc27182d75244e2652ab52f557123d1539cd160720d659452fded8b9836f5d4eed9945d7f50cab7f79263a5d335dcdcf00
7
+ data.tar.gz: be74e32b09f5499e75f2bdad040966f7166fb1bbcd00198f25e852596c0a54217e2fc06c880962f4cbff006d46737848322de87b90f516ec1e702297a81b32a6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # salsify_rubocop
2
2
 
3
+ ## v0.48.1
4
+ - Add `Salsify/RailsApplicationMailer` cop.
5
+
3
6
  ## v0.48.0
4
7
  - Add `Salsify/RspecDotNotSelfDot` cop.
5
8
  - Add `Salsify/RailsApplicationSerializer` cop.
@@ -7,5 +7,8 @@ AllCops:
7
7
  Rails/HttpPositionalArguments:
8
8
  Enabled: true
9
9
 
10
+ Salsify/RailsApplicationMailer:
11
+ Enabled: true
12
+
10
13
  Salsify/RailsApplicationRecord:
11
14
  Enabled: true
data/config/default.yml CHANGED
@@ -2,6 +2,10 @@ Salsify/RailsApplicationSerializer:
2
2
  Description: 'Serializers must subclass ApplicationSerializer.'
3
3
  Enabled: false
4
4
 
5
+ Salsify/RailsApplicationMailer:
6
+ Description: 'Mailers must subclass ApplicationMailer.'
7
+ Enabled: false
8
+
5
9
  Salsify/RailsApplicationRecord:
6
10
  Description: 'Models must subclass ApplicationRecord.'
7
11
  Enabled: false
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubocop'
4
+
5
+ module RuboCop
6
+ module Cop
7
+ module Salsify
8
+ # Check that mailers subclass ApplicationMailer with Rails 5.0
9
+ #
10
+ # @example
11
+ #
12
+ # # good
13
+ # class Tesla < ApplicationMailer
14
+ # ...
15
+ # end
16
+ #
17
+ # # bad
18
+ # class Yugo < ActionMailer::Base
19
+ # ...
20
+ # end
21
+ class RailsApplicationMailer < Cop
22
+
23
+ MSG = 'Mailers must subclass ApplicationMailer'.freeze
24
+ APPLICATION_MAILER = 'ApplicationMailer'.freeze
25
+ ACTIVE_MAILER_BASE_PATTERN = '(const (const nil :ActionMailer) :Base)'.freeze
26
+
27
+ def_node_matcher :mailer_class_definition, <<-PATTERN
28
+ (class (const _ !:ApplicationMailer) #{ACTIVE_MAILER_BASE_PATTERN} ...)
29
+ PATTERN
30
+
31
+ def_node_matcher :class_new_definition, <<-PATTERN
32
+ [!^(casgn nil :ApplicationMailer ...) (send (const nil :Class) :new #{ACTIVE_MAILER_BASE_PATTERN})]
33
+ PATTERN
34
+
35
+ def on_class(node)
36
+ mailer_class_definition(node) do
37
+ add_offense(node.children[1], :expression, MSG)
38
+ end
39
+ end
40
+
41
+ def on_send(node)
42
+ class_new_definition(node) do
43
+ add_offense(node.children.last, :expression, MSG)
44
+ end
45
+ end
46
+
47
+ def autocorrect(node)
48
+ lambda do |corrector|
49
+ corrector.replace(node.source_range, APPLICATION_MAILER)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ 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_mailer'
16
17
  require 'rubocop/cop/salsify/rails_application_serializer'
17
18
  require 'rubocop/cop/salsify/rails_application_record'
18
19
  require 'rubocop/cop/salsify/rspec_doc_string'
@@ -1,3 +1,3 @@
1
1
  module SalsifyRubocop
2
- VERSION = '0.48.0'.freeze
2
+ VERSION = '0.48.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.48.0
4
+ version: 0.48.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-04-11 00:00:00.000000000 Z
11
+ date: 2017-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,6 +103,7 @@ files:
103
103
  - conf/rubocop_rails50.yml
104
104
  - conf/rubocop_without_rspec.yml
105
105
  - config/default.yml
106
+ - lib/rubocop/cop/salsify/rails_application_mailer.rb
106
107
  - lib/rubocop/cop/salsify/rails_application_record.rb
107
108
  - lib/rubocop/cop/salsify/rails_application_serializer.rb
108
109
  - lib/rubocop/cop/salsify/rspec_doc_string.rb