salsify_rubocop 0.48.0 → 0.48.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 +4 -4
- data/CHANGELOG.md +3 -0
- data/conf/rubocop_rails50.yml +3 -0
- data/config/default.yml +4 -0
- data/lib/rubocop/cop/salsify/rails_application_mailer.rb +55 -0
- data/lib/salsify_rubocop.rb +1 -0
- data/lib/salsify_rubocop/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1168006be538d22e3437ab541c048e7b6d16502e
|
4
|
+
data.tar.gz: 1f27eaee901f052080f61c69d6fe10f00e6908e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0c8afbcf2b7ff19fa513446155e97bc27182d75244e2652ab52f557123d1539cd160720d659452fded8b9836f5d4eed9945d7f50cab7f79263a5d335dcdcf00
|
7
|
+
data.tar.gz: be74e32b09f5499e75f2bdad040966f7166fb1bbcd00198f25e852596c0a54217e2fc06c880962f4cbff006d46737848322de87b90f516ec1e702297a81b32a6
|
data/CHANGELOG.md
CHANGED
data/conf/rubocop_rails50.yml
CHANGED
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
|
data/lib/salsify_rubocop.rb
CHANGED
@@ -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'
|
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.
|
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
|
+
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
|