kpn-style 0.1.7 → 0.1.9
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 +4 -4
- data/.gitignore +14 -14
- data/Gemfile +4 -4
- data/LICENSE +201 -201
- data/README.md +114 -106
- data/Rakefile +1 -1
- data/kpn_style.gemspec +32 -32
- data/lib/kpn/style/version.rb +3 -3
- data/lib/kpn/style.rb +5 -5
- data/ruby-2.1.yml +107 -107
- data/ruby-2.4-strict.yml +107 -107
- data/ruby-2.4.yml +109 -109
- data/ruby-2.5.yml +268 -268
- data/ruby-2.7.yml +554 -0
- metadata +12 -11
data/README.md
CHANGED
@@ -1,106 +1,114 @@
|
|
1
|
-
# kpn-style
|
2
|
-
|
3
|
-
kpn shared style configs.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
group :test, :development do
|
11
|
-
gem 'kpn-style'
|
12
|
-
end
|
13
|
-
```
|
14
|
-
|
15
|
-
Or, for a Ruby library, add this to your gemspec:
|
16
|
-
|
17
|
-
```ruby
|
18
|
-
spec.add_development_dependency 'kpn-style'
|
19
|
-
```
|
20
|
-
|
21
|
-
And then run:
|
22
|
-
|
23
|
-
```bash
|
24
|
-
$ bundle install
|
25
|
-
```
|
26
|
-
|
27
|
-
## Usage
|
28
|
-
|
29
|
-
Create a `.rubocop.yml` with the following directives:
|
30
|
-
|
31
|
-
```yaml
|
32
|
-
inherit_gem:
|
33
|
-
kpn-style:
|
34
|
-
- ruby-2.1.yml
|
35
|
-
```
|
36
|
-
|
37
|
-
Or for Ruby 2.4:
|
38
|
-
|
39
|
-
```yaml
|
40
|
-
inherit_gem:
|
41
|
-
kpn-style:
|
42
|
-
- ruby-2.4.yml
|
43
|
-
```
|
44
|
-
|
45
|
-
Or for Ruby 2.5:
|
46
|
-
|
47
|
-
```yaml
|
48
|
-
inherit_gem:
|
49
|
-
kpn-style:
|
50
|
-
- ruby-2.5.yml
|
51
|
-
```
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
```
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
1
|
+
# kpn-style
|
2
|
+
|
3
|
+
kpn shared style configs.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
group :test, :development do
|
11
|
+
gem 'kpn-style'
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
Or, for a Ruby library, add this to your gemspec:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
spec.add_development_dependency 'kpn-style'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then run:
|
22
|
+
|
23
|
+
```bash
|
24
|
+
$ bundle install
|
25
|
+
```
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Create a `.rubocop.yml` with the following directives:
|
30
|
+
|
31
|
+
```yaml
|
32
|
+
inherit_gem:
|
33
|
+
kpn-style:
|
34
|
+
- ruby-2.1.yml
|
35
|
+
```
|
36
|
+
|
37
|
+
Or for Ruby 2.4:
|
38
|
+
|
39
|
+
```yaml
|
40
|
+
inherit_gem:
|
41
|
+
kpn-style:
|
42
|
+
- ruby-2.4.yml
|
43
|
+
```
|
44
|
+
|
45
|
+
Or for Ruby 2.5:
|
46
|
+
|
47
|
+
```yaml
|
48
|
+
inherit_gem:
|
49
|
+
kpn-style:
|
50
|
+
- ruby-2.5.yml
|
51
|
+
```
|
52
|
+
|
53
|
+
Or for Ruby 2.7:
|
54
|
+
|
55
|
+
```yaml
|
56
|
+
inherit_gem:
|
57
|
+
kpn-style:
|
58
|
+
- ruby-2.7.yml
|
59
|
+
```
|
60
|
+
|
61
|
+
Now, run:
|
62
|
+
|
63
|
+
```bash
|
64
|
+
$ bundle exec rubocop
|
65
|
+
|
66
|
+
or
|
67
|
+
|
68
|
+
$ rake rubocop
|
69
|
+
```
|
70
|
+
|
71
|
+
You do not need to include rubocop directly in your application's dependencies. kpn-style will include a specific version of `rubocop` and `rubocop-rspec` that is shared across all projects.
|
72
|
+
|
73
|
+
## Style overrides
|
74
|
+
|
75
|
+
Sometimes you need to override style rules. RuboCop have a nice inheritance hierachy so you can override the default settings.
|
76
|
+
The hierachy is:
|
77
|
+
|
78
|
+
```
|
79
|
+
inherit_gem -> inherit_from -> local rules
|
80
|
+
```
|
81
|
+
|
82
|
+
For example:
|
83
|
+
|
84
|
+
```yaml
|
85
|
+
inherit_gem:
|
86
|
+
kpn-style:
|
87
|
+
- ruby-2.7.yml
|
88
|
+
|
89
|
+
inherit_from: .rubocop_todo.yml
|
90
|
+
|
91
|
+
AllCops:
|
92
|
+
Exclude:
|
93
|
+
- exclude/file.rb
|
94
|
+
```
|
95
|
+
|
96
|
+
## Update gem
|
97
|
+
|
98
|
+
1. Update the ruby-2.X.yml file
|
99
|
+
2. Update the version parameter `spec.version` in the `kpn_style.gemspec`
|
100
|
+
3. Tag the release: `git tag VERSION`
|
101
|
+
4. Push changes: `git push --tags`
|
102
|
+
5. Update the release notes on GitHub.com
|
103
|
+
6. Build and publish:
|
104
|
+
|
105
|
+
```bash
|
106
|
+
gem build kpn_style.gemspec
|
107
|
+
gem push kpn-style-x.x.x.gem
|
108
|
+
```
|
109
|
+
|
110
|
+
To push gems to rubygems.org you can use a `~/.gem/credentials` with the `rubygems_api_key`. You can find a small how to on the Profile edit page https://rubygems.org/profile/edit in the section `API ACCESS`.
|
111
|
+
|
112
|
+
### Special thanks
|
113
|
+
|
114
|
+
A special thanks to https://github.com/percy/percy-style/ for the idea and template of this Gem.
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
1
|
+
require 'bundler/gem_tasks'
|
data/kpn_style.gemspec
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
lib = File.expand_path('lib', __dir__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
|
4
|
-
Gem::Specification.new do |spec|
|
5
|
-
spec.name = 'kpn-style'
|
6
|
-
spec.version = '0.1.
|
7
|
-
spec.authors = ['kpn']
|
8
|
-
spec.email = ['noreply@kpn.com']
|
9
|
-
|
10
|
-
spec.summary = 'kpn style guides and shared style configs.'
|
11
|
-
spec.homepage = 'https://github.com/kpn-puppet/gem-kpn-style'
|
12
|
-
spec.license = 'Apache-2.0'
|
13
|
-
|
14
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
15
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
16
|
-
if spec.respond_to?(:metadata)
|
17
|
-
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
|
-
else
|
19
|
-
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
20
|
-
'public gem pushes.'
|
21
|
-
end
|
22
|
-
|
23
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
24
|
-
f.match(%r{^(test|spec|features)/})
|
25
|
-
end
|
26
|
-
spec.bindir = 'exe'
|
27
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
-
spec.require_paths = ['lib']
|
29
|
-
|
30
|
-
spec.add_dependency 'rubocop', '~>
|
31
|
-
spec.add_dependency 'rubocop-rspec', '~>
|
32
|
-
end
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'kpn-style'
|
6
|
+
spec.version = '0.1.9'
|
7
|
+
spec.authors = ['kpn']
|
8
|
+
spec.email = ['noreply@kpn.com']
|
9
|
+
|
10
|
+
spec.summary = 'kpn style guides and shared style configs.'
|
11
|
+
spec.homepage = 'https://github.com/kpn-puppet/gem-kpn-style'
|
12
|
+
spec.license = 'Apache-2.0'
|
13
|
+
|
14
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
15
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
16
|
+
if spec.respond_to?(:metadata)
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
|
+
else
|
19
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
20
|
+
'public gem pushes.'
|
21
|
+
end
|
22
|
+
|
23
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
24
|
+
f.match(%r{^(test|spec|features)/})
|
25
|
+
end
|
26
|
+
spec.bindir = 'exe'
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
|
30
|
+
spec.add_dependency 'rubocop', '~> 1.38'
|
31
|
+
spec.add_dependency 'rubocop-rspec', '~> 2.15'
|
32
|
+
end
|
data/lib/kpn/style/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Kpn::Style
|
2
|
-
VERSION = '0.1.
|
3
|
-
end
|
1
|
+
module Kpn::Style
|
2
|
+
VERSION = '0.1.9'.freeze
|
3
|
+
end
|
data/lib/kpn/style.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
# Kpn::Style
|
3
|
-
module Kpn::Style
|
4
|
-
# Nothing here
|
5
|
-
end
|
1
|
+
|
2
|
+
# Kpn::Style
|
3
|
+
module Kpn::Style
|
4
|
+
# Nothing here
|
5
|
+
end
|
data/ruby-2.1.yml
CHANGED
@@ -1,107 +1,107 @@
|
|
1
|
-
---
|
2
|
-
require: rubocop-rspec
|
3
|
-
AllCops:
|
4
|
-
DisplayCopNames: true
|
5
|
-
TargetRubyVersion: '2.1'
|
6
|
-
Include:
|
7
|
-
- "./**/*.rb"
|
8
|
-
Exclude:
|
9
|
-
- bin/*
|
10
|
-
- ".vendor/**/*"
|
11
|
-
- Gemfile
|
12
|
-
- Rakefile
|
13
|
-
- pkg/**/*
|
14
|
-
- spec/fixtures/**/*
|
15
|
-
- vendor/**/*
|
16
|
-
Metrics/LineLength:
|
17
|
-
Description: People have wide screens, use them.
|
18
|
-
Max: 240
|
19
|
-
RSpec/BeforeAfterAll:
|
20
|
-
Description: Beware of using after(:all) as it may cause state to leak between tests.
|
21
|
-
A necessary evil in acceptance testing.
|
22
|
-
Exclude:
|
23
|
-
- spec/acceptance/**/*.rb
|
24
|
-
RSpec/HookArgument:
|
25
|
-
Description: Prefer explicit :each argument, matching existing module's style
|
26
|
-
EnforcedStyle: each
|
27
|
-
Style/BlockDelimiters:
|
28
|
-
Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
|
29
|
-
be consistent then.
|
30
|
-
EnforcedStyle: braces_for_chaining
|
31
|
-
Style/ClassAndModuleChildren:
|
32
|
-
Description: Compact style reduces the required amount of indentation.
|
33
|
-
EnforcedStyle: compact
|
34
|
-
Style/EmptyElse:
|
35
|
-
Description: Enforce against empty else clauses, but allow `nil` for clarity.
|
36
|
-
EnforcedStyle: empty
|
37
|
-
Style/FormatString:
|
38
|
-
Description: Following the main puppet project's style, prefer the % format format.
|
39
|
-
EnforcedStyle: percent
|
40
|
-
Style/FormatStringToken:
|
41
|
-
Description: Following the main puppet project's style, prefer the simpler template
|
42
|
-
tokens over annotated ones.
|
43
|
-
EnforcedStyle: template
|
44
|
-
Style/Lambda:
|
45
|
-
Description: Prefer the keyword for easier discoverability.
|
46
|
-
EnforcedStyle: literal
|
47
|
-
Style/RegexpLiteral:
|
48
|
-
Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168
|
49
|
-
EnforcedStyle: percent_r
|
50
|
-
Style/TernaryParentheses:
|
51
|
-
Description: Checks for use of parentheses around ternary conditions. Enforce parentheses
|
52
|
-
on complex expressions for better readability, but seriously consider breaking
|
53
|
-
it up.
|
54
|
-
EnforcedStyle: require_parentheses_when_complex
|
55
|
-
Style/TrailingCommaInArguments:
|
56
|
-
Description: Prefer always trailing comma on multiline argument lists. This makes
|
57
|
-
diffs, and re-ordering nicer.
|
58
|
-
EnforcedStyleForMultiline: comma
|
59
|
-
Style/TrailingCommaInArrayLiteral:
|
60
|
-
EnforcedStyleForMultiline: comma
|
61
|
-
Style/TrailingCommaInHashLiteral:
|
62
|
-
EnforcedStyleForMultiline: comma
|
63
|
-
Style/SymbolArray:
|
64
|
-
Description: Using percent style obscures symbolic intent of array's contents.
|
65
|
-
EnforcedStyle: brackets
|
66
|
-
RSpec/MessageSpies:
|
67
|
-
EnforcedStyle: receive
|
68
|
-
Style/CollectionMethods:
|
69
|
-
Enabled: true
|
70
|
-
Style/MethodCalledOnDoEndBlock:
|
71
|
-
Enabled: true
|
72
|
-
Style/StringMethods:
|
73
|
-
Enabled: true
|
74
|
-
Layout/EndOfLine:
|
75
|
-
EnforcedStyle: lf
|
76
|
-
Metrics/AbcSize:
|
77
|
-
Enabled: false
|
78
|
-
Metrics/BlockLength:
|
79
|
-
Enabled: false
|
80
|
-
Metrics/ClassLength:
|
81
|
-
Enabled: false
|
82
|
-
Metrics/CyclomaticComplexity:
|
83
|
-
Enabled: false
|
84
|
-
Metrics/MethodLength:
|
85
|
-
Enabled: false
|
86
|
-
Metrics/ModuleLength:
|
87
|
-
Enabled: false
|
88
|
-
Metrics/ParameterLists:
|
89
|
-
Enabled: false
|
90
|
-
Metrics/PerceivedComplexity:
|
91
|
-
Enabled: false
|
92
|
-
RSpec/DescribeClass:
|
93
|
-
Enabled: false
|
94
|
-
RSpec/ExampleLength:
|
95
|
-
Enabled: false
|
96
|
-
RSpec/MessageExpectation:
|
97
|
-
Enabled: false
|
98
|
-
RSpec/MultipleExpectations:
|
99
|
-
Enabled: false
|
100
|
-
RSpec/NestedGroups:
|
101
|
-
Enabled: false
|
102
|
-
Style/AsciiComments:
|
103
|
-
Enabled: false
|
104
|
-
Style/IfUnlessModifier:
|
105
|
-
Enabled: false
|
106
|
-
Style/SymbolProc:
|
107
|
-
Enabled: false
|
1
|
+
---
|
2
|
+
require: rubocop-rspec
|
3
|
+
AllCops:
|
4
|
+
DisplayCopNames: true
|
5
|
+
TargetRubyVersion: '2.1'
|
6
|
+
Include:
|
7
|
+
- "./**/*.rb"
|
8
|
+
Exclude:
|
9
|
+
- bin/*
|
10
|
+
- ".vendor/**/*"
|
11
|
+
- Gemfile
|
12
|
+
- Rakefile
|
13
|
+
- pkg/**/*
|
14
|
+
- spec/fixtures/**/*
|
15
|
+
- vendor/**/*
|
16
|
+
Metrics/LineLength:
|
17
|
+
Description: People have wide screens, use them.
|
18
|
+
Max: 240
|
19
|
+
RSpec/BeforeAfterAll:
|
20
|
+
Description: Beware of using after(:all) as it may cause state to leak between tests.
|
21
|
+
A necessary evil in acceptance testing.
|
22
|
+
Exclude:
|
23
|
+
- spec/acceptance/**/*.rb
|
24
|
+
RSpec/HookArgument:
|
25
|
+
Description: Prefer explicit :each argument, matching existing module's style
|
26
|
+
EnforcedStyle: each
|
27
|
+
Style/BlockDelimiters:
|
28
|
+
Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
|
29
|
+
be consistent then.
|
30
|
+
EnforcedStyle: braces_for_chaining
|
31
|
+
Style/ClassAndModuleChildren:
|
32
|
+
Description: Compact style reduces the required amount of indentation.
|
33
|
+
EnforcedStyle: compact
|
34
|
+
Style/EmptyElse:
|
35
|
+
Description: Enforce against empty else clauses, but allow `nil` for clarity.
|
36
|
+
EnforcedStyle: empty
|
37
|
+
Style/FormatString:
|
38
|
+
Description: Following the main puppet project's style, prefer the % format format.
|
39
|
+
EnforcedStyle: percent
|
40
|
+
Style/FormatStringToken:
|
41
|
+
Description: Following the main puppet project's style, prefer the simpler template
|
42
|
+
tokens over annotated ones.
|
43
|
+
EnforcedStyle: template
|
44
|
+
Style/Lambda:
|
45
|
+
Description: Prefer the keyword for easier discoverability.
|
46
|
+
EnforcedStyle: literal
|
47
|
+
Style/RegexpLiteral:
|
48
|
+
Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168
|
49
|
+
EnforcedStyle: percent_r
|
50
|
+
Style/TernaryParentheses:
|
51
|
+
Description: Checks for use of parentheses around ternary conditions. Enforce parentheses
|
52
|
+
on complex expressions for better readability, but seriously consider breaking
|
53
|
+
it up.
|
54
|
+
EnforcedStyle: require_parentheses_when_complex
|
55
|
+
Style/TrailingCommaInArguments:
|
56
|
+
Description: Prefer always trailing comma on multiline argument lists. This makes
|
57
|
+
diffs, and re-ordering nicer.
|
58
|
+
EnforcedStyleForMultiline: comma
|
59
|
+
Style/TrailingCommaInArrayLiteral:
|
60
|
+
EnforcedStyleForMultiline: comma
|
61
|
+
Style/TrailingCommaInHashLiteral:
|
62
|
+
EnforcedStyleForMultiline: comma
|
63
|
+
Style/SymbolArray:
|
64
|
+
Description: Using percent style obscures symbolic intent of array's contents.
|
65
|
+
EnforcedStyle: brackets
|
66
|
+
RSpec/MessageSpies:
|
67
|
+
EnforcedStyle: receive
|
68
|
+
Style/CollectionMethods:
|
69
|
+
Enabled: true
|
70
|
+
Style/MethodCalledOnDoEndBlock:
|
71
|
+
Enabled: true
|
72
|
+
Style/StringMethods:
|
73
|
+
Enabled: true
|
74
|
+
Layout/EndOfLine:
|
75
|
+
EnforcedStyle: lf
|
76
|
+
Metrics/AbcSize:
|
77
|
+
Enabled: false
|
78
|
+
Metrics/BlockLength:
|
79
|
+
Enabled: false
|
80
|
+
Metrics/ClassLength:
|
81
|
+
Enabled: false
|
82
|
+
Metrics/CyclomaticComplexity:
|
83
|
+
Enabled: false
|
84
|
+
Metrics/MethodLength:
|
85
|
+
Enabled: false
|
86
|
+
Metrics/ModuleLength:
|
87
|
+
Enabled: false
|
88
|
+
Metrics/ParameterLists:
|
89
|
+
Enabled: false
|
90
|
+
Metrics/PerceivedComplexity:
|
91
|
+
Enabled: false
|
92
|
+
RSpec/DescribeClass:
|
93
|
+
Enabled: false
|
94
|
+
RSpec/ExampleLength:
|
95
|
+
Enabled: false
|
96
|
+
RSpec/MessageExpectation:
|
97
|
+
Enabled: false
|
98
|
+
RSpec/MultipleExpectations:
|
99
|
+
Enabled: false
|
100
|
+
RSpec/NestedGroups:
|
101
|
+
Enabled: false
|
102
|
+
Style/AsciiComments:
|
103
|
+
Enabled: false
|
104
|
+
Style/IfUnlessModifier:
|
105
|
+
Enabled: false
|
106
|
+
Style/SymbolProc:
|
107
|
+
Enabled: false
|