cobalt-rubocop 0.8.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -0
- data/README.md +32 -16
- data/config/default.yml +31 -16
- data/config/rspec.yml +11 -5
- data/lib/rubocop/cobalt/version.rb +1 -1
- data/lib/rubocop/cop/cobalt/insecure_hash_algorithm.rb +3 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83361f0df69096d9c273be6b367c117e12ecf9f7f213d8d8838e6b4019332f73
|
4
|
+
data.tar.gz: 3699ad2b3cee6367a0ea14ac692437380f18f55405a5ae26a77a6831e32d0f99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 768f655514f4c7038d89af1cdc2d3f76bcf9df951b03f0050022adf241a639bb6ce9cb31d799aa148fcaed2e56198d46bd2e0b72de373b27203b8c344c5abe65
|
7
|
+
data.tar.gz: 28f1315e26ad48aa71ab4aca4771f6323a0e004994182ccffe7f4c19c4426c389f1b2ebb5f64c023b9cc849a13568e1b150f4416c34fd3294e18f1f67ee753ec
|
data/CHANGELOG.md
CHANGED
@@ -1,30 +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
|
+
|
30
|
+
## 0.9.0 (2023-04-20)
|
31
|
+
|
32
|
+
* Allow either hash syntax (legacy vs 3.1) as long as the use is consistent.
|
33
|
+
|
4
34
|
## 0.8.0 (2023-04-04)
|
35
|
+
|
5
36
|
* Relax dependency versions
|
6
37
|
|
7
38
|
## 0.7.0 (2022-08-24)
|
39
|
+
|
8
40
|
* Update Gem versions: ([#12](https://github.com/cobalthq/cobalt-rubocop/pull/12))
|
9
41
|
|
10
42
|
## 0.6.0 (2022-06-24)
|
43
|
+
|
11
44
|
* Update Gem versions: ([#11](https://github.com/cobalthq/cobalt-rubocop/pull/11))
|
12
45
|
* Security: Require Multi-Factor Authentication for RubyGems privileged operations ([#10](https://github.com/cobalthq/cobalt-rubocop/pull/10))
|
13
46
|
|
14
47
|
## 0.5.0 (2022-01-25)
|
48
|
+
|
15
49
|
* Update Gem versions ([#8](https://github.com/cobalthq/cobalt-rubocop/pull/8))
|
16
50
|
|
17
51
|
## 0.4.0 (2021-09-07)
|
52
|
+
|
18
53
|
* Update Gem versions ([#7](https://github.com/cobalthq/cobalt-rubocop/pull/7))
|
19
54
|
|
20
55
|
## 0.3.0 (2021-04-16)
|
56
|
+
|
21
57
|
* Update Rubocop and Rubocop Performance versions ([#6](https://github.com/cobalthq/cobalt-rubocop/pull/6))
|
22
58
|
|
23
59
|
## 0.2.0 (2021-04-14)
|
60
|
+
|
24
61
|
* Avoid warnings on RSpec `let` with parameter arrays ([#5](https://github.com/cobalthq/cobalt-rubocop/pull/5))
|
25
62
|
* Add new cop `InsecureHashAlgorithm`. ([#3](https://github.com/cobalthq/cobalt-rubocop/pull/3))
|
26
63
|
|
27
64
|
## 0.1.0 (2021-02-10)
|
65
|
+
|
28
66
|
* Introduce default rules
|
29
67
|
* Introduce rails rules
|
30
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
9
|
-
|
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,20 @@ Layout/MultilineOperationIndentation:
|
|
32
32
|
Layout/MultilineMethodCallIndentation:
|
33
33
|
EnforcedStyle: indented
|
34
34
|
|
35
|
-
Layout/
|
36
|
-
EnforcedStyle:
|
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
|
-
|
42
|
-
|
44
|
+
Naming/MethodName:
|
45
|
+
EnforcedStyle: snake_case
|
46
|
+
|
47
|
+
Style/ClassAndModuleChildren:
|
48
|
+
EnforcedStyle: nested
|
43
49
|
|
44
50
|
Style/Documentation:
|
45
51
|
Enabled: false
|
@@ -47,17 +53,26 @@ Style/Documentation:
|
|
47
53
|
Style/EachWithObject:
|
48
54
|
Enabled: false
|
49
55
|
|
50
|
-
Style/MutableConstant:
|
51
|
-
Enabled: false
|
52
|
-
|
53
56
|
Style/GuardClause:
|
54
57
|
Enabled: false
|
55
58
|
|
59
|
+
Style/HashSyntax:
|
60
|
+
EnforcedShorthandSyntax: consistent
|
61
|
+
|
56
62
|
Style/IfUnlessModifier:
|
57
63
|
Enabled: false
|
58
64
|
|
59
|
-
Style/
|
60
|
-
|
65
|
+
Style/MutableConstant:
|
66
|
+
Enabled: false
|
61
67
|
|
62
|
-
|
63
|
-
Enabled:
|
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>[]')`
|
@@ -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.
|
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-
|
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.
|
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.
|
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: []
|