salsify_rubocop 0.47.2 → 0.48.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01ddf57339e753b601e0bbbefda0a87141ee09c5
4
- data.tar.gz: 964f0c25cd592a0ca6a9949f3a4c05fa3d4630f3
3
+ metadata.gz: 5e07cf5240f0567f82de5841b7918aced03bbcd1
4
+ data.tar.gz: 5cf9381c581f64eabf2c9bd1fe5d1dfd08c2e191
5
5
  SHA512:
6
- metadata.gz: 4b5a9ed9d733e36708b4a75d14c6c82121f18eeb71fb16b542d9a8c1719a0a0580f61df67c5b793e240ab515ac4963f9adc3a90511d21e3ac3f737afb330cbec
7
- data.tar.gz: bc07f258e1f8fc671f8f0ed2e763dc072a35bbfc300821e2585d9ee7ab631dd606af31e9dc823de9de4468651708eb2b49b087fabd9ba9828f542d45a6ada720
6
+ metadata.gz: f1f8d75e6ae82ce709e174d327b0008520182f7f9af9ac5d79c1e2fa6df9604c1eeca592ad83502e658ffcffde33d47c77c531f8129c98dbda5e3bb6863f35f0
7
+ data.tar.gz: 0c093a80290aedf6bee8ba31858b32744b440f7d52d6b4487e0b2734a9ec0f3aeb6414dbdeb6fdc27a23052545e5f5b4fc2bb2d909d72f8cf6c770742b53f67a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # salsify_rubocop
2
2
 
3
+ ## v0.48.0
4
+ - Add `Salsify/RspecDotNotSelfDot` cop.
5
+ - Add `Salsify/RailsApplicationSerializer` cop.
6
+ - Update to `rubocop` v0.48.1 and `rubocop-rspec` v1.15.0.
7
+ - Disable cops: `Lint/AmbiguousBlockAssociation`, `Style/PercentLiteralDelimiters`,
8
+ and `Style/SymbolArray`.
9
+
3
10
  ## v0.47.2
4
11
  - Fix issue for `Salsify/Style` with nested access as the target for
5
12
  conditional assignment.
@@ -1,6 +1,9 @@
1
1
  inherit_from:
2
2
  - ../conf/rubocop_rails.yml
3
3
 
4
+ AllCops:
5
+ TargetRailsVersion: 5.0
6
+
4
7
  Rails/HttpPositionalArguments:
5
8
  Enabled: true
6
9
 
@@ -9,6 +9,10 @@ AllCops:
9
9
  - 'tmp/**/*'
10
10
  - 'vendor/**/*'
11
11
 
12
+ # This cop has poor handling for the common case of a lambda arg in a DSL
13
+ Lint/AmbiguousBlockAssociation:
14
+ Enabled: false
15
+
12
16
  Lint/AmbiguousOperator:
13
17
  Enabled: false
14
18
 
@@ -56,6 +60,12 @@ Style/EmptyLiteral:
56
60
  Style/EmptyMethod:
57
61
  Enabled: false
58
62
 
63
+ # The Exclude list is not additive. Projects that exclude file names will
64
+ # need to re-add Appraisals.
65
+ Style/FileName:
66
+ Exclude:
67
+ - 'Appraisals'
68
+
59
69
  Style/FrozenStringLiteralComment:
60
70
  Enabled: false
61
71
 
@@ -92,6 +102,10 @@ Style/NumericLiteralPrefix:
92
102
  Style/NumericPredicate:
93
103
  Enabled: false
94
104
 
105
+ # This cop is unstable.
106
+ Style/PercentLiteralDelimiters:
107
+ Enabled: false
108
+
95
109
  Style/Proc:
96
110
  Enabled: false
97
111
 
@@ -120,6 +134,10 @@ Style/StringLiterals:
120
134
  Exclude:
121
135
  - 'spec/**/*'
122
136
 
137
+ # We don't require %i() for an array of symbols.
138
+ Style/SymbolArray:
139
+ Enabled: false
140
+
123
141
  Style/VariableNumber:
124
142
  Enabled: false
125
143
 
data/config/default.yml CHANGED
@@ -1,3 +1,7 @@
1
+ Salsify/RailsApplicationSerializer:
2
+ Description: 'Serializers must subclass ApplicationSerializer.'
3
+ Enabled: false
4
+
1
5
  Salsify/RailsApplicationRecord:
2
6
  Description: 'Models must subclass ApplicationRecord.'
3
7
  Enabled: false
@@ -12,6 +16,12 @@ Salsify/RspecDocString:
12
16
  Include:
13
17
  - 'spec/**/*'
14
18
 
19
+ Salsify/RspecDotNotSelfDot:
20
+ Description: 'Enforce ".<class method>" instead of "self.<class method>" for example group description.'
21
+ Enabled: true
22
+ Include:
23
+ - 'spec/**/*'
24
+
15
25
  Salsify/RspecStringLiterals:
16
26
  Description: 'Enforce consistent quote style for non-doc strings in RSpec tests.'
17
27
  Enabled: true
@@ -19,8 +29,8 @@ Salsify/RspecStringLiterals:
19
29
  SupportedStyles:
20
30
  - single_quotes
21
31
  - double_quotes
22
- # Include:
23
- # - 'spec/**/*'
32
+ Include:
33
+ - 'spec/**/*'
24
34
 
25
35
  Salsify/StyleDig:
26
36
  Description: 'Recommend `dig` for deeply nested access.'
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
+
2
3
  require 'rubocop'
4
+
3
5
  module RuboCop
4
6
  module Cop
5
7
  module Salsify
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubocop'
4
+
5
+ module RuboCop
6
+ module Cop
7
+ module Salsify
8
+ # Check that serializers subclass ApplicationSerializer
9
+ class RailsApplicationSerializer < Cop
10
+
11
+ MSG = 'Serializers must subclass ApplicationSerializer'.freeze
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
22
+
23
+ def on_class(node)
24
+ serializer_class_definition(node) do
25
+ add_offense(node.children[1], :expression, MSG)
26
+ end
27
+ end
28
+
29
+ def on_send(node)
30
+ class_new_definition(node) do
31
+ add_offense(node.children.last, :expression, MSG)
32
+ end
33
+ end
34
+
35
+ def autocorrect(node)
36
+ lambda do |corrector|
37
+ corrector.replace(node.source_range, APPLICATION_SERIALIZER)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -60,7 +60,7 @@ module RuboCop
60
60
  src = node.source
61
61
  return false if src.start_with?('%', '?')
62
62
  if style == :single_quotes
63
- src !~ /^'/ && !double_quotes_acceptable?(node.str_content)
63
+ src !~ /^'/ && !needs_escaping?(node.str_content)
64
64
  else
65
65
  src !~ /^" | \\ | \#/x
66
66
  end
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Salsify
6
+ # Use ".<class method>" instead of "self.<class method>" in RSpec example
7
+ # group descriptions.
8
+ #
9
+ # @example
10
+ #
11
+ # # good
12
+ # describe ".does_stuff" do
13
+ # ...
14
+ # end
15
+ #
16
+ # # bad
17
+ # describe "self.does_stuff" do
18
+ # ...
19
+ # end
20
+ class RspecDotNotSelfDot < Cop
21
+
22
+ SELF_DOT_REGEXP = /["']self\./
23
+ MSG = 'Use ".<class method>" instead of "self.<class method>" for example group description.'.freeze
24
+
25
+ def_node_matcher :example_group_match, <<-PATTERN
26
+ (send _ #{RuboCop::RSpec::Language::ExampleGroups::ALL.node_pattern_union} $_ ...)
27
+ PATTERN
28
+
29
+ def on_send(node)
30
+ example_group_match(node) do |doc|
31
+ add_offense(doc, :expression, MSG) if SELF_DOT_REGEXP =~ doc.source
32
+ end
33
+ end
34
+
35
+ def autocorrect(node)
36
+ lambda do |corrector|
37
+ corrector.remove(Parser::Source::Range.new(node.source_range.source_buffer,
38
+ node.source_range.begin_pos + 1,
39
+ node.source_range.begin_pos + 5))
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module SalsifyRubocop
2
- VERSION = '0.47.2'.freeze
2
+ VERSION = '0.48.0'.freeze
3
3
  end
@@ -13,7 +13,9 @@ 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_serializer'
16
17
  require 'rubocop/cop/salsify/rails_application_record'
17
18
  require 'rubocop/cop/salsify/rspec_doc_string'
19
+ require 'rubocop/cop/salsify/rspec_dot_not_self_dot'
18
20
  require 'rubocop/cop/salsify/rspec_string_literals'
19
21
  require 'rubocop/cop/salsify/style_dig'
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'salsify_rubocop/version'
@@ -33,6 +34,6 @@ Gem::Specification.new do |spec|
33
34
  spec.add_development_dependency 'rake', '~> 10.0'
34
35
  spec.add_development_dependency 'rspec', '~> 3.0'
35
36
 
36
- spec.add_runtime_dependency 'rubocop', '~> 0.47.1'
37
- spec.add_runtime_dependency 'rubocop-rspec', '~> 1.10.0'
37
+ spec.add_runtime_dependency 'rubocop', '~> 0.48.1'
38
+ spec.add_runtime_dependency 'rubocop-rspec', '~> 1.15.0'
38
39
  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.2
4
+ version: 0.48.0
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-08 00:00:00.000000000 Z
11
+ date: 2017-04-11 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.47.1
61
+ version: 0.48.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.47.1
68
+ version: 0.48.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.10.0
75
+ version: 1.15.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.10.0
82
+ version: 1.15.0
83
83
  description: Shared shared RuboCop configuration
84
84
  email:
85
85
  - engineering@salsify.com
@@ -104,7 +104,9 @@ files:
104
104
  - conf/rubocop_without_rspec.yml
105
105
  - config/default.yml
106
106
  - lib/rubocop/cop/salsify/rails_application_record.rb
107
+ - lib/rubocop/cop/salsify/rails_application_serializer.rb
107
108
  - lib/rubocop/cop/salsify/rspec_doc_string.rb
109
+ - lib/rubocop/cop/salsify/rspec_dot_not_self_dot.rb
108
110
  - lib/rubocop/cop/salsify/rspec_string_literals.rb
109
111
  - lib/rubocop/cop/salsify/style_dig.rb
110
112
  - lib/rubocop/rspec/language/each_selector.rb
@@ -132,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
134
  version: '0'
133
135
  requirements: []
134
136
  rubyforge_project:
135
- rubygems_version: 2.6.10
137
+ rubygems_version: 2.6.11
136
138
  signing_key:
137
139
  specification_version: 4
138
140
  summary: Shared shared RuboCop configuration