cobalt-rubocop 0.9.0 → 1.0.0

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: 6e362d3b2d73010a79138252128e40a847240a636e0bf47b66420ff8e3fadece
4
- data.tar.gz: c3e8d123ceb792de6b5f47838b9fcc119641875f9621cd5c495c64d06ba8f493
3
+ metadata.gz: 83361f0df69096d9c273be6b367c117e12ecf9f7f213d8d8838e6b4019332f73
4
+ data.tar.gz: 3699ad2b3cee6367a0ea14ac692437380f18f55405a5ae26a77a6831e32d0f99
5
5
  SHA512:
6
- metadata.gz: 62efc720640cc2f3e29504ecc0fd81eb01ace1b820d3532c336b04cd99361625a9b97bdebb45f00dea9adc9761c89f03b8d3dd6a9515fdfa7b6b9148c45a67dc
7
- data.tar.gz: ae22d0536f332f7bc4dd3a8a915424da94b215963e5c390c26570a55be26d2707f1883bc363d9e2ce7c7b3b87f40a93eb3233d8a2e14b72c695e339620063526
6
+ metadata.gz: 768f655514f4c7038d89af1cdc2d3f76bcf9df951b03f0050022adf241a639bb6ce9cb31d799aa148fcaed2e56198d46bd2e0b72de373b27203b8c344c5abe65
7
+ data.tar.gz: 28f1315e26ad48aa71ab4aca4771f6323a0e004994182ccffe7f4c19c4426c389f1b2ebb5f64c023b9cc849a13568e1b150f4416c34fd3294e18f1f67ee753ec
data/CHANGELOG.md CHANGED
@@ -1,33 +1,68 @@
1
1
  # CHANGELOG
2
+
2
3
  ## main (unreleased)
3
4
 
5
+ ## 1.0.0 (2023-06-09)
6
+
7
+ * Bump required ruby version to 3.2.x
8
+ * Add default settings:
9
+
10
+ ```yaml
11
+ RSpec/IndexedLet:
12
+ Enabled: false
13
+
14
+ RSpec/Rails/InferredSpecType:
15
+ Enabled: false
16
+
17
+ Style/RedundantConstantBase:
18
+ Enabled: false
19
+
20
+ Style/TrailingCommaInArguments:
21
+ EnforcedStyleForMultiline: consistent_comma
22
+
23
+ Style/TrailingCommaInArrayLiteral:
24
+ EnforcedStyleForMultiline: consistent_comma
25
+
26
+ Style/TrailingCommaInHashLiteral:
27
+ EnforcedStyleForMultiline: consistent_comma
28
+ ```
29
+
4
30
  ## 0.9.0 (2023-04-20)
31
+
5
32
  * Allow either hash syntax (legacy vs 3.1) as long as the use is consistent.
6
33
 
7
34
  ## 0.8.0 (2023-04-04)
35
+
8
36
  * Relax dependency versions
9
37
 
10
38
  ## 0.7.0 (2022-08-24)
39
+
11
40
  * Update Gem versions: ([#12](https://github.com/cobalthq/cobalt-rubocop/pull/12))
12
41
 
13
42
  ## 0.6.0 (2022-06-24)
43
+
14
44
  * Update Gem versions: ([#11](https://github.com/cobalthq/cobalt-rubocop/pull/11))
15
45
  * Security: Require Multi-Factor Authentication for RubyGems privileged operations ([#10](https://github.com/cobalthq/cobalt-rubocop/pull/10))
16
46
 
17
47
  ## 0.5.0 (2022-01-25)
48
+
18
49
  * Update Gem versions ([#8](https://github.com/cobalthq/cobalt-rubocop/pull/8))
19
50
 
20
51
  ## 0.4.0 (2021-09-07)
52
+
21
53
  * Update Gem versions ([#7](https://github.com/cobalthq/cobalt-rubocop/pull/7))
22
54
 
23
55
  ## 0.3.0 (2021-04-16)
56
+
24
57
  * Update Rubocop and Rubocop Performance versions ([#6](https://github.com/cobalthq/cobalt-rubocop/pull/6))
25
58
 
26
59
  ## 0.2.0 (2021-04-14)
60
+
27
61
  * Avoid warnings on RSpec `let` with parameter arrays ([#5](https://github.com/cobalthq/cobalt-rubocop/pull/5))
28
62
  * Add new cop `InsecureHashAlgorithm`. ([#3](https://github.com/cobalthq/cobalt-rubocop/pull/3))
29
63
 
30
64
  ## 0.1.0 (2021-02-10)
65
+
31
66
  * Introduce default rules
32
67
  * Introduce rails rules
33
68
  * 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,8 @@ RSpec/NamedSubject:
24
25
 
25
26
  RSpec/NestedGroups:
26
27
  Max: 5
28
+
29
+ RSpec/VariableName:
30
+ AllowedPatterns:
31
+ - ^Authorization
32
+ - '\[\]$' # 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.0'
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.0
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-06-07 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.12
123
+ signing_key:
124
124
  specification_version: 4
125
125
  summary: Cobalt RuboCop
126
126
  test_files: []