silvercop 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -20
- data/README.md +39 -1
- data/config/rubocop.yml +18 -0
- metadata +39 -11
- data/config/default.yml +0 -3963
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a96d0efecbc1b615ed69b421bd49b8d5d6254ce
|
4
|
+
data.tar.gz: 73343926e61b8f7c6fc2deff9a7d109d3e8fd18e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e384842c52d79e163cbf83ee794c0f5fcbed272e543afe4b37ae86c98a77e8bd45dc3d5cb81949c8e93838ecc6140dd6da22083702a5c1eaad743572cedc1689
|
7
|
+
data.tar.gz: 64475e34de9e1f7e255a076afd17f5accf3309472d37341194be4e4bf0deac0d84310cafba21aa0917a6e7df87858cdd19458d5c8a3a92cd2a3c4b734b5135b4
|
data/.rubocop.yml
CHANGED
@@ -1,25 +1,10 @@
|
|
1
|
-
inherit_from: config/
|
1
|
+
inherit_from: config/rubocop.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
NewCops: enable
|
2
5
|
|
3
6
|
require:
|
4
7
|
- rubocop-performance
|
5
8
|
- rubocop-rails
|
9
|
+
- rubocop-rake
|
6
10
|
- rubocop-thread_safety
|
7
|
-
|
8
|
-
Style/Documentation:
|
9
|
-
Enabled: false
|
10
|
-
|
11
|
-
Layout/MultilineMethodCallIndentation:
|
12
|
-
EnforcedStyle: indented
|
13
|
-
|
14
|
-
Layout/HashAlignment:
|
15
|
-
EnforcedColonStyle: key
|
16
|
-
EnforcedLastArgumentHashStyle: ignore_implicit
|
17
|
-
|
18
|
-
Layout/ParameterAlignment:
|
19
|
-
EnforcedStyle: with_fixed_indentation
|
20
|
-
|
21
|
-
Layout/FirstArrayElementIndentation:
|
22
|
-
EnforcedStyle: consistent
|
23
|
-
|
24
|
-
Layout/FirstHashElementIndentation:
|
25
|
-
EnforcedStyle: consistent
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
After merging your changes to master, create a tag in the github repo. This will trigger a CircleCi build
|
21
21
|
which will push the gem to RubyGems.
|
22
22
|
|
23
|
-
**Note**: Make sure you update the `
|
23
|
+
**Note**: Make sure you update the gemspec `spec.version`, otherwise the build will fail saying the package already
|
24
24
|
exists.
|
25
25
|
|
26
26
|
## Usage
|
@@ -36,6 +36,28 @@ inherit_gem:
|
|
36
36
|
It is recommended to use this gem as `bundle exec rubocop -D`, which will output the violated
|
37
37
|
cop for that line of code
|
38
38
|
|
39
|
+
## Intent of Linting Configuration
|
40
|
+
|
41
|
+
Rubocop supports the generation of a todo file that helps add linting to a legacy project
|
42
|
+
without needing to address all the linting violations up front. However, this does split
|
43
|
+
the linting configuration across multiple files.
|
44
|
+
|
45
|
+
For consistency within Ruby projects, the following conventions should be followed:
|
46
|
+
|
47
|
+
#### .rubocop.yml
|
48
|
+
Inherits from silvercop's .rubocop.yml file and contains project level settings. Adding configuration to this file indicates the project is overriding silvercop's or rubocop's default configuration. These settings can change over time.
|
49
|
+
|
50
|
+
#### .rubocop_todo.yml
|
51
|
+
Contains explicit exclusions so that Rubocop can lint the project without addressing all violations within the project. Any cops or files that exist in this file are expected to be resolved and come into alignment with rules established within `.rubocop.yml`. Code modifications can temporarily allow for style alignment to be addressed as follow-up, depending on the scope of effort. Newly written code should follow styling and conventions, using this file as a last resort.
|
52
|
+
|
53
|
+
#### rubocop:disable, rubocop:enable
|
54
|
+
Used inline within code to locally disable and re-enable specific cops. This conveys the same intent as configuration within `.rubocop.yml` because generation and maintenance of `.rubocop_todo.yml` will not take into account locally disabled cops. If the intent of the styling changing is intended and permanent, the configuration must exist in `.rubocop.yml` and not use `rubocop:disable` locally.
|
55
|
+
|
56
|
+
#### rubocop:todo, rubocop:enable
|
57
|
+
Used inline within code to locally disable and re-enable specific cops. `rubocop:todo` is aliased to `rubocop:disable` but conveys the intent that addressing the styling or convention issue will be addressed as follow-up. Prefer using `rubocop_todo.yml` over this method.
|
58
|
+
|
59
|
+
## Creating TODO List
|
60
|
+
|
39
61
|
If many offenses are detected, it is recommended to generate a TODO list that can be handled over
|
40
62
|
time without needing to fix all of the existing offenses. This can be done by generating and
|
41
63
|
including the following config:
|
@@ -45,6 +67,22 @@ including the following config:
|
|
45
67
|
Then add `inherit_from: .rubocop_todo.yml` to your `.rubocop.yml` file. Adding `--exclude-limit 10000` can help prevent
|
46
68
|
the generated config from disabling cops entirely with `Enabled: false`.
|
47
69
|
|
70
|
+
Many of the `Metric/*` cops will analyze the code to find the worst offender and make that the new threshold. It is
|
71
|
+
recommended to set a sane limit and manually exclude violations beyond that sane threshold. For example, generating the
|
72
|
+
todo file in one repo attempts to set the `Metrics/LineLength` at a `Max` of 295 because that's the longest method in
|
73
|
+
the code base, which means the cop will no longer trigger any violations unless methods exceed 295 lines. Instead, set
|
74
|
+
the `Max` to something which creates a balance between a reasonable length and number of violations. As those violations
|
75
|
+
get addressed, the threshold can be tightened toward the organization/project standard or to the default. In this
|
76
|
+
example, the `Max` was set to 20 with an eventual goal of 10.
|
77
|
+
|
78
|
+
An example of doing this and easily capturing the violations is to set the `Max` to 20 in the todo file, then run:
|
79
|
+
`bundle exec rubocop -D --only Metrics/MethodLength --format files`
|
80
|
+
|
81
|
+
which will output a list of files that can then be pasted as the `Exclude` list in the todo file.
|
82
|
+
|
83
|
+
Putting these defaults in `.rubocop.yml` can help to remember the current threshold and indicate the target goal, but
|
84
|
+
that `Max` will not be taken into account when generating the todo file.
|
85
|
+
|
48
86
|
Example usage of configuration inside Ruby project:
|
49
87
|
|
50
88
|
```ruby
|
data/config/rubocop.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Style/Documentation:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Layout/MultilineMethodCallIndentation:
|
5
|
+
EnforcedStyle: indented
|
6
|
+
|
7
|
+
Layout/HashAlignment:
|
8
|
+
EnforcedColonStyle: key
|
9
|
+
EnforcedLastArgumentHashStyle: ignore_implicit
|
10
|
+
|
11
|
+
Layout/ParameterAlignment:
|
12
|
+
EnforcedStyle: with_fixed_indentation
|
13
|
+
|
14
|
+
Layout/FirstArrayElementIndentation:
|
15
|
+
EnforcedStyle: consistent
|
16
|
+
|
17
|
+
Layout/FirstHashElementIndentation:
|
18
|
+
EnforcedStyle: consistent
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: silvercop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Silvercar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,56 +16,84 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.44.0
|
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:
|
26
|
+
version: 1.44.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop-performance
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.15.2
|
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: 1.
|
40
|
+
version: 1.15.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rubocop-rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.4
|
47
|
+
version: 2.17.4
|
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.4
|
54
|
+
version: 2.17.4
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop-rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.6.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.6.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.18.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.18.1
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: rubocop-thread_safety
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
87
|
- - '='
|
60
88
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
89
|
+
version: 0.4.4
|
62
90
|
type: :runtime
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
94
|
- - '='
|
67
95
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
96
|
+
version: 0.4.4
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: rake
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,7 +131,7 @@ extra_rdoc_files: []
|
|
103
131
|
files:
|
104
132
|
- ".rubocop.yml"
|
105
133
|
- README.md
|
106
|
-
- config/
|
134
|
+
- config/rubocop.yml
|
107
135
|
- lib/silvercop.rb
|
108
136
|
homepage: https://github.com/silvercar/silvercop
|
109
137
|
licenses:
|