cobalt-rubocop 0.9.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e362d3b2d73010a79138252128e40a847240a636e0bf47b66420ff8e3fadece
4
- data.tar.gz: c3e8d123ceb792de6b5f47838b9fcc119641875f9621cd5c495c64d06ba8f493
3
+ metadata.gz: fd065596ae4e92888e92dabb5f30c1ef58420633090f455e1b8243ca29a29a9e
4
+ data.tar.gz: 0d73e78f813543da948d3da9cea85f892f8c80e02866a69ae3f133ac3a3c422b
5
5
  SHA512:
6
- metadata.gz: 62efc720640cc2f3e29504ecc0fd81eb01ace1b820d3532c336b04cd99361625a9b97bdebb45f00dea9adc9761c89f03b8d3dd6a9515fdfa7b6b9148c45a67dc
7
- data.tar.gz: ae22d0536f332f7bc4dd3a8a915424da94b215963e5c390c26570a55be26d2707f1883bc363d9e2ce7c7b3b87f40a93eb3233d8a2e14b72c695e339620063526
6
+ metadata.gz: e5f9fc4099f495a2439da30053e563eb99d18e6cd90d3b5c48cf079ee9dde5bb54b7462765ca4fb1637cb89085dc63a09723a7c418c3a2c77ac6f618696bf1e7
7
+ data.tar.gz: 2e85d5f9491e17043824a7ec9318da665cc37b4f4bd89466bf7bcec653d78e878871d3e8fb6fed5da404d87cb00882d23529d0b8da809c070423731f841fd689
data/CHANGELOG.md CHANGED
@@ -1,33 +1,79 @@
1
1
  # CHANGELOG
2
+
2
3
  ## main (unreleased)
3
4
 
5
+ ## 1.0.1 (2023-07-13)
6
+
7
+ * Disable `RSpec/ScatteredSetup` for specs inside `/api`, since it
8
+ incorrectly thinks that separate `before` blocks can be put together for
9
+ RSwag specs
10
+
11
+ * Maintenance:
12
+ * Add CI status checks
13
+ * Add dependabot
14
+ * Add required CI checks for IaaC setup
15
+
16
+ ## 1.0.0 (2023-06-09)
17
+
18
+ * Bump required ruby version to 3.2.x
19
+ * Add default settings:
20
+
21
+ ```yaml
22
+ RSpec/IndexedLet:
23
+ Enabled: false
24
+
25
+ RSpec/Rails/InferredSpecType:
26
+ Enabled: false
27
+
28
+ Style/RedundantConstantBase:
29
+ Enabled: false
30
+
31
+ Style/TrailingCommaInArguments:
32
+ EnforcedStyleForMultiline: consistent_comma
33
+
34
+ Style/TrailingCommaInArrayLiteral:
35
+ EnforcedStyleForMultiline: consistent_comma
36
+
37
+ Style/TrailingCommaInHashLiteral:
38
+ EnforcedStyleForMultiline: consistent_comma
39
+ ```
40
+
4
41
  ## 0.9.0 (2023-04-20)
42
+
5
43
  * Allow either hash syntax (legacy vs 3.1) as long as the use is consistent.
6
44
 
7
45
  ## 0.8.0 (2023-04-04)
46
+
8
47
  * Relax dependency versions
9
48
 
10
49
  ## 0.7.0 (2022-08-24)
50
+
11
51
  * Update Gem versions: ([#12](https://github.com/cobalthq/cobalt-rubocop/pull/12))
12
52
 
13
53
  ## 0.6.0 (2022-06-24)
54
+
14
55
  * Update Gem versions: ([#11](https://github.com/cobalthq/cobalt-rubocop/pull/11))
15
56
  * Security: Require Multi-Factor Authentication for RubyGems privileged operations ([#10](https://github.com/cobalthq/cobalt-rubocop/pull/10))
16
57
 
17
58
  ## 0.5.0 (2022-01-25)
59
+
18
60
  * Update Gem versions ([#8](https://github.com/cobalthq/cobalt-rubocop/pull/8))
19
61
 
20
62
  ## 0.4.0 (2021-09-07)
63
+
21
64
  * Update Gem versions ([#7](https://github.com/cobalthq/cobalt-rubocop/pull/7))
22
65
 
23
66
  ## 0.3.0 (2021-04-16)
67
+
24
68
  * Update Rubocop and Rubocop Performance versions ([#6](https://github.com/cobalthq/cobalt-rubocop/pull/6))
25
69
 
26
70
  ## 0.2.0 (2021-04-14)
71
+
27
72
  * Avoid warnings on RSpec `let` with parameter arrays ([#5](https://github.com/cobalthq/cobalt-rubocop/pull/5))
28
73
  * Add new cop `InsecureHashAlgorithm`. ([#3](https://github.com/cobalthq/cobalt-rubocop/pull/3))
29
74
 
30
75
  ## 0.1.0 (2021-02-10)
76
+
31
77
  * Introduce default rules
32
78
  * Introduce rails rules
33
79
  * Introduce rspec rules
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Cobalt RuboCop
2
+
2
3
  [![Gem Version](https://badge.fury.io/rb/cobalt-rubocop.svg)](https://badge.fury.io/rb/cobalt-rubocop)
3
4
  [![GitHub License](https://img.shields.io/github/license/cobalthq/cobalt-rubocop.svg)](https://github.com/cobalthq/cobalt-rubocop/blob/main/LICENSE)
4
5
  ![Gem Downloads](https://img.shields.io/gem/dt/cobalt-rubocop)
@@ -9,29 +10,35 @@ This repository provides recommended linting rules for Ruby repositories.
9
10
  ## Installation
10
11
 
11
12
  ### Gemfile
13
+
12
14
  #### Add
13
- ```ruby
14
- group :development do
15
- gem 'cobalt-rubocop', require: false
16
- end
17
- ```
15
+
16
+ ```ruby
17
+ group :development do
18
+ gem 'cobalt-rubocop', require: false
19
+ end
20
+ ```
18
21
 
19
22
  #### Remove
20
- ```ruby
21
- gem 'rubocop', require: false
22
- gem 'rubocop-performance', require: false
23
- gem 'rubocop-rails', require: false
24
- gem 'rubocop-rspec', require: false
25
- ```
26
23
 
27
- [Specific versions](https://github.com/cobalthq/cobalt-rubocop/blob/main/cobalt-rubocop.gemspec) installed for:
28
- - [rubocop](https://github.com/rubocop-hq/rubocop)
29
- - [rubocop-performance](https://github.com/rubocop/rubocop-performance)
30
- - [rubocop-rails](https://github.com/rubocop/rubocop-rails)
31
- - [rubocop-rspec](https://github.com/rubocop/rubocop-rspec)
24
+ ```ruby
25
+ gem 'rubocop', require: false
26
+ gem 'rubocop-performance', require: false
27
+ gem 'rubocop-rails', require: false
28
+ gem 'rubocop-rspec', require: false
29
+ ```
30
+
31
+ [Specific versions](https://github.com/cobalthq/cobalt-rubocop/blob/main/cobalt-rubocop.gemspec) installed for:
32
+
33
+ - [rubocop](https://github.com/rubocop-hq/rubocop)
34
+ - [rubocop-performance](https://github.com/rubocop/rubocop-performance)
35
+ - [rubocop-rails](https://github.com/rubocop/rubocop-rails)
36
+ - [rubocop-rspec](https://github.com/rubocop/rubocop-rspec)
32
37
 
33
38
  ### .rubocop.yml
39
+
34
40
  Configuration Options:
41
+
35
42
  ```yaml
36
43
  inherit_gem:
37
44
  cobalt-rubocop:
@@ -60,10 +67,13 @@ grep "Offense count" .rubocop_todo.yml | awk -F: '{sum+=$2} END {print sum}'
60
67
  ```
61
68
 
62
69
  ## Custom Cops
70
+
63
71
  ### InsecureHashAlgorithm
72
+
64
73
  See [Ruby Docs](https://ruby-doc.org/stdlib-2.7.2/libdoc/openssl/rdoc/OpenSSL/Digest.html) for built in hash functions.
65
74
 
66
75
  - Default Configuration:
76
+
67
77
  ```yml
68
78
  Cobalt/InsecureHashAlgorithm:
69
79
  Allowed:
@@ -86,24 +96,30 @@ See [Ruby Docs](https://ruby-doc.org/stdlib-2.7.2/libdoc/openssl/rdoc/OpenSSL/Di
86
96
  ```
87
97
 
88
98
  ## Development
99
+
89
100
  ```shell
90
101
  git clone git@github.com:cobalthq/cobalt-rubocop.git
91
102
  bundle install
92
103
  ```
93
104
 
94
105
  ### Testing locally
106
+
95
107
  In your application, use the `path` attribute to point to your local copy of the gem
108
+
96
109
  ```ruby
97
110
  # Use the relative path from your application, to the cobalt-rubocop folder
98
111
  gem 'cobalt-rubocop', path: '../cobalt-rubocop', require: false
99
112
  ```
100
113
 
101
114
  Alternatively:
115
+
102
116
  - `rake build`
103
117
  - `gem install pkg/cobalt-rubocop-<version_number>.gem`
104
118
 
105
119
  ## Publish (internal)
120
+
106
121
  > Note: Publishing a new version of this gem is only meant for maintainers.
122
+
107
123
  - Ensure you have access to publish on [rubygems](https://rubygems.org/gems/cobalt-rubocop).
108
124
  - Update [CHANGELOG](https://github.com/cobalthq/cobalt-rubocop/blob/main/CHANGELOG.md).
109
125
  - Update [`VERSION`](https://github.com/cobalthq/cobalt-rubocop/blob/main/lib/rubocop/cobalt/version.rb).
data/config/default.yml CHANGED
@@ -5,8 +5,8 @@ require:
5
5
  AllCops:
6
6
  NewCops: enable
7
7
 
8
- Naming/MethodName:
9
- EnforcedStyle: snake_case
8
+ Cobalt/InsecureHashAlgorithm:
9
+ Enabled: true
10
10
 
11
11
  Layout/ArgumentAlignment:
12
12
  EnforcedStyle: with_fixed_indentation
@@ -17,12 +17,12 @@ Layout/DotPosition:
17
17
  Layout/FirstArrayElementIndentation:
18
18
  EnforcedStyle: consistent
19
19
 
20
+ Layout/FirstHashElementIndentation:
21
+ EnforcedStyle: consistent
22
+
20
23
  Layout/LineLength:
21
24
  Enabled: false
22
25
 
23
- Layout/ParameterAlignment:
24
- EnforcedStyle: with_fixed_indentation
25
-
26
26
  Layout/SpaceInsideHashLiteralBraces:
27
27
  EnforcedStyle: no_space
28
28
 
@@ -32,14 +32,17 @@ Layout/MultilineOperationIndentation:
32
32
  Layout/MultilineMethodCallIndentation:
33
33
  EnforcedStyle: indented
34
34
 
35
- Layout/FirstHashElementIndentation:
36
- EnforcedStyle: consistent
35
+ Layout/ParameterAlignment:
36
+ EnforcedStyle: with_fixed_indentation
37
+
38
+ Metrics/AbcSize:
39
+ Enabled: false
37
40
 
38
41
  Metrics/MethodLength:
39
42
  Max: 20
40
43
 
41
- Metrics/AbcSize:
42
- Enabled: false
44
+ Naming/MethodName:
45
+ EnforcedStyle: snake_case
43
46
 
44
47
  Style/ClassAndModuleChildren:
45
48
  EnforcedStyle: nested
@@ -59,8 +62,17 @@ Style/HashSyntax:
59
62
  Style/IfUnlessModifier:
60
63
  Enabled: false
61
64
 
62
- Cobalt/InsecureHashAlgorithm:
63
- Enabled: true
64
-
65
65
  Style/MutableConstant:
66
66
  Enabled: false
67
+
68
+ Style/RedundantConstantBase:
69
+ Enabled: false
70
+
71
+ Style/TrailingCommaInArguments:
72
+ EnforcedStyleForMultiline: consistent_comma
73
+
74
+ Style/TrailingCommaInArrayLiteral:
75
+ EnforcedStyleForMultiline: consistent_comma
76
+
77
+ Style/TrailingCommaInHashLiteral:
78
+ EnforcedStyleForMultiline: consistent_comma
data/config/rspec.yml CHANGED
@@ -8,14 +8,15 @@ Metrics/BlockLength:
8
8
  RSpec/ExampleLength:
9
9
  Enabled: false
10
10
 
11
+ RSpec/IndexedLet:
12
+ Enabled: false
13
+
14
+ RSpec/Rails/InferredSpecType:
15
+ Enabled: false
16
+
11
17
  RSpec/MessageSpies:
12
18
  EnforcedStyle: receive
13
19
 
14
- RSpec/VariableName:
15
- AllowedPatterns:
16
- - ^Authorization
17
- - '\[\]$' # For array parameters in rswag like `let(:'<parameter_name>[]')`
18
-
19
20
  RSpec/MultipleMemoizedHelpers:
20
21
  Max: 17
21
22
 
@@ -24,3 +25,14 @@ RSpec/NamedSubject:
24
25
 
25
26
  RSpec/NestedGroups:
26
27
  Max: 5
28
+
29
+ # This cop does not correctly detect that RSwag creates
30
+ # extra contexts, reporting false positives for those tests
31
+ RSpec/ScatteredSetup:
32
+ Exclude:
33
+ - '{components/*/,}spec/api/**/*'
34
+
35
+ RSpec/VariableName:
36
+ AllowedPatterns:
37
+ - ^Authorization
38
+ - '\[\]$' # For array parameters in rswag like `let(:'<parameter_name>[]')`
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cobalt
5
- VERSION = '0.9.0'
5
+ VERSION = '1.0.1'
6
6
  end
7
7
  end
@@ -103,16 +103,18 @@ module RuboCop
103
103
  add_offense(const_node, message: default_message) if insecure_const?(const_node) && !digest_uuid?(const_node)
104
104
  end
105
105
 
106
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
106
107
  def on_send(send_node)
107
108
  if uuid_v3?(send_node) && !allowed_hash_functions.include?('md5')
108
109
  add_offense(send_node, message: "uuid_v3 uses MD5, which is not allowed. Prefer: #{allowed_hash_functions.join(', ')}")
109
110
  elsif uuid_v5?(send_node) && !allowed_hash_functions.include?('sha1')
110
111
  add_offense(send_node, message: "uuid_v5 uses SHA1, which is not allowed. Prefer: #{allowed_hash_functions.join(', ')}")
111
- elsif openssl_hmac_new?(send_node) && openssl_hmac_new_insecure?(send_node) ||
112
+ elsif (openssl_hmac_new?(send_node) && openssl_hmac_new_insecure?(send_node)) ||
112
113
  insecure_digest?(send_node) || insecure_hash_lookup?(send_node)
113
114
  add_offense(send_node, message: default_message)
114
115
  end
115
116
  end
117
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
116
118
 
117
119
  def default_message
118
120
  "This hash function is not allowed. Prefer: #{allowed_hash_functions.join(', ')}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cobalt-rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cobalt Engineering
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-21 00:00:00.000000000 Z
11
+ date: 2023-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.10'
83
83
  description: Ruby code linting for Cobalt Ruby repositories
84
- email:
84
+ email:
85
85
  executables: []
86
86
  extensions: []
87
87
  extra_rdoc_files: []
@@ -104,7 +104,7 @@ metadata:
104
104
  source_code_uri: https://github.com/cobalthq/cobalt-rubocop
105
105
  changelog_uri: https://github.com/cobalthq/cobalt-rubocop/blob/main/CHANGELOG.md
106
106
  rubygems_mfa_required: 'true'
107
- post_install_message:
107
+ post_install_message:
108
108
  rdoc_options: []
109
109
  require_paths:
110
110
  - lib
@@ -112,15 +112,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - ">="
114
114
  - !ruby/object:Gem::Version
115
- version: 2.5.0
115
+ version: 3.2.0
116
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  requirements:
118
118
  - - ">="
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  requirements: []
122
- rubygems_version: 3.1.6
123
- signing_key:
122
+ rubygems_version: 3.4.1
123
+ signing_key:
124
124
  specification_version: 4
125
125
  summary: Cobalt RuboCop
126
126
  test_files: []