simplycop 1.1.1 → 1.4.2

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
  SHA256:
3
- metadata.gz: a54a114f25c519f0cbec8e857770ff428ea51a1148b5eb3ce719388541b8c647
4
- data.tar.gz: b75b736960f350917d6422d71bfb9da64827d054679bd589ff43e077818894db
3
+ metadata.gz: 88f566a01241a5651bbeee6ab969274e2aaddc7ae5d202a5178e69ddfb777442
4
+ data.tar.gz: 6d0ae21a2f04e4a78e3abb43ae04fca74109fb84732a67d918d5c511e2465f78
5
5
  SHA512:
6
- metadata.gz: e13383ca8dd858a47d623680a5a1cb792bac2a4046c91b26be909499d26910d8e0a8afd830d5eb69ac88d4f569ab2ce60069842610ccbda03cd920c09859f23a
7
- data.tar.gz: 48ef17ec00705a490c3541fa661afc04a225c8f688831c2c8f1f8d12564abc6dd0b3c02b0f35c81989655c9b3253aceca4e7267efbfd554456b335375abe9325
6
+ metadata.gz: a0c1d3b1ab76fedf742d219b0b8c8c19380634ae2e5b0886ffbe41709e0b6a64184e4f87efae1c20fafacfe3b5b2916574b1bcddca7d47ca7c206093ffa2f5f0
7
+ data.tar.gz: b64adedc727cfa74c539e8e221016764e89f8ea158fbfa910be89acc4d5fc39d70091e54ac4724612d4018e74a6f52fc2678927876e901e3430696405aa29f03
@@ -1,5 +1,6 @@
1
1
  require:
2
2
  - './lib/simplycop/custom_cops/timecop_without_block.rb'
3
+ - './lib/simplycop/custom_cops/dont_print_all_env.rb'
3
4
 
4
5
  AllCops:
5
6
  ExtraDetails: true
@@ -9,3 +10,8 @@ CustomCops/TimecopWithoutBlock:
9
10
  Details: >-
10
11
  Time in all tests is faked to be midday. Using `Timecop.return` rather than the block format will spoil that for all subsequent tests.
11
12
  `https://github.com/simplybusiness/chopin/pull/10607`
13
+
14
+ CustomCops/DontPrintAllEnv:
15
+ Enabled: true
16
+ Details: >-
17
+ This cop checks if someone accidentally print all environment variables as they may contain secrets.
@@ -0,0 +1,18 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "05:00"
8
+ open-pull-requests-limit: 99
9
+ labels:
10
+ - dependencies
11
+ - package-ecosystem: github-actions
12
+ directory: "/"
13
+ schedule:
14
+ interval: daily
15
+ time: "05:00"
16
+ open-pull-requests-limit: 99
17
+ labels:
18
+ - dependencies
@@ -11,7 +11,7 @@ jobs:
11
11
  runs-on: ubuntu-18.04
12
12
 
13
13
  steps:
14
- - uses: simplybusiness/version-forget-me-not@v1
14
+ - uses: simplybusiness/version-forget-me-not@v2
15
15
  env:
16
16
  ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17
17
  VERSION_FILE_PATH: "lib/simplycop/version.rb"
@@ -18,6 +18,7 @@ AllCops:
18
18
  DisplayStyleGuide: true
19
19
  UseCache: true
20
20
  MaxFilesInCache: 5000
21
+ ExtraDetails: true
21
22
  # Adapted from: https://github.com/simplybusiness/how-we-roll/blob/master/development/RUBYSTYLEGUIDE.markdown
22
23
 
23
24
  Naming/VariableName:
@@ -130,7 +131,7 @@ Layout/CaseIndentation:
130
131
  Enabled: true
131
132
 
132
133
  Style/MethodDefParentheses:
133
- Enabled: false
134
+ Enabled: true
134
135
 
135
136
  Style/MultilineTernaryOperator:
136
137
  Enabled: true
@@ -216,6 +217,10 @@ Style/LambdaCall:
216
217
  Metrics/ModuleLength:
217
218
  Enabled: true
218
219
 
220
+ Metrics/BlockLength:
221
+ Exclude:
222
+ - spec/**/*.rb
223
+
219
224
  Style/For:
220
225
  Enabled: true
221
226
 
@@ -246,10 +251,10 @@ Style/HashEachMethods:
246
251
  Enabled: false
247
252
 
248
253
  Style/HashTransformKeys:
249
- Enabled: false
254
+ Enabled: true
250
255
 
251
256
  Style/HashTransformValues:
252
- Enabled: false
257
+ Enabled: true
253
258
 
254
259
  Layout/EmptyLinesAroundAttributeAccessor:
255
260
  Enabled: true
@@ -1,64 +1,20 @@
1
1
  require:
2
2
  - rubocop-rails
3
3
 
4
- AllCops:
5
- Exclude:
6
- - 'db/schema.rb'
7
- - 'vendor/**/*'
8
-
9
- # Cop names are not displayed in offense messages by default. Change behavior
10
- # by overriding DisplayCopNames, or by giving the -D/--display-cop-names
11
- # option.
12
- DisplayCopNames: true
13
- # Style guide URLs are not displayed in offense messages by default. Change
14
- # behavior by overriding DisplayStyleGuide, or by giving the
15
- # -S/--display-style-guide option.
16
- DisplayStyleGuide: true
17
- UseCache: true
18
- MaxFilesInCache: 5000
19
- # Adapted from: https://github.com/simplybusiness/how-we-roll/blob/master/development/RUBYSTYLEGUIDE.markdown
20
-
21
- Rails:
22
- Enabled: true
23
-
24
- ## Rails Cops
25
- Rails/TimeZone:
26
- Enabled: true
27
- Severity: warning
28
-
29
- Rails/Date:
30
- Enabled: true
31
- Severity: warning
32
-
33
- Rails/Delegate:
34
- Enabled: false
35
-
36
- Rails/Output:
37
- Enabled: true
38
-
39
- Rails/Validation:
40
- Enabled: true
41
-
42
- Rails/FindBy:
43
- Enabled: true
44
-
45
- Rails/ActionFilter:
46
- Enabled: true
47
-
48
- Rails/ReadWriteAttribute:
4
+ Rails/ActiveRecordCallbacksOrder:
49
5
  Enabled: true
50
6
 
51
- Rails/PluralizationGrammar:
7
+ Rails/AfterCommitOverride:
52
8
  Enabled: true
53
9
 
54
- Rails/SkipsModelValidations:
10
+ Rails/AttributeDefaultBlockValue:
55
11
  Enabled: true
56
12
 
57
- Rails/ActiveRecordCallbacksOrder:
13
+ Rails/DefaultScope:
58
14
  Enabled: true
59
15
 
60
- Rails/AfterCommitOverride:
61
- Enabled: true
16
+ Rails/Delegate:
17
+ Enabled: false
62
18
 
63
19
  Rails/FindById:
64
20
  Enabled: true
@@ -75,9 +31,11 @@ Rails/MatchRoute:
75
31
  Rails/NegateInclude:
76
32
  Enabled: true
77
33
 
34
+ # Conflicts with Mongoid
78
35
  Rails/Pluck:
79
36
  Enabled: false
80
37
 
38
+ # Conflicts with Mongoid
81
39
  Rails/PluckInWhere:
82
40
  Enabled: false
83
41
 
@@ -93,8 +51,13 @@ Rails/ShortI18n:
93
51
  Rails/SquishedSQLHeredocs:
94
52
  Enabled: true
95
53
 
54
+ Rails/WhereEquals:
55
+ Enabled: true
56
+
57
+ # Conflicts with Mongoid
96
58
  Rails/WhereExists:
97
59
  Enabled: false
98
60
 
61
+ # Conflicts with Mongoid
99
62
  Rails/WhereNot:
100
63
  Enabled: false
@@ -1,234 +1,48 @@
1
1
  require:
2
2
  - rubocop-rspec
3
3
 
4
- RSpec/ContextMethod:
5
- Enabled: false
6
-
7
- RSpec/LeakyConstantDeclaration:
8
- Enabled: false
9
-
10
- RSpec/EmptyLineAfterExample:
11
- Enabled: false
12
-
13
- RSpec/AnyInstance:
14
- Description: Check that instances are not being stubbed globally.
15
- Enabled: true
16
-
17
- RSpec/AroundBlock:
18
- Description: Checks that around blocks actually run the test.
19
- Enabled: true
20
-
21
- RSpec/BeEql:
22
- Description: Check for expectations where `be(...)` can replace `eql(...)`.
23
- Enabled: true
24
-
25
4
  RSpec/BeforeAfterAll:
26
- Description: Check that before/after(:all) isn't being used.
27
5
  Enabled: false
28
6
 
29
7
  RSpec/DescribeClass:
30
- Description: Check that the first argument to the top level describe is a constant.
31
- Enabled: false
32
-
33
- RSpec/DescribedClass:
34
- Description: Checks that tests use `described_class`.
35
- SkipBlocks: false
36
8
  Enabled: false
37
- EnforcedStyle: described_class
38
- SupportedStyles:
39
- - described_class
40
- - explicit
41
9
 
42
10
  RSpec/DescribeMethod:
43
- Description: Checks that the second argument to `describe` specifies a method.
44
- Enabled: false
45
-
46
- RSpec/DescribeSymbol:
47
- Description: Avoid describing symbols.
48
11
  Enabled: false
49
12
 
50
- RSpec/IteratedExpectation:
51
- Description: Check that `all` matcher is used instead of iterating over an array.
52
- Enabled: true
53
-
54
- RSpec/EmptyExampleGroup:
55
- Description: Checks if an example group does not include any tests.
56
- Enabled: true
57
-
58
- RSpec/EmptyLineAfterFinalLet:
59
- Description: Checks if there is an empty line after the last let block.
60
- Enabled: false
61
-
62
- RSpec/EmptyLineAfterSubject:
63
- Description: Checks if there is an empty line after subject block.
13
+ RSpec/DescribedClass:
64
14
  Enabled: false
65
15
 
66
16
  RSpec/ExampleLength:
67
- Description: Checks for long examples.
68
17
  Enabled: false
69
- Max: 5
70
-
71
- RSpec/ExampleWording:
72
- Description: Checks for common mistakes in example descriptions.
73
- Enabled: true
74
- CustomTransform:
75
- be: is
76
- BE: IS
77
- have: has
78
- HAVE: HAS
79
- IgnoredWords: []
80
-
81
- RSpec/ExpectActual:
82
- Description: Checks for `expect(...)` calls containing literal values.
83
- Enabled: true
84
18
 
85
19
  RSpec/ExpectOutput:
86
- Description: Checks for opportunities to use `expect { ... }.to output`.
87
20
  Enabled: false
88
21
 
89
22
  RSpec/FilePath:
90
- Description: Checks that spec file paths are consistent with the test subject.
91
- Enabled: false
92
- CustomTransform:
93
- RuboCop: rubocop
94
- RSpec: rspec
95
- IgnoreMethods: false
96
-
97
- RSpec/Focus:
98
- Description: Checks if examples are focused.
99
- Enabled: false
100
-
101
- RSpec/HookArgument:
102
- Description: Checks the arguments passed to `before`, `around`, and `after`.
103
- Enabled: true
104
- EnforcedStyle: implicit
105
- SupportedStyles:
106
- - implicit
107
- - each
108
- - example
109
-
110
- RSpec/ImplicitExpect:
111
- Description: Check that a consistent implicit expectation style is used.
112
- Enabled: true
113
- EnforcedStyle: is_expected
114
- SupportedStyles:
115
- - is_expected
116
- - should
117
-
118
- RSpec/InstanceSpy:
119
- Description: Checks for `instance_double` used with `have_received`.
120
23
  Enabled: false
121
24
 
122
25
  RSpec/InstanceVariable:
123
- Description: Checks for instance variable usage in specs.
124
- AssignmentOnly: false
125
26
  Enabled: false
126
27
 
127
- RSpec/ItBehavesLike:
128
- Description: Checks that only one `it_behaves_like` style is used.
129
- Enabled: true
130
- EnforcedStyle: it_behaves_like
131
- SupportedStyles:
132
- - it_behaves_like
133
- - it_should_behave_like
134
-
135
- RSpec/LeadingSubject:
136
- Description: Checks for `subject` definitions that come after `let` definitions.
137
- Enabled: true
138
-
139
- RSpec/LetSetup:
140
- Description: Checks unreferenced `let!` calls being used for test setup.
141
- Enabled: true
142
-
143
- RSpec/MessageChain:
144
- Description: Check that chains of messages are not being stubbed.
145
- Enabled: true
146
-
147
- RSpec/MessageExpectation:
148
- Description: Checks for consistent message expectation style.
149
- Enabled: false
150
- EnforcedStyle: allow
151
- SupportedStyles:
152
- - allow
153
- - expect
154
-
155
28
  RSpec/MessageSpies:
156
- Description: Checks that message expectations are set using spies.
157
29
  Enabled: false
158
- EnforcedStyle: have_received
159
- SupportedStyles:
160
- - have_received
161
- - receive
162
-
163
- RSpec/MultipleDescribes:
164
- Description: Checks for multiple top level describes.
165
- Enabled: true
166
30
 
167
31
  RSpec/MultipleExpectations:
168
- Description: Checks if examples contain too many `expect` calls.
169
32
  Enabled: false
170
- Max: 1
171
33
 
172
34
  RSpec/MultipleMemoizedHelpers:
173
35
  Enabled: false
174
36
 
175
- RSpec/NamedSubject:
176
- Description: Checks for explicitly referenced test subjects.
177
- Enabled: true
178
-
179
37
  RSpec/NestedGroups:
180
- Description: Checks for nested example groups.
181
38
  Enabled: true
182
39
  Max: 4
183
40
 
184
41
  RSpec/NotToNot:
185
- Description: Checks for consistent method usage for negating expectations.
186
- EnforcedStyle: not_to
187
- SupportedStyles:
188
- - not_to
189
- - to_not
190
42
  Enabled: false
191
43
 
192
- RSpec/OverwritingSetup:
193
- Enabled: true
194
- Description: Checks if there is a let/subject that overwrites an existing one.
195
-
196
- RSpec/RepeatedDescription:
197
- Enabled: true
198
- Description: Check for repeated description strings in example groups.
199
-
200
- RSpec/RepeatedExample:
201
- Enabled: true
202
- Description: Check for repeated examples within example groups.
203
-
204
- RSpec/SharedContext:
205
- Description: Checks for proper shared_context and shared_examples usage.
206
- Enabled: true
207
-
208
- RSpec/SingleArgumentMessageChain:
209
- Description: Checks that chains of messages contain more than one element.
210
- Enabled: true
211
-
212
- RSpec/ScatteredLet:
213
- Description: Checks for let scattered across the example group.
214
- Enabled: true
215
-
216
44
  RSpec/ScatteredSetup:
217
- Description: Checks for setup scattered across multiple hooks in an example group.
218
- Enabled: false
219
-
220
- RSpec/SubjectStub:
221
- Description: Checks for stubbed test subjects.
222
- Enabled: true
223
-
224
- RSpec/VerifiedDoubles:
225
- Description: Prefer using verifying doubles over normal doubles.
226
45
  Enabled: false
227
- IgnoreSymbolicNames: true
228
-
229
- Metrics/BlockLength:
230
- Exclude:
231
- - 'spec/**/*.rb'
232
46
 
233
47
  RSpec/StubbedMock:
234
48
  Enabled: false
@@ -3,9 +3,6 @@ require:
3
3
  - './lib/simplycop/security/reject_all_requests_local.rb'
4
4
  - './lib/simplycop/security/check_for_vulnerable_code.rb'
5
5
 
6
- AllCops:
7
- ExtraDetails: true
8
-
9
6
  Security/CSRFTokenValidation:
10
7
  Enabled: true
11
8
  Details: >-
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CustomCops
4
+ class DontPrintAllEnv < RuboCop::Cop::Cop
5
+ # This cop checks if someone accidentally print all environment variables
6
+ # because some of them may contain secrets.
7
+ #
8
+ # @example
9
+ # # bad
10
+ # puts ENV.to_h
11
+ # puts `env`
12
+ # puts ENVIRON.to_h
13
+ #
14
+ # # good
15
+ # puts ENV['SOME_KEY']
16
+ # puts ENVIRON['SOME_KEY']
17
+ MSG = 'Printing all Environment Variables is extremely risky'\
18
+ ' If this code has been run, then it is likely that secrets have been'\
19
+ ' exposed in plaintext. Please alert `#infosec` about this so it can be'\
20
+ ' investigated immediately.'\
21
+
22
+ def_node_matcher :convert_env_to_hash_or_array?, <<~PATTERN
23
+ (send (const nil? {:ENVIRON :ENV}) {:to_h :to_a :to_hash})
24
+ PATTERN
25
+
26
+ def_node_matcher :print_all_env_shell?, <<~PATTERN
27
+ (send nil? {:puts :p :print} (xstr(str "env")))
28
+ PATTERN
29
+
30
+ def on_send(node)
31
+ return unless convert_env_to_hash_or_array?(node) || print_all_env_shell?(node)
32
+
33
+ add_offense(node, location: :selector)
34
+ end
35
+ end
36
+ end
@@ -7,5 +7,5 @@
7
7
  #
8
8
 
9
9
  module Simplycop
10
- VERSION = '1.1.1'
10
+ VERSION = '1.4.2'
11
11
  end
@@ -17,9 +17,9 @@ Gem::Specification.new do |spec|
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
18
  spec.require_paths = ['lib']
19
19
 
20
- spec.add_dependency 'rubocop', '~> 1.5.2'
21
- spec.add_dependency 'rubocop-rails', '~> 2.8.1'
22
- spec.add_dependency 'rubocop-rspec', '~> 2.0.1'
20
+ spec.add_dependency 'rubocop', '~> 1.6.1'
21
+ spec.add_dependency 'rubocop-rails', '~> 2.9.0'
22
+ spec.add_dependency 'rubocop-rspec', '~> 2.1.0'
23
23
  spec.add_development_dependency 'bundler'
24
24
  spec.add_development_dependency 'rake', '>= 12.3.3'
25
25
  spec.add_development_dependency 'rspec', '~> 3.10'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplycop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simply Business
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-09 00:00:00.000000000 Z
11
+ date: 2021-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.5.2
19
+ version: 1.6.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.5.2
26
+ version: 1.6.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubocop-rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.8.1
33
+ version: 2.9.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.8.1
40
+ version: 2.9.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rubocop-rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 2.0.1
47
+ version: 2.1.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 2.0.1
54
+ version: 2.1.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -103,6 +103,7 @@ extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
105
  - ".custom_simplycop.yml"
106
+ - ".github/dependabot.yml"
106
107
  - ".github/workflows/ci.yml"
107
108
  - ".github/workflows/publish_gem.yml"
108
109
  - ".github/workflows/version_forget_me_not.yml"
@@ -124,6 +125,7 @@ files:
124
125
  - lib/simplycop.rb
125
126
  - lib/simplycop/custom_cops/constantize.rb
126
127
  - lib/simplycop/custom_cops/define_method.rb
128
+ - lib/simplycop/custom_cops/dont_print_all_env.rb
127
129
  - lib/simplycop/custom_cops/instance_eval.rb
128
130
  - lib/simplycop/custom_cops/method_missing.rb
129
131
  - lib/simplycop/custom_cops/timecop_without_block.rb