salsify_rubocop 0.48.1 → 0.52.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +4 -3
- data/CHANGELOG.md +3 -0
- data/conf/rubocop.yml +3 -0
- data/conf/rubocop_without_rspec.yml +13 -13
- data/lib/rubocop/cop/salsify/rails_application_mailer.rb +8 -27
- data/lib/rubocop/cop/salsify/rails_application_serializer.rb +20 -27
- data/lib/rubocop/cop/salsify/rspec_doc_string.rb +6 -15
- data/lib/rubocop/cop/salsify/rspec_dot_not_self_dot.rb +1 -3
- data/lib/rubocop/cop/salsify/rspec_string_literals.rb +5 -3
- data/lib/rubocop/cop/salsify/style_dig.rb +4 -4
- data/lib/salsify_rubocop.rb +0 -1
- data/lib/salsify_rubocop/version.rb +1 -1
- data/salsify_rubocop.gemspec +2 -4
- metadata +7 -8
- data/lib/rubocop/cop/salsify/rails_application_record.rb +0 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 711fd8590c32360212eb79475aed75fa3c9005be72bd22c2a65c4499ed0a9eb5
|
4
|
+
data.tar.gz: 8dedaaccd58cdffb7943dbbcf32e6454bcb77d99a95f2428066ebcdb8008ea32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c471766fc309ae3115177dce42b057c5fa18a6bffd1f0f47dc88b5b4cdb906d8ecac815873d4c6a9f6a204cfa898585db3588cff32b71d1340b7ac8714169c78
|
7
|
+
data.tar.gz: 1ef6635f33167b36b2e0b72995939a9e31f0c97dba606290eac0c76c0eb195a599a6870b3226d9551a98d87a7d5a43252ca1fd14b8571747fcf640092d743629
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/conf/rubocop.yml
CHANGED
@@ -22,7 +22,7 @@ Performance/RedundantMerge:
|
|
22
22
|
Style/Alias:
|
23
23
|
EnforcedStyle: prefer_alias_method
|
24
24
|
|
25
|
-
|
25
|
+
Layout/AlignHash:
|
26
26
|
Enabled: false
|
27
27
|
|
28
28
|
Style/Documentation:
|
@@ -39,19 +39,19 @@ Style/EachForSimpleLoop:
|
|
39
39
|
Style/EachWithObject:
|
40
40
|
Enabled: false
|
41
41
|
|
42
|
-
|
42
|
+
Layout/EmptyLines:
|
43
43
|
Enabled: false
|
44
44
|
|
45
|
-
|
45
|
+
Layout/EmptyLinesAroundBlockBody:
|
46
46
|
Enabled: false
|
47
47
|
|
48
|
-
|
48
|
+
Layout/EmptyLinesAroundClassBody:
|
49
49
|
Enabled: false
|
50
50
|
|
51
|
-
|
51
|
+
Layout/EmptyLinesAroundModuleBody:
|
52
52
|
Enabled: false
|
53
53
|
|
54
|
-
|
54
|
+
Layout/EmptyLinesAroundMethodBody:
|
55
55
|
Enabled: false
|
56
56
|
|
57
57
|
Style/EmptyLiteral:
|
@@ -62,7 +62,7 @@ Style/EmptyMethod:
|
|
62
62
|
|
63
63
|
# The Exclude list is not additive. Projects that exclude file names will
|
64
64
|
# need to re-add Appraisals.
|
65
|
-
|
65
|
+
Naming/FileName:
|
66
66
|
Exclude:
|
67
67
|
- 'Appraisals'
|
68
68
|
|
@@ -73,7 +73,7 @@ Style/GuardClause:
|
|
73
73
|
Enabled: false
|
74
74
|
|
75
75
|
# does not make sense to enable this without AlignHash
|
76
|
-
|
76
|
+
Layout/IndentHash:
|
77
77
|
Enabled: false
|
78
78
|
|
79
79
|
Style/Lambda:
|
@@ -85,13 +85,13 @@ Style/ModuleFunction:
|
|
85
85
|
Style/MultilineBlockChain:
|
86
86
|
Enabled: false
|
87
87
|
|
88
|
-
|
88
|
+
Layout/MultilineMethodCallIndentation:
|
89
89
|
Enabled: false
|
90
90
|
|
91
|
-
|
91
|
+
Layout/MultilineOperationIndentation:
|
92
92
|
Enabled: false
|
93
93
|
|
94
|
-
|
94
|
+
Layout/MultilineBlockLayout:
|
95
95
|
Enabled: false
|
96
96
|
|
97
97
|
# This cop complains about values like 05.
|
@@ -126,7 +126,7 @@ Style/SingleLineBlockParams:
|
|
126
126
|
|
127
127
|
# This cop doesn't work properly if you a have a block with
|
128
128
|
# arguments split across multiple lines
|
129
|
-
|
129
|
+
Layout/SpaceAroundBlockParameters:
|
130
130
|
Enabled: false
|
131
131
|
|
132
132
|
Style/StringLiterals:
|
@@ -138,7 +138,7 @@ Style/StringLiterals:
|
|
138
138
|
Style/SymbolArray:
|
139
139
|
Enabled: false
|
140
140
|
|
141
|
-
|
141
|
+
Naming/VariableNumber:
|
142
142
|
Enabled: false
|
143
143
|
|
144
144
|
Metrics/AbcSize:
|
@@ -1,11 +1,7 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'rubocop'
|
4
|
-
|
5
1
|
module RuboCop
|
6
2
|
module Cop
|
7
3
|
module Salsify
|
8
|
-
# Check that mailers subclass ApplicationMailer with Rails 5.0
|
4
|
+
# Check that mailers subclass ApplicationMailer with Rails 5.0.
|
9
5
|
#
|
10
6
|
# @example
|
11
7
|
#
|
@@ -19,34 +15,19 @@ module RuboCop
|
|
19
15
|
# ...
|
20
16
|
# end
|
21
17
|
class RailsApplicationMailer < Cop
|
18
|
+
extend TargetRailsVersion
|
22
19
|
|
23
|
-
|
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
|
20
|
+
minimum_target_rails_version 5.0
|
34
21
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
22
|
+
MSG = 'Mailers should subclass `ApplicationMailer`.'.freeze
|
23
|
+
SUPERCLASS = 'ApplicationMailer'.freeze
|
24
|
+
BASE_PATTERN = '(const (const nil? :ActionMailer) :Base)'.freeze
|
40
25
|
|
41
|
-
|
42
|
-
class_new_definition(node) do
|
43
|
-
add_offense(node.children.last, :expression, MSG)
|
44
|
-
end
|
45
|
-
end
|
26
|
+
include RuboCop::Cop::EnforceSuperclass
|
46
27
|
|
47
28
|
def autocorrect(node)
|
48
29
|
lambda do |corrector|
|
49
|
-
corrector.replace(node.source_range,
|
30
|
+
corrector.replace(node.source_range, self.class::SUPERCLASS)
|
50
31
|
end
|
51
32
|
end
|
52
33
|
end
|
@@ -1,40 +1,33 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'rubocop'
|
4
|
-
|
5
1
|
module RuboCop
|
6
2
|
module Cop
|
7
3
|
module Salsify
|
8
|
-
# Check that serializers subclass ApplicationSerializer
|
4
|
+
# Check that serializers subclass ApplicationSerializer with Rails 5.0.
|
5
|
+
#
|
6
|
+
# @example
|
7
|
+
#
|
8
|
+
# # good
|
9
|
+
# class Tesla < ApplicationSerializer
|
10
|
+
# ...
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# # bad
|
14
|
+
# class Yugo < ActiveModel::Serializer
|
15
|
+
# ...
|
16
|
+
# end
|
9
17
|
class RailsApplicationSerializer < Cop
|
18
|
+
extend TargetRailsVersion
|
10
19
|
|
11
|
-
|
12
|
-
APPLICATION_SERIALIZER = 'ApplicationSerializer'.freeze
|
13
|
-
ACTIVE_MODEL_SERIALIZER_PATTERN = '(const (const nil :ActiveModel) :Serializer)'.freeze
|
14
|
-
|
15
|
-
def_node_matcher :serializer_class_definition, <<-PATTERN
|
16
|
-
(class (const _ !:ApplicationSerializer) #{ACTIVE_MODEL_SERIALIZER_PATTERN} ...)
|
17
|
-
PATTERN
|
18
|
-
|
19
|
-
def_node_matcher :class_new_definition, <<-PATTERN
|
20
|
-
[!^(casgn nil :ApplicationSerializer ...) (send (const nil :Class) :new #{ACTIVE_MODEL_SERIALIZER_PATTERN})]
|
21
|
-
PATTERN
|
20
|
+
minimum_target_rails_version 5.0
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
22
|
+
MSG = 'Serializers should subclass `ApplicationSerializer`.'.freeze
|
23
|
+
SUPERCLASS = 'ApplicationSerializer'.freeze
|
24
|
+
BASE_PATTERN = '(const (const nil? :ActiveModel) :Serializer)'.freeze
|
28
25
|
|
29
|
-
|
30
|
-
class_new_definition(node) do
|
31
|
-
add_offense(node.children.last, :expression, MSG)
|
32
|
-
end
|
33
|
-
end
|
26
|
+
include RuboCop::Cop::EnforceSuperclass
|
34
27
|
|
35
28
|
def autocorrect(node)
|
36
29
|
lambda do |corrector|
|
37
|
-
corrector.replace(node.source_range,
|
30
|
+
corrector.replace(node.source_range, self.class::SUPERCLASS)
|
38
31
|
end
|
39
32
|
end
|
40
33
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module RuboCop
|
4
2
|
module Cop
|
5
3
|
module Salsify
|
@@ -44,14 +42,18 @@ module RuboCop
|
|
44
42
|
check_quotes(args.first)
|
45
43
|
end
|
46
44
|
|
45
|
+
def autocorrect(node)
|
46
|
+
StringLiteralCorrector.correct(node, style)
|
47
|
+
end
|
48
|
+
|
47
49
|
private
|
48
50
|
|
49
51
|
def check_quotes(doc_node)
|
50
52
|
if wrong_quotes?(doc_node)
|
51
53
|
if style == :single_quotes
|
52
|
-
add_offense(doc_node, :
|
54
|
+
add_offense(doc_node, message: SINGLE_QUOTE_MSG)
|
53
55
|
else
|
54
|
-
add_offense(doc_node, :
|
56
|
+
add_offense(doc_node, message: DOUBLE_QUOTE_MSG)
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
@@ -65,17 +67,6 @@ module RuboCop
|
|
65
67
|
src !~ /^" | \\ | \#/x
|
66
68
|
end
|
67
69
|
end
|
68
|
-
|
69
|
-
def autocorrect(node)
|
70
|
-
lambda do |corrector|
|
71
|
-
str = node.str_content
|
72
|
-
if style == :single_quotes
|
73
|
-
corrector.replace(node.source_range, to_string_literal(str))
|
74
|
-
else
|
75
|
-
corrector.replace(node.source_range, str.inspect)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
70
|
end
|
80
71
|
end
|
81
72
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module RuboCop
|
4
2
|
module Cop
|
5
3
|
module Salsify
|
@@ -28,7 +26,7 @@ module RuboCop
|
|
28
26
|
|
29
27
|
def on_send(node)
|
30
28
|
example_group_match(node) do |doc|
|
31
|
-
add_offense(doc
|
29
|
+
add_offense(doc) if SELF_DOT_REGEXP =~ doc.source
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module RuboCop
|
4
2
|
module Cop
|
5
3
|
module Salsify
|
@@ -22,9 +20,13 @@ module RuboCop
|
|
22
20
|
DOUBLE_QUOTE_MSG = 'Prefer double-quoted strings unless you need ' \
|
23
21
|
'single quotes to avoid extra backslashes for escaping.'.freeze
|
24
22
|
|
23
|
+
def autocorrect(node)
|
24
|
+
StringLiteralCorrector.correct(node, style)
|
25
|
+
end
|
26
|
+
|
25
27
|
private
|
26
28
|
|
27
|
-
def message(
|
29
|
+
def message(_node)
|
28
30
|
style == :single_quotes ? SINGLE_QUOTE_MSG : DOUBLE_QUOTE_MSG
|
29
31
|
end
|
30
32
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# This may be added in the near future to rubocop, see https://github.com/bbatsov/rubocop/issues/5332
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
@@ -32,16 +32,16 @@ module RuboCop
|
|
32
32
|
match_node = node
|
33
33
|
# walk to outermost access node
|
34
34
|
match_node = match_node.parent while access_node?(match_node.parent)
|
35
|
-
add_offense(match_node
|
35
|
+
add_offense(match_node)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
def autocorrect(node)
|
40
40
|
access_node = node
|
41
|
-
source_args = [access_node.
|
41
|
+
source_args = [access_node.first_argument.source]
|
42
42
|
while access_node?(access_node.children.first)
|
43
43
|
access_node = access_node.children.first
|
44
|
-
source_args << access_node.
|
44
|
+
source_args << access_node.first_argument.source
|
45
45
|
end
|
46
46
|
root_node = access_node.children.first
|
47
47
|
|
data/lib/salsify_rubocop.rb
CHANGED
@@ -15,7 +15,6 @@ RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
|
|
15
15
|
# cops
|
16
16
|
require 'rubocop/cop/salsify/rails_application_mailer'
|
17
17
|
require 'rubocop/cop/salsify/rails_application_serializer'
|
18
|
-
require 'rubocop/cop/salsify/rails_application_record'
|
19
18
|
require 'rubocop/cop/salsify/rspec_doc_string'
|
20
19
|
require 'rubocop/cop/salsify/rspec_dot_not_self_dot'
|
21
20
|
require 'rubocop/cop/salsify/rspec_string_literals'
|
data/salsify_rubocop.gemspec
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
1
|
lib = File.expand_path('../lib', __FILE__)
|
4
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
3
|
require 'salsify_rubocop/version'
|
@@ -34,6 +32,6 @@ Gem::Specification.new do |spec|
|
|
34
32
|
spec.add_development_dependency 'rake', '~> 10.0'
|
35
33
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
36
34
|
|
37
|
-
spec.add_runtime_dependency 'rubocop', '~> 0.
|
38
|
-
spec.add_runtime_dependency 'rubocop-rspec', '~> 1.
|
35
|
+
spec.add_runtime_dependency 'rubocop', '~> 0.52.1'
|
36
|
+
spec.add_runtime_dependency 'rubocop-rspec', '~> 1.21.0'
|
39
37
|
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.
|
4
|
+
version: 0.52.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:
|
11
|
+
date: 2018-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,28 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.52.1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.52.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubocop-rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
75
|
+
version: 1.21.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
82
|
+
version: 1.21.0
|
83
83
|
description: Shared shared RuboCop configuration
|
84
84
|
email:
|
85
85
|
- engineering@salsify.com
|
@@ -104,7 +104,6 @@ files:
|
|
104
104
|
- conf/rubocop_without_rspec.yml
|
105
105
|
- config/default.yml
|
106
106
|
- lib/rubocop/cop/salsify/rails_application_mailer.rb
|
107
|
-
- lib/rubocop/cop/salsify/rails_application_record.rb
|
108
107
|
- lib/rubocop/cop/salsify/rails_application_serializer.rb
|
109
108
|
- lib/rubocop/cop/salsify/rspec_doc_string.rb
|
110
109
|
- lib/rubocop/cop/salsify/rspec_dot_not_self_dot.rb
|
@@ -135,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
134
|
version: '0'
|
136
135
|
requirements: []
|
137
136
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.7.3
|
139
138
|
signing_key:
|
140
139
|
specification_version: 4
|
141
140
|
summary: Shared shared RuboCop configuration
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'rubocop'
|
4
|
-
|
5
|
-
module RuboCop
|
6
|
-
module Cop
|
7
|
-
module Salsify
|
8
|
-
# Check that models subclass ApplicationRecord with Rails 5.0
|
9
|
-
#
|
10
|
-
# @example
|
11
|
-
#
|
12
|
-
# # good
|
13
|
-
# class Tesla < ApplicationRecord
|
14
|
-
# ...
|
15
|
-
# end
|
16
|
-
#
|
17
|
-
# # bad
|
18
|
-
# class Yugo < ActiveRecord::Base
|
19
|
-
# ...
|
20
|
-
# end
|
21
|
-
class RailsApplicationRecord < Cop
|
22
|
-
|
23
|
-
MSG = 'Models must subclass ApplicationRecord'.freeze
|
24
|
-
APPLICATION_RECORD = 'ApplicationRecord'.freeze
|
25
|
-
ACTIVE_RECORD_BASE_PATTERN = '(const (const nil :ActiveRecord) :Base)'.freeze
|
26
|
-
|
27
|
-
def_node_matcher :model_class_definition, <<-PATTERN
|
28
|
-
(class (const _ !:ApplicationRecord) #{ACTIVE_RECORD_BASE_PATTERN} ...)
|
29
|
-
PATTERN
|
30
|
-
|
31
|
-
def_node_matcher :class_new_definition, <<-PATTERN
|
32
|
-
[!^(casgn nil :ApplicationRecord ...) (send (const nil :Class) :new #{ACTIVE_RECORD_BASE_PATTERN})]
|
33
|
-
PATTERN
|
34
|
-
|
35
|
-
def on_class(node)
|
36
|
-
model_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_RECORD)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|